- /* by calling GtkOnSize here, we don't have to call
- either after showing the frame, which would entail
- much ugly flicker or from within the size_allocate
- handler, because GTK 1.1.X forbids that. */
+ // Initial show. If WM supports _NET_REQUEST_FRAME_EXTENTS, defer
+ // calling gtk_widget_show() until _NET_FRAME_EXTENTS property
+ // notification is received, so correct frame extents are known.
+ // This allows resizing m_widget to keep the overall size in sync with
+ // what wxWidgets expects it to be without an obvious change in the
+ // window size immediately after it becomes visible.
+
+ // Realize m_widget, so m_widget->window can be used. Realizing normally
+ // causes the widget tree to be size_allocated, which generates size
+ // events in the wrong order. However, the size_allocates will not be
+ // done if the allocation is not the default (1,1).
+ const int alloc_width = m_widget->allocation.width;
+ if (alloc_width == 1)
+ m_widget->allocation.width = 2;
+ gtk_widget_realize(m_widget);
+ if (alloc_width == 1)
+ m_widget->allocation.width = 1;
+
+ // send _NET_REQUEST_FRAME_EXTENTS
+ XClientMessageEvent xevent;
+ memset(&xevent, 0, sizeof(xevent));
+ xevent.type = ClientMessage;
+ xevent.window = gdk_x11_drawable_get_xid(m_widget->window);
+ xevent.message_type = gdk_x11_atom_to_xatom_for_display(
+ gdk_drawable_get_display(m_widget->window),
+ gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false));
+ xevent.format = 32;
+ Display* display = gdk_x11_drawable_get_xdisplay(m_widget->window);
+ XSendEvent(display, DefaultRootWindow(display), false,
+ SubstructureNotifyMask | SubstructureRedirectMask,
+ (XEvent*)&xevent);
+
+ // defer calling gtk_widget_show()
+ m_isShown = true;
+ return true;
+ }