+void wxTopLevelWindowGTK::AddGrab()
+{
+ if (!m_grabbed)
+ {
+ m_grabbed = true;
+ gtk_grab_add( m_widget );
+ wxGUIEventLoop().Run();
+ gtk_grab_remove( m_widget );
+ }
+}
+
+void wxTopLevelWindowGTK::RemoveGrab()
+{
+ if (m_grabbed)
+ {
+ gtk_main_quit();
+ m_grabbed = false;
+ }
+}
+
+bool wxTopLevelWindowGTK::IsActive()
+{
+ return (this == (wxTopLevelWindowGTK*)g_activeFrame);
+}
+
+void wxTopLevelWindowGTK::RequestUserAttention(int flags)
+{
+ bool new_hint_value = false;
+
+ // FIXME: This is a workaround to focus handling problem
+ // If RequestUserAttention is called for example right after a wxSleep, OnInternalIdle
+ // hasn't yet been processed, and the internal focus system is not up to date yet.
+ // YieldFor(wxEVT_CATEGORY_UI) ensures the processing of it (hopefully it
+ // won't have side effects) - MR
+ wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
+
+ if(m_urgency_hint >= 0)
+ g_source_remove(m_urgency_hint);
+
+ m_urgency_hint = -2;
+
+ if( gtk_widget_get_realized(m_widget) && !IsActive() )
+ {
+ new_hint_value = true;
+
+ if (flags & wxUSER_ATTENTION_INFO)
+ {
+ m_urgency_hint = g_timeout_add(5000, (GSourceFunc)gtk_frame_urgency_timer_callback, this);
+ } else {
+ m_urgency_hint = -1;
+ }
+ }
+
+ gtk_window_set_urgency_hint(GTK_WINDOW(m_widget), new_hint_value);
+}
+
+void wxTopLevelWindowGTK::SetWindowStyleFlag( long style )
+{
+ // Store which styles were changed
+ long styleChanges = style ^ m_windowStyle;
+
+ // Process wxWindow styles. This also updates the internal variable
+ // Therefore m_windowStyle bits carry now the _new_ style values
+ wxWindow::SetWindowStyleFlag(style);
+
+ // just return for now if widget does not exist yet
+ if (!m_widget)
+ return;
+
+ if ( styleChanges & wxSTAY_ON_TOP )
+ {
+ gtk_window_set_keep_above(GTK_WINDOW(m_widget),
+ m_windowStyle & wxSTAY_ON_TOP);
+ }
+
+ if ( styleChanges & wxFRAME_NO_TASKBAR )
+ {
+ gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget),
+ m_windowStyle & wxFRAME_NO_TASKBAR);
+ }
+}
+
+bool wxTopLevelWindowGTK::SetTransparent(wxByte alpha)
+{
+ GdkWindow* window = NULL;
+ if (m_widget)
+ window = gtk_widget_get_window(m_widget);
+ if (window == NULL)
+ return false;
+
+#ifdef GDK_WINDOWING_X11
+ Display* dpy = GDK_WINDOW_XDISPLAY(window);
+ Window win = GDK_WINDOW_XID(window);
+
+ // Using pure Xlib to not have a GTK version check mess due to gtk2.0 not having GdkDisplay
+ if (alpha == 0xff)
+ XDeleteProperty(dpy, win, XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False));
+ else
+ {
+ long opacity = alpha * 0x1010101L;
+ XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False),
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &opacity, 1L);
+ }
+ XSync(dpy, False);
+ return true;
+#else // !GDK_WINDOWING_X11
+ return false;
+#endif // GDK_WINDOWING_X11 / !GDK_WINDOWING_X11
+}
+
+bool wxTopLevelWindowGTK::CanSetTransparent()
+{
+ // allow to override automatic detection as it's far from perfect
+ const wxString SYSOPT_TRANSPARENT = "gtk.tlw.can-set-transparent";
+ if ( wxSystemOptions::HasOption(SYSOPT_TRANSPARENT) )
+ {
+ return wxSystemOptions::GetOptionInt(SYSOPT_TRANSPARENT) != 0;
+ }
+
+#ifdef __WXGTK3__
+ return gtk_widget_is_composited(m_widget) != 0;
+#else
+#if GTK_CHECK_VERSION(2,10,0)
+ if (!gtk_check_version(2,10,0))
+ {
+ return gtk_widget_is_composited(m_widget) != 0;
+ }
+ else
+#endif // In case of lower versions than gtk+-2.10.0 we could look for _NET_WM_CM_Sn ourselves
+ {
+ return false;
+ }
+#endif // !__WXGTK3__
+
+#if 0 // Don't be optimistic here for the sake of wxAUI
+ int opcode, event, error;
+ // Check for the existence of a RGBA visual instead?
+ return XQueryExtension(gdk_x11_get_default_xdisplay (),
+ "Composite", &opcode, &event, &error);
+#endif
+}