summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-04-10 21:20:04 +0200
committerDavid Robillard <d@drobilla.net>2020-04-10 21:58:55 +0200
commit4912f67839be6992b09a80a7b605cfb26f8024d3 (patch)
tree04f356e482bf387be40ceeec98be039236162679
parent967c197a1f53903ccbda84e32357f1d2b221a7f1 (diff)
downloadsuil-4912f67839be6992b09a80a7b605cfb26f8024d3.tar.gz
suil-4912f67839be6992b09a80a7b605cfb26f8024d3.tar.bz2
suil-4912f67839be6992b09a80a7b605cfb26f8024d3.zip
Ensure that XSizeHints are set and updated
This fixes the following regression introduced in db07a21d484: * The window may not have been realized when wrapper_wrap is called, in which case XSizeHints were not set. * Changes to XSizeHints were never queried, so the original mininum size was enforced even when the window called ui:resize().
-rw-r--r--NEWS1
-rw-r--r--src/x11_in_gtk2.c66
2 files changed, 43 insertions, 24 deletions
diff --git a/NEWS b/NEWS
index 2f86caa..024350d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
suil (0.10.7) unstable;
+ * Fix X11 in Gtk size regressions (thanks Robin Gareus)
* Fix compilation on MacOS older than 10.12
* Fix drag and drop for X11 in Gtk
diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c
index d8f9578..612eefa 100644
--- a/src/x11_in_gtk2.c
+++ b/src/x11_in_gtk2.c
@@ -49,6 +49,7 @@ struct _SuilX11Wrapper {
SuilX11SizeHints custom_size;
SuilX11SizeHints base_size;
SuilX11SizeHints min_size;
+ bool query_wm;
};
struct _SuilX11WrapperClass {
@@ -235,6 +236,38 @@ idle_size_request(gpointer user_data)
return FALSE;
}
+/// Read XSizeHints and store the values for later use
+static void
+query_wm_hints(SuilX11Wrapper* wrap)
+{
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(wrap->plug));
+ XSizeHints hints = {0};
+ long supplied = 0;
+
+ XGetWMNormalHints(GDK_WINDOW_XDISPLAY(window),
+ (Window)wrap->instance->ui_widget,
+ &hints,
+ &supplied);
+
+ if (hints.flags & PMaxSize) {
+ wrap->max_size.width = hints.max_width;
+ wrap->max_size.height = hints.max_height;
+ wrap->max_size.is_set = true;
+ }
+ if (hints.flags & PBaseSize) {
+ wrap->base_size.width = hints.base_width;
+ wrap->base_size.height = hints.base_height;
+ wrap->base_size.is_set = true;
+ }
+ if (hints.flags & PMinSize) {
+ wrap->min_size.width = hints.min_width;
+ wrap->min_size.height = hints.min_height;
+ wrap->min_size.is_set = true;
+ }
+
+ wrap->query_wm = false;
+}
+
static void
forward_size_request(SuilX11Wrapper* socket,
GtkAllocation* allocation)
@@ -245,6 +278,10 @@ forward_size_request(SuilX11Wrapper* socket,
int width = allocation->width;
int height = allocation->height;
+ if (socket->query_wm) {
+ query_wm_hints(socket);
+ }
+
if (socket->max_size.is_set) {
width = MIN(width, socket->max_size.width);
height = MIN(height, socket->max_size.height);
@@ -367,6 +404,7 @@ suil_x11_wrapper_init(SuilX11Wrapper* self)
self->custom_size = (SuilX11SizeHints){false, 0, 0};
self->base_size = (SuilX11SizeHints){false, 0, 0};
self->min_size = (SuilX11SizeHints){false, 0, 0};
+ self->query_wm = true;
}
static int
@@ -378,6 +416,9 @@ wrapper_resize(LV2UI_Feature_Handle handle, int width, int height)
wrap->custom_size.height = height;
wrap->custom_size.is_set = width > 0 && height > 0;
+ // Assume the plugin has also updated min/max size constraints
+ wrap->query_wm = true;
+
gtk_widget_queue_resize(GTK_WIDGET(handle));
return 0;
}
@@ -403,30 +444,7 @@ wrapper_wrap(SuilWrapper* wrapper,
wrap->instance = instance;
if (x_window_is_valid(wrap)) {
- // Read XSizeHints and store the values for later use
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(wrap->plug));
- XSizeHints hints;
- memset(&hints, 0, sizeof(hints));
- long supplied;
- XGetWMNormalHints(GDK_WINDOW_XDISPLAY(window),
- (Window)wrap->instance->ui_widget,
- &hints,
- &supplied);
- if (hints.flags & PMaxSize) {
- wrap->max_size.width = hints.max_width;
- wrap->max_size.height = hints.max_height;
- wrap->max_size.is_set = true;
- }
- if (hints.flags & PBaseSize) {
- wrap->base_size.width = hints.base_width;
- wrap->base_size.height = hints.base_height;
- wrap->base_size.is_set = true;
- }
- if (hints.flags & PMinSize) {
- wrap->min_size.width = hints.min_width;
- wrap->min_size.height = hints.min_height;
- wrap->min_size.is_set = true;
- }
+ query_wm_hints(wrap);
}
const LV2UI_Idle_Interface* idle_iface = NULL;