+ if (!wm_hints)
+ wm_hints = XAllocWMHints();
+
+ if (setting)
+ wm_hints->flags |= XUrgencyHint;
+ else
+ wm_hints->flags &= ~XUrgencyHint;
+
+ XSetWMHints(GDK_WINDOW_XDISPLAY(window), GDK_WINDOW_XWINDOW(window), wm_hints);
+ XFree(wm_hints);
+}
+
+static gint gtk_frame_urgency_timer_callback( wxTopLevelWindowGTK *win )
+{
+ wxgtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE);
+
+ win->m_urgency_hint = -2;
+ return FALSE;
+}
+}
+
+//-----------------------------------------------------------------------------
+// "focus_in_event"
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static gint gtk_frame_focus_in_callback( GtkWidget *widget,
+ GdkEvent *WXUNUSED(event),
+ wxTopLevelWindowGTK *win )
+{
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+
+ switch ( g_sendActivateEvent )
+ {
+ case -1:
+ // we've got focus from outside, synthetize wxActivateEvent
+ g_sendActivateEvent = 1;
+ break;
+
+ case 0:
+ // another our window just lost focus, it was already ours before
+ // - don't send any wxActivateEvent
+ g_sendActivateEvent = -1;
+ break;
+ }
+
+ g_activeFrame = win;
+ g_lastActiveFrame = g_activeFrame;
+
+ // wxPrintf( wxT("active: %s\n"), win->GetTitle().c_str() );
+
+ // MR: wxRequestUserAttention related block
+ switch( win->m_urgency_hint )
+ {
+ default:
+ gtk_timeout_remove( win->m_urgency_hint );
+ // no break, fallthrough to remove hint too
+ case -1:
+ wxgtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE);
+
+ win->m_urgency_hint = -2;
+ break;
+
+ case -2: break;
+ }
+
+ wxLogTrace(wxT("activate"), wxT("Activating frame %p (from focus_in)"), g_activeFrame);
+ wxActivateEvent event(wxEVT_ACTIVATE, true, g_activeFrame->GetId());
+ event.SetEventObject(g_activeFrame);
+ g_activeFrame->GetEventHandler()->ProcessEvent(event);
+
+ return FALSE;
+}
+}
+
+//-----------------------------------------------------------------------------
+// "focus_out_event"
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static gint gtk_frame_focus_out_callback( GtkWidget *widget,
+ GdkEventFocus *WXUNUSED(gdk_event),
+ wxTopLevelWindowGTK *win )
+{
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+
+ // if the focus goes out of our app alltogether, OnIdle() will send
+ // wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset
+ // g_sendActivateEvent to -1
+ g_sendActivateEvent = 0;
+
+ // wxASSERT_MSG( (g_activeFrame == win), wxT("TLW deactivatd although it wasn't active") );
+
+ // wxPrintf( wxT("inactive: %s\n"), win->GetTitle().c_str() );
+
+ if (g_activeFrame)
+ {
+ wxLogTrace(wxT("activate"), wxT("Activating frame %p (from focus_in)"), g_activeFrame);
+ wxActivateEvent event(wxEVT_ACTIVATE, false, g_activeFrame->GetId());
+ event.SetEventObject(g_activeFrame);
+ g_activeFrame->GetEventHandler()->ProcessEvent(event);
+
+ g_activeFrame = NULL;
+ }
+
+ return FALSE;
+}
+}