+void wxTopLevelWindowGTK::AddGrab()
+{
+ if (!m_grabbed)
+ {
+ m_grabbed = true;
+ gtk_grab_add( m_widget );
+ wxEventLoop().Run();
+ gtk_grab_remove( m_widget );
+ }
+}
+
+void wxTopLevelWindowGTK::RemoveGrab()
+{
+ if (m_grabbed)
+ {
+ gtk_main_quit();
+ m_grabbed = false;
+ }
+}
+
+
+// helper
+static bool do_shape_combine_region(GdkWindow* window, const wxRegion& region)
+{
+ if (window)
+ {
+ if (region.IsEmpty())
+ {
+ gdk_window_shape_combine_mask(window, NULL, 0, 0);
+ }
+ else
+ {
+#ifdef __WXGTK20__
+ gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0);
+#else
+ wxBitmap bmp = region.ConvertToBitmap();
+ bmp.SetMask(new wxMask(bmp, *wxBLACK));
+ GdkBitmap* mask = bmp.GetMask()->GetBitmap();
+ gdk_window_shape_combine_mask(window, mask, 0, 0);
+#endif
+ return true;
+ }
+ }
+ return false;
+}
+
+
+bool wxTopLevelWindowGTK::SetShape(const wxRegion& region)
+{
+ wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
+ _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
+
+ GdkWindow *window = NULL;
+ if (m_wxwindow)
+ {
+ window = GTK_PIZZA(m_wxwindow)->bin_window;
+ do_shape_combine_region(window, region);
+ }
+ window = m_widget->window;
+ return do_shape_combine_region(window, region);
+}
+
+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.
+ // wxYieldIfNeeded ensures the processing of it, but can have unwanted side effects - MR
+ ::wxYieldIfNeeded();
+
+ if(m_urgency_hint >= 0)
+ gtk_timeout_remove(m_urgency_hint);
+
+ m_urgency_hint = -2;
+
+ if( GTK_WIDGET_REALIZED(m_widget) && !IsActive() )
+ {
+ new_hint_value = true;
+
+ if (flags & wxUSER_ATTENTION_INFO)
+ {
+ m_urgency_hint = gtk_timeout_add(5000, (GtkFunction)gtk_frame_urgency_timer_callback, this);
+ } else {
+ m_urgency_hint = -1;
+ }
+ }
+
+#if defined(__WXGTK20__) && GTK_CHECK_VERSION(2,7,0)
+ if(!gtk_check_version(2,7,0))
+ gtk_window_set_urgency_hint(GTK_WINDOW( m_widget ), new_hint_value);
+ else
+#endif
+ wxgtk_window_set_urgency_hint(GTK_WINDOW( m_widget ), new_hint_value);
+}
+
+void wxTopLevelWindowGTK::SetWindowStyleFlag( long style )
+{
+#ifdef __WXGTK20__
+ // Store which styles were changed
+ long styleChanges = style ^ m_windowStyle;
+#endif
+
+ // Process wxWindow styles. This also updates the internal variable
+ // Therefore m_windowStyle bits carry now the _new_ style values
+ wxWindow::SetWindowStyleFlag(style);
+
+#ifdef __WXGTK20__
+ // just return for now if widget does not exist yet
+ if (!m_widget)
+ return;
+
+#ifdef __WXGTK24__
+ if ( (styleChanges & wxSTAY_ON_TOP) && !gtk_check_version(2,4,0) )
+ gtk_window_set_keep_above(GTK_WINDOW(m_widget), m_windowStyle & wxSTAY_ON_TOP);
+#endif // GTK+ 2.4
+#if GTK_CHECK_VERSION(2,2,0)
+ if ( (styleChanges & wxFRAME_NO_TASKBAR) && !gtk_check_version(2,2,0) )
+ {
+ gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), m_windowStyle & wxFRAME_NO_TASKBAR);
+ }
+#endif // GTK+ 2.2
+#endif // GTK+ 2.0
+}