From b2c64e5a8f463ee47490bc1325924ea4bbc051cc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 1 Dec 2024 22:38:31 -0500 Subject: Monitor UI window resizes for X11 in Gtk3 --- src/x11_in_gtk3.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/x11_in_gtk3.c') diff --git a/src/x11_in_gtk3.c b/src/x11_in_gtk3.c index 138fdcb..e3be7fb 100644 --- a/src/x11_in_gtk3.c +++ b/src/x11_in_gtk3.c @@ -110,12 +110,15 @@ suil_x11_wrapper_realize(GtkWidget* w) gtk_widget_set_can_focus(GTK_WIDGET(wrap->plug), TRUE); gtk_widget_grab_focus(GTK_WIDGET(wrap->plug)); + // Request configure events for child windows + GdkWindow* gwindow = gtk_widget_get_window(GTK_WIDGET(wrap->plug)); + Display* xdisplay = GDK_WINDOW_XDISPLAY(gwindow); + Window xwindow = GDK_WINDOW_XID(gwindow); + XSelectInput(xdisplay, xwindow, SubstructureRedirectMask); + // Setup drag/drop proxy from parent/grandparent window - GdkWindow* gwindow = gtk_widget_get_window(GTK_WIDGET(wrap->plug)); - Display* xdisplay = GDK_WINDOW_XDISPLAY(gwindow); - Window xwindow = GDK_WINDOW_XID(gwindow); - Atom xdnd_proxy_atom = gdk_x11_get_xatom_by_name("XdndProxy"); - Window ui_window = (Window)wrap->instance->ui_widget; + Atom xdnd_proxy_atom = gdk_x11_get_xatom_by_name("XdndProxy"); + Window ui_window = (Window)wrap->instance->ui_widget; while (xwindow) { XChangeProperty(xdisplay, @@ -407,6 +410,20 @@ suil_x11_wrapper_idle(void* data) wrap->idle_iface->idle(wrap->instance->handle); + GdkWindow* const gwindow = gtk_widget_get_window(GTK_WIDGET(wrap->plug)); + const Window window = GDK_WINDOW_XID(gwindow); + Display* const display = GDK_WINDOW_XDISPLAY(gwindow); + XEvent event = {0}; + while (XCheckWindowEvent(display, window, SubstructureRedirectMask, &event)) { + if (event.type == MapRequest) { + XMapWindow(display, event.xmaprequest.window); + } else if (event.type == ConfigureRequest) { + wrap->size_hints.flags = 0; + wrap->size_hints_dirty = TRUE; + wrapper_resize(wrap, event.xconfigure.width, event.xconfigure.height); + } + } + return TRUE; // Continue calling } -- cgit v1.2.1