+#ifdef GDK_WINDOWING_X11
+ bool deferShow = show && !m_isShown && m_deferShow;
+ if (deferShow)
+ {
+ deferShow = m_deferShowAllowed && gs_requestFrameExtentsStatus != 2 &&
+ !gtk_widget_get_realized(m_widget) &&
+ g_signal_handler_find(m_widget,
+ GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
+ g_signal_lookup("property_notify_event", GTK_TYPE_WIDGET),
+ 0, NULL, NULL, this);
+ if (deferShow)
+ {
+ GdkScreen* screen = gtk_widget_get_screen(m_widget);
+ GdkAtom atom = gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false);
+ deferShow = gdk_x11_screen_supports_net_wm_hint(screen, atom) != 0;
+
+ // If _NET_REQUEST_FRAME_EXTENTS not supported, don't allow changes
+ // to m_decorSize, it breaks saving/restoring window size with
+ // GetSize()/SetSize() because it makes window bigger between each
+ // restore and save.
+ m_updateDecorSize = deferShow;
+ }
+
+ m_deferShow = deferShow;
+ }
+ 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);
+ }
+
+ // defer calling gtk_widget_show()
+ m_isShown = true;
+ return true;
+ }
+#endif // GDK_WINDOWING_X11
+
+ if (show && !gtk_widget_get_realized(m_widget))