+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();
+
+ /*BCI:
+ if(m_urgency_hint >= 0)
+ gtk_timeout_remove(m_urgency_hint);
+ */
+ int urgency_hint = GPOINTER_TO_INT( gtk_object_get_data( GTK_OBJECT(m_widget), "m_urgency_hint") );
+ if(urgency_hint >= 0)
+ gtk_timeout_remove(urgency_hint);
+ //BCI: END
+
+ //BCI: m_urgency_hint = -2;
+ gtk_object_set_data( GTK_OBJECT(m_widget), "m_urgency_hint", GINT_TO_POINTER(-2));
+
+ if( GTK_WIDGET_REALIZED(m_widget) && !IsActive() )
+ {
+ new_hint_value = true;
+
+ if (flags & wxUSER_ATTENTION_INFO)
+ {
+ //BCI: m_urgency_hint = gtk_timeout_add(5000, (GtkFunction)gtk_frame_urgency_timer_callback, this);
+ gtk_object_set_data( GTK_OBJECT(m_widget), "m_urgency_hint",
+ GINT_TO_POINTER( gtk_timeout_add(5000,
+ (GtkFunction)gtk_frame_urgency_timer_callback,
+ m_widget) ) );
+ } else {
+ //BCI: m_urgency_hint = -1;
+ gtk_object_set_data( GTK_OBJECT(m_widget), "m_urgency_hint", GINT_TO_POINTER(-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);
+}