diff options
Diffstat (limited to 'src/x11_in_gtk3.c')
-rw-r--r-- | src/x11_in_gtk3.c | 55 |
1 files changed, 14 insertions, 41 deletions
diff --git a/src/x11_in_gtk3.c b/src/x11_in_gtk3.c index 5ac5306..4addc03 100644 --- a/src/x11_in_gtk3.c +++ b/src/x11_in_gtk3.c @@ -3,6 +3,7 @@ #include "suil_internal.h" #include "warnings.h" +#include "x11_util.h" #include <lv2/core/lv2.h> #include <lv2/options/options.h> @@ -24,7 +25,6 @@ SUIL_DISABLE_GTK_WARNINGS #include <gtk/gtkx.h> SUIL_RESTORE_WARNINGS -#include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -57,39 +57,6 @@ suil_x11_wrapper_get_type(void); // Accessor for SUIL_TYPE_X11_WRAPPER G_DEFINE_TYPE(SuilX11Wrapper, suil_x11_wrapper, GTK_TYPE_SOCKET) -/** - Check if 'swallowed' subwindow is known to the X server. - - Gdk/GTK can mark the window as realized, mapped and visible even though - there is no window-ID on the X server for it yet. Then, - suil_x11_on_size_allocate() will cause a "BadWinow" X error. -*/ -static bool -x_window_is_valid(SuilX11Wrapper* socket) -{ - GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(socket->plug)); - Window root = 0; - Window parent = 0; - Window* children = NULL; - unsigned childcount = 0; - - XQueryTree(GDK_WINDOW_XDISPLAY(window), - GDK_WINDOW_XID(window), - &root, - &parent, - &children, - &childcount); - for (unsigned i = 0; i < childcount; ++i) { - if (children[i] == (Window)socket->instance->ui_widget) { - XFree(children); - return true; - } - } - - XFree(children); - return false; -} - static gboolean on_plug_removed(GtkSocket* sock, gpointer data) { @@ -212,7 +179,9 @@ static void forward_size_request(SuilX11Wrapper* socket, GtkAllocation* allocation) { GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(socket->plug)); - if (x_window_is_valid(socket)) { + if (suil_x11_is_valid_child(GDK_WINDOW_XDISPLAY(window), + GDK_WINDOW_XID(window), + (Window)socket->instance->ui_widget)) { // Calculate allocation size constrained to X11 limits for widget int width = allocation->width; int height = allocation->height; @@ -281,9 +250,11 @@ suil_x11_wrapper_get_preferred_width(GtkWidget* widget, gint* minimum_width, gint* natural_width) { - SuilX11Wrapper* const self = SUIL_X11_WRAPPER(widget); - if (x_window_is_valid(self)) { - GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(self->plug)); + SuilX11Wrapper* const self = SUIL_X11_WRAPPER(widget); + GdkWindow* const window = gtk_widget_get_window(GTK_WIDGET(self->plug)); + if (suil_x11_is_valid_child(GDK_WINDOW_XDISPLAY(window), + GDK_WINDOW_XID(window), + (Window)self->instance->ui_widget)) { XSizeHints hints; memset(&hints, 0, sizeof(hints)); long supplied = 0; @@ -305,9 +276,11 @@ suil_x11_wrapper_get_preferred_height(GtkWidget* widget, gint* minimum_height, gint* natural_height) { - SuilX11Wrapper* const self = SUIL_X11_WRAPPER(widget); - if (x_window_is_valid(self)) { - GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(self->plug)); + SuilX11Wrapper* const self = SUIL_X11_WRAPPER(widget); + GdkWindow* const window = gtk_widget_get_window(GTK_WIDGET(self->plug)); + if (suil_x11_is_valid_child(GDK_WINDOW_XDISPLAY(window), + GDK_WINDOW_XID(window), + (Window)self->instance->ui_widget)) { XSizeHints hints; memset(&hints, 0, sizeof(hints)); long supplied = 0; |