After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 701273 - Some windows not receiving focus when opened with keyboard shortcuts
Some windows not receiving focus when opened with keyboard shortcuts
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: media-keys
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on: 704859
Blocks:
 
 
Reported: 2013-05-30 13:51 UTC by Jamie Nguyen
Modified: 2013-07-26 18:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
media-keys: Fix launched apps not getting focused (1.63 KB, patch)
2013-07-25 12:21 UTC, Bastien Nocera
needs-work Details | Review
media-keys: Fix launched apps not getting focused (2.15 KB, patch)
2013-07-25 12:50 UTC, Bastien Nocera
committed Details | Review
media-keys: Work-around launched apps not getting focused (2.19 KB, patch)
2013-07-25 13:23 UTC, Bastien Nocera
rejected Details | Review

Description Jamie Nguyen 2013-05-30 13:51:04 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);
Comment 1 Jamie Nguyen 2013-06-07 22:17:21 UTC
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.
Comment 2 Stefan 2013-07-14 11:19:29 UTC
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!
Comment 3 Bastien Nocera 2013-07-25 12:21:10 UTC
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.
Comment 4 drago01 2013-07-25 12:44:04 UTC
Review of attachment 250105 [details] [review]:

You need to add the timestamp param to AcceleratorActivated in org.gnome.ShellKeyGrabber.xml
Comment 5 Bastien Nocera 2013-07-25 12:50:05 UTC
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.
Comment 6 drago01 2013-07-25 12:53:44 UTC
Review of attachment 250110 [details] [review]:

Works fine here with the other patches (tested with the calculator).
Comment 7 Bastien Nocera 2013-07-25 12:56:19 UTC
Attachment 250110 [details] pushed as 487a936 - media-keys: Fix launched apps not getting focused
Comment 8 Bastien Nocera 2013-07-25 13:23:27 UTC
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.
Comment 9 Bastien Nocera 2013-07-25 13:24:42 UTC
Attached is a patch for GNOME 3.8, if you can test it.
Comment 10 drago01 2013-07-25 18:27:26 UTC
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.
Comment 11 Bastien Nocera 2013-07-25 18:33:11 UTC
(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.
Comment 12 drago01 2013-07-25 18:57:14 UTC
(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.
Comment 13 Bastien Nocera 2013-07-26 18:05:26 UTC
Attachment 250114 [details] pushed as 5ed4d73 - media-keys: Work-around launched apps not getting focused
Comment 14 Bastien Nocera 2013-07-26 18:07:01 UTC
Comment on attachment 250114 [details] [review]
media-keys: Work-around launched apps not getting focused

This deadlocks gnome-settings-daemon it seems.
Comment 15 Bastien Nocera 2013-07-26 18:08:16 UTC
Not fixable cleanly for gnome-3-8, so this will have to wait (not too long though) for GNOME 3.10.