From ae678cf9a39239eaa508dad9c8eb068cfae1d06c Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 2 Sep 2011 11:00:15 -0400 Subject: 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 file 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 (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 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) { -- cgit v1.2.1