+ GTKApplyWidgetStyle(true);
+ }
+#endif // !__WXGTK3__
+
+ return true;
+}
+
+bool wxWindowGTK::IsTransparentBackgroundSupported(wxString* reason) const
+{
+#if wxGTK_HAS_COMPOSITING_SUPPORT
+#ifndef __WXGTK3__
+ if (gtk_check_version(wxGTK_VERSION_REQUIRED_FOR_COMPOSITING) != NULL)
+ {
+ if (reason)
+ {
+ *reason = _("GTK+ installed on this machine is too old to "
+ "support screen compositing, please install "
+ "GTK+ 2.12 or later.");
+ }
+
+ return false;
+ }
+#endif // !__WXGTK3__
+
+ // NB: We don't check here if the particular kind of widget supports
+ // transparency, we check only if it would be possible for a generic window
+
+ wxCHECK_MSG ( m_widget, false, "Window must be created first" );
+
+ if (!gdk_screen_is_composited(gtk_widget_get_screen(m_widget)))
+ {
+ if (reason)
+ {
+ *reason = _("Compositing not supported by this system, "
+ "please enable it in your Window Manager.");
+ }
+
+ return false;
+ }
+
+ return true;
+#else
+ if (reason)
+ {
+ *reason = _("This program was compiled with a too old version of GTK+, "
+ "please rebuild with GTK+ 2.12 or newer.");
+ }
+
+ return false;
+#endif // wxGTK_HAS_COMPOSITING_SUPPORT/!wxGTK_HAS_COMPOSITING_SUPPORT
+}
+
+// ----------------------------------------------------------------------------
+// Pop-up menu stuff
+// ----------------------------------------------------------------------------
+
+#if wxUSE_MENUS_NATIVE
+
+extern "C" {
+static
+void wxPopupMenuPositionCallback( GtkMenu *menu,
+ gint *x, gint *y,
+ gboolean * WXUNUSED(whatever),
+ gpointer user_data )
+{
+ // ensure that the menu appears entirely on screen
+ GtkRequisition req;
+ gtk_widget_get_child_requisition(GTK_WIDGET(menu), &req);
+
+ wxSize sizeScreen = wxGetDisplaySize();
+ wxPoint *pos = (wxPoint*)user_data;
+
+ gint xmax = sizeScreen.x - req.width,
+ ymax = sizeScreen.y - req.height;
+
+ *x = pos->x < xmax ? pos->x : xmax;
+ *y = pos->y < ymax ? pos->y : ymax;
+}
+}
+
+bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
+{
+ wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") );
+
+ menu->UpdateUI();
+
+ wxPoint pos;
+ gpointer userdata;
+ GtkMenuPositionFunc posfunc;
+ if ( x == -1 && y == -1 )
+ {
+ // use GTK's default positioning algorithm
+ userdata = NULL;
+ posfunc = NULL;
+ }
+ else
+ {
+ pos = ClientToScreen(wxPoint(x, y));
+ userdata = &pos;
+ posfunc = wxPopupMenuPositionCallback;
+ }
+
+ menu->m_popupShown = true;
+ gtk_menu_popup(
+ GTK_MENU(menu->m_menu),
+ NULL, // parent menu shell
+ NULL, // parent menu item
+ posfunc, // function to position it
+ userdata, // client data
+ 0, // button used to activate it
+ gtk_get_current_event_time()
+ );
+
+ while (menu->m_popupShown)
+ {
+ gtk_main_iteration();