[Window] Another try at thwarting focus-stealing prevention
authorIra W. Snyder <devel@irasnyder.com>
Tue, 22 Jan 2008 20:06:33 +0000 (12:06 -0800)
committerIra W. Snyder <devel@irasnyder.com>
Tue, 22 Jan 2008 20:06:33 +0000 (12:06 -0800)
Try to keep focus-stealing prevention out of our way. This unconditionally
sets the X11 property _NET_WM_USER_TIME on our window when activated
by the global keybinding callback.

tilda-window.c

index f0852aa..f20b273 100644 (file)
@@ -230,7 +230,12 @@ tilda_window_keybinding_cb (const gchar *keystr, gpointer data)
        TildaWindow *self = TILDA_WINDOW(data);
        TildaTerminal *tt;
 
-       // FIXME: this doesn't handle animation!
+       /* This call sets the X11 window property _NET_WM_USER_TIME, which GTK+ normally
+        * sets for us. However, because this callback is activated via a global keybinding,
+        * we see the event before GDK / GTK+ does. Therefore, to get the focus, we must
+        * set the property ourselves. */
+       gdk_x11_window_set_user_time (GTK_WIDGET(self->window)->window,
+                                                                 tomboy_keybinder_get_current_event_time());
 
        switch (self->state)
        {
@@ -249,8 +254,7 @@ tilda_window_keybinding_cb (const gchar *keystr, gpointer data)
                                        "keep-above", self->keep_above,
                                        "stick", self->stick,
                                        NULL);
-                       gtk_window_present_with_time (GTK_WINDOW(self->window),
-                                                                                 tomboy_keybinder_get_current_event_time());
+                       gtk_widget_show (GTK_WIDGET(self->window));
 
                        /* Focusing the term here works perfectly, near as I can tell */
                        tt = tilda_window_find_current_terminal (self);
@@ -611,6 +615,7 @@ tilda_window_constructor (GType                  type,
        tilda_window_setup_real_transparency (self);
 
        gtk_container_add (GTK_CONTAINER(self->window), self->notebook);
+       g_object_set (G_OBJECT(self->notebook), "can-focus", FALSE, NULL);
        gtk_widget_show (self->notebook);
 
        // FIXME: Remove these, and replace with reads from the config system