+ if (deferShow)
+ {
+ // 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).
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(m_widget, &alloc);
+ const int alloc_width = alloc.width;
+ if (alloc_width == 1)
+ {
+ alloc.width = 2;
+ gtk_widget_set_allocation(m_widget, &alloc);
+ }
+ gtk_widget_realize(m_widget);
+ if (alloc_width == 1)
+ {
+ alloc.width = 1;
+ gtk_widget_set_allocation(m_widget, &alloc);
+ }
+
+ // send _NET_REQUEST_FRAME_EXTENTS
+ XClientMessageEvent xevent;
+ memset(&xevent, 0, sizeof(xevent));
+ xevent.type = ClientMessage;
+ GdkWindow* window = gtk_widget_get_window(m_widget);
+ xevent.window = GDK_WINDOW_XID(window);
+ xevent.message_type = gdk_x11_atom_to_xatom_for_display(
+ gdk_window_get_display(window),
+ gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false));
+ xevent.format = 32;
+ Display* display = GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window));
+ XSendEvent(display, DefaultRootWindow(display), false,
+ SubstructureNotifyMask | SubstructureRedirectMask,
+ (XEvent*)&xevent);
+
+ if (gs_requestFrameExtentsStatus == 0)
+ {
+ // if WM does not respond to request within 1 second,
+ // we assume support for _NET_REQUEST_FRAME_EXTENTS is not working
+ m_netFrameExtentsTimerId =
+ g_timeout_add(1000, request_frame_extents_timeout, this);
+ }