[caribou] caribou-gtk-module: don't add the event filter until the dbus call finishes



commit ae678cf9a39239eaa508dad9c8eb068cfae1d06c
Author: Dan Winship <danw gnome org>
Date:   Fri Sep 2 11:00:15 2011 -0400

    caribou-gtk-module: don't add the event filter until the dbus call finishes
    
    event_filter() assumes that the D-Bus handle to the keyboard has been
    initialized (and will crash if it's null), so don't set up the event
    filter until after the async call returns.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=658063

 modules/gtk3/caribou-gtk-module.vala |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/modules/gtk3/caribou-gtk-module.vala b/modules/gtk3/caribou-gtk-module.vala
index 17ef41b..a33f1a0 100644
--- a/modules/gtk3/caribou-gtk-module.vala
+++ b/modules/gtk3/caribou-gtk-module.vala
@@ -21,8 +21,6 @@ namespace Caribou {
 
             Bus.get_proxy.begin<Keyboard> (BusType.SESSION, "org.gnome.Caribou.Keyboard",
                                            "/org/gnome/Caribou/Keyboard", 0, null, callback);
-
-            Gdk.window_add_filter (null, event_filter);
         }
 
         private void callback (GLib.Object? obj, GLib.AsyncResult res) {
@@ -31,7 +29,19 @@ namespace Caribou {
             }
             catch (Error e) {
                 stderr.printf ("%s\n", e.message);
-             }
+                return;
+            }
+
+            Gdk.window_add_filter (null, event_filter);
+
+            // Something might already be focused
+            GLib.List<weak Gtk.Window> toplevels = Gtk.Window.list_toplevels();
+            foreach (weak Gtk.Window w in toplevels) {
+                if (w.has_toplevel_focus) {
+                    do_focus_change (w.get_focus ());
+                    break;
+                }
+            }
         }
 
         private Gdk.FilterReturn event_filter (Gdk.XEvent xevent, Gdk.Event evt) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]