GNOME Bugzilla – Bug 701273
Some windows not receiving focus when opened with keyboard shortcuts
Last modified: 2013-07-26 18:08:16 UTC
Also reported on bugzilla.redhat.com: https://bugzilla.redhat.com/show_bug.cgi?id=969021 Using custom keyboard shortcuts to open applications seems to result in some applications not receiving focus. Opening Firefox or Nautilus/Files using a custom keyboard shortcut (such as Alt-B) on an empty workspace starts the application, but the new window does not receive focus until you click. This is different from the behaviour in Fedora 18 (with gnome-shell 3.6.x), where the new window would immediately receive focus. Using the mouse to open Firefox or Nautilus gives it focus straight away, so the problem seems to be only when using keyboard shortcuts. Strangely, opening gnome-terminal using a custom keyboard shortcut doesn't result in the same symptoms. It receives focus immediately. So apparently not all applications are affected. Fedora 19 x86_64 gnome-shell-3.8.2-3.fc19 gnome-settings-daemon-3.8.2-1.fc19 "halfline" on fedora-devel IRC mentioned the following: looks like a settings-daemon bug static void do_custom_action (GsdMediaKeysManager *manager, guint deviceid, MediaKey *key, gint64 timestamp) { g_debug ("Launching custom action for key (on device id %d)", deviceid); execute (manager, key->custom_command, FALSE); } timestamp is getting thrown away and it's getting hardcoded to GDK_CURRENT_TIME anyway: do_custom_action (manager, deviceid, key, GDK_CURRENT_TIME);
Just in case it's not clear, here's some steps to reproduce: 1) Open Settings 2) Set [Alt-B] as a keyboard shortcut for Firefox (or Nautilus) 3) Go to blank desktop 4) Press [Alt-B] 5) Firefox (or Nautilus) is not the focused window The expected behaviour is for Firefox to be focused. Just to reiterate, this was previously working in GNOME 3.6, but the behaviour has changed in GNOME 3.8. I'm not sure if this is the correct component to have filed against.
This happens to me, when I open the calculator by the calculator key on the keyboard. var/log/messages contains the following warning: /etc/gdm/Xsession[820]: Window manager warning: Got a request to focus the no_focus_window with a timestamp of 0. This shouldn't happen!
Created attachment 250105 [details] [review] media-keys: Fix launched apps not getting focused Use the timestamp passed by newer versions of mutter/gnome-shell to launch applications. This should make them focus correctly when launched.
Review of attachment 250105 [details] [review]: You need to add the timestamp param to AcceleratorActivated in org.gnome.ShellKeyGrabber.xml
Created attachment 250110 [details] [review] media-keys: Fix launched apps not getting focused Use the timestamp passed by newer versions of mutter/gnome-shell to launch applications. This should make them focus correctly when launched.
Review of attachment 250110 [details] [review]: Works fine here with the other patches (tested with the calculator).
Attachment 250110 [details] pushed as 487a936 - media-keys: Fix launched apps not getting focused
Created attachment 250114 [details] [review] media-keys: Work-around launched apps not getting focused Get a timestamp from the root window to launch applications. This should work-around applications not getting focused correctly when launched.
Attached is a patch for GNOME 3.8, if you can test it.
Review of attachment 250114 [details] [review]: ::: plugins/media-keys/gsd-media-keys-manager.c @@ +2112,3 @@ + + manager = gdk_display_manager_get (); + window = gdk_x11_window_lookup_for_display (gdk_display_manager_get_default_display(manager), GDK_ROOT_WINDOW()); Missing space before parenthesis and you need gdk/gdkx.h for GDK_ROOT_WINDOW.
(In reply to comment #10) > Review of attachment 250114 [details] [review]: > > ::: plugins/media-keys/gsd-media-keys-manager.c > @@ +2112,3 @@ > + > + manager = gdk_display_manager_get (); > + window = gdk_x11_window_lookup_for_display > (gdk_display_manager_get_default_display(manager), GDK_ROOT_WINDOW()); > > Missing space before parenthesis Yep. Will fix before pushing. > and you need gdk/gdkx.h for GDK_ROOT_WINDOW. It's already there, line 39.
(In reply to comment #11) > (In reply to comment #10) > > Review of attachment 250114 [details] [review] [details]: > > > > ::: plugins/media-keys/gsd-media-keys-manager.c > > @@ +2112,3 @@ > > + > > + manager = gdk_display_manager_get (); > > + window = gdk_x11_window_lookup_for_display > > (gdk_display_manager_get_default_display(manager), GDK_ROOT_WINDOW()); > > > > Missing space before parenthesis > > Yep. Will fix before pushing. OK. > > and you need gdk/gdkx.h for GDK_ROOT_WINDOW. > > It's already there, line 39. Oh crap was looking at master, sorry. For some reason building 3.8 on top of my jhbuild does not work right now so can't test it.
Attachment 250114 [details] pushed as 5ed4d73 - media-keys: Work-around launched apps not getting focused
Comment on attachment 250114 [details] [review] media-keys: Work-around launched apps not getting focused This deadlocks gnome-settings-daemon it seems.
Not fixable cleanly for gnome-3-8, so this will have to wait (not too long though) for GNOME 3.10.