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 693016 - media-keys: Refer key grabbing to the shell
media-keys: Refer key grabbing to the shell
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: media-keys
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
: 694952 (view as bug list)
Depends on: 643111
Blocks:
 
 
Reported: 2013-02-01 15:16 UTC by Florian Müllner
Modified: 2013-03-01 20:38 UTC
See Also:
GNOME target: 3.8
GNOME version: ---


Attachments
media-keys: Refer key grabbing to the shell (19.37 KB, patch)
2013-02-01 15:16 UTC, Florian Müllner
needs-work Details | Review
media-keys: Remove multihead support (2.33 KB, patch)
2013-02-01 15:16 UTC, Florian Müllner
reviewed Details | Review
media-keys: Pass appropriate GrabModes to grab_key_unsafe() (13.98 KB, patch)
2013-02-01 15:16 UTC, Florian Müllner
needs-work Details | Review
media-keys: Refer key grabbing to the shell (24.67 KB, patch)
2013-03-01 03:34 UTC, Florian Müllner
committed Details | Review
media-keys: Remove multihead support (3.91 KB, patch)
2013-03-01 03:34 UTC, Florian Müllner
committed Details | Review
media-keys: Pass appropriate GrabModes to grab_accelerator() (14.68 KB, patch)
2013-03-01 03:35 UTC, Florian Müllner
committed Details | Review
media-keys: Also pass deviceid for custom actions (1.57 KB, patch)
2013-03-01 14:34 UTC, Florian Müllner
committed Details | Review
common: Remove now unused key grab functions (2.50 KB, patch)
2013-03-01 15:09 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2013-02-01 15:16:14 UTC
GSD patches to go with bug 643111; sorry for not having written proper commit messages yet ...
Comment 1 Florian Müllner 2013-02-01 15:16:18 UTC
Created attachment 234998 [details] [review]
media-keys: Refer key grabbing to the shell
Comment 2 Florian Müllner 2013-02-01 15:16:21 UTC
Created attachment 234999 [details] [review]
media-keys: Remove multihead support
Comment 3 Florian Müllner 2013-02-01 15:16:26 UTC
Created attachment 235000 [details] [review]
media-keys: Pass appropriate GrabModes to grab_key_unsafe()
Comment 4 Bastien Nocera 2013-02-03 00:03:34 UTC
Review of attachment 234998 [details] [review]:

::: plugins/media-keys/gsd-media-keys-manager.c
@@ +71,3 @@
 #define GNOME_KEYRING_DBUS_INTERFACE "org.gnome.keyring.Daemon"
 
+

Why the additional linefeed?

@@ +416,3 @@
+
+        if (error) {
+                retry = error->code == G_DBUS_ERROR_UNKNOWN_METHOD;

brackets please:
retry = (error->code == G_DBUS_ERROR_UNKNOWN_METHOD);

@@ +421,3 @@
+                g_error_free (error);
+        } else {
+                retry = key->accel_id == 0;

Ditto.

@@ +425,3 @@
+
+        if (retry)
+                g_timeout_add_seconds (1, retry_grab, data);

Why 1 second? Please move to a #define at the top of the file.

@@ +439,2 @@
+	if (key->accel_id != 0) {
+		shell_key_grabber_call_ungrab_accelerator (manager->priv->key_grabber,

This needs to use a GCancellable.

@@ +446,3 @@
 	tmp = get_key_string (manager, key);
 
+	data = g_new0 (GrabData, 1);

Given the number of those we create, does it make sense to use g_slice_*?

@@ +452,1 @@
+	shell_key_grabber_call_grab_accelerator (manager->priv->key_grabber,

Needs to use a GCancellable as well...

@@ +552,3 @@
                 if (strcmp (key->custom_path, path) == 0) {
                         g_debug ("Removing custom key binding %s", path);
+                        if (key->accel_id)

You already check the value of key->accel_id inside the ungrab_media_key() function.

@@ +623,3 @@
                         continue;
 
+                if (key->accel_id)

Ditto.

@@ +2100,3 @@
+        g_object_get (object, "g-name-owner", &owner, NULL);
+        if (!owner)
+            return;

Indentation.

@@ +2108,2 @@
+                key = g_ptr_array_index (manager->priv->keys, i);
+                grab_media_key (key, manager);

You don't reset key->accel_id so this won't do anything.

@@ +2112,3 @@
 
+static void
+on_accelerator_activated (ShellKeyGrabber     *grabber,

We seem to have lost all the "is this key repeatable" logic.

@@ +2242,3 @@
 
+        manager->priv->key_grabber =
+		shell_key_grabber_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,

This *needs* to be async, g-s-d and g-s start at the same time, and we don't want to block on gnome-shell being started in the hotpath.

@@ +2337,3 @@
                         key = g_ptr_array_index (manager->priv->keys, i);
 
+                        if (key->accel_id)

Same as before, we check for that value in the ungrab function, and as we're shutting down, is it safe to call async functions? I'd do it async, if at all...
Comment 5 Bastien Nocera 2013-02-03 00:06:00 UTC
Review of attachment 234999 [details] [review]:

::: plugins/media-keys/gsd-media-keys-manager.c
@@ +176,1 @@
         /* Multihead stuff */

Remove that comment?

@@ +176,2 @@
         /* Multihead stuff */
         GdkScreen       *current_screen;

Renaming to ->screen would be nice as well.
Comment 6 Bastien Nocera 2013-02-03 00:11:48 UTC
Review of attachment 235000 [details] [review]:

::: plugins/media-keys/gsd-media-keys-manager.c
@@ +511,3 @@
         key = g_new0 (MediaKey, 1);
         key->key_type = CUSTOM_KEY;
+        key->modes = SHELL_KEYBINDING_MODE_NORMAL | SHELL_KEYBINDING_MODE_OVERVIEW;

LAUNCHER_MODES?
Maybe you could rename the define and use it instead of undefining in the header.
Comment 7 Bastien Nocera 2013-02-03 00:27:02 UTC
Review of attachment 235000 [details] [review]:

::: plugins/media-keys/shortcuts-list.h
@@ +116,3 @@
+        { EMAIL_KEY, "email", NULL, NULL, LAUNCHER_MODES },
+        { SCREENSAVER_KEY, "screensaver", NULL, NULL, SCREENSAVER_MODES },
+        { SCREENSAVER_KEY, NULL, N_("Lock Screen"), "XF86ScreenSaver", SCREENSAVER_MODES },

This needs to work when the shield is down, to lock the screen and require a password.
Comment 8 Florian Müllner 2013-03-01 03:34:38 UTC
Created attachment 237679 [details] [review]
media-keys: Refer key grabbing to the shell

(In reply to comment #4)
> Review of attachment 234998 [details] [review]:
> +    data = g_new0 (GrabData, 1);
> 
> Given the number of those we create, does it make sense to use g_slice_*?

We create a lot less now thanks to GrabAccelerators(), but switched to g_slice anyway ...


> @@ +2108,2 @@
> +                key = g_ptr_array_index (manager->priv->keys, i);
> +                grab_media_key (key, manager);
> 
> You don't reset key->accel_id so this won't do anything.

It will, grab_media_key() will try to ungrab first if accel_id is non-zero, and intend a grab in any case.


> @@ +2112,3 @@
> +static void
> +on_accelerator_activated (ShellKeyGrabber     *grabber,
> 
> We seem to have lost all the "is this key repeatable" logic.

Right. This needs to be moved into mutter and exposed in the grab_accelerator() call (e.g. grab(accel, modes) => grab(accel, modes, flags)). Would you be OK with addressing this later? (If not 3.8.0, it should at least make it in 3.8.1)


> Same as before, we check for that value in the ungrab function, and as we're
> shutting down, is it safe to call async functions? I'd do it async, if at
> all...

Good question. As I changed gnome-shell to ungrab all our keys once we leave the bus, it shouldn't matter in practice.
Comment 9 Florian Müllner 2013-03-01 03:34:51 UTC
Created attachment 237680 [details] [review]
media-keys: Remove multihead support

Updated according to review.
Comment 10 Florian Müllner 2013-03-01 03:35:16 UTC
Created attachment 237681 [details] [review]
media-keys: Pass appropriate GrabModes to grab_accelerator()

Updated according to review.
Comment 11 Florian Müllner 2013-03-01 03:55:11 UTC
(In reply to comment #8)
> > @@ +2112,3 @@
> > +static void
> > +on_accelerator_activated (ShellKeyGrabber     *grabber,
> > 
> > We seem to have lost all the "is this key repeatable" logic.
> 
> Right. This needs to be moved into mutter and exposed in the grab_accelerator()
> call (e.g. grab(accel, modes) => grab(accel, modes, flags)). Would you be OK
> with addressing this later? (If not 3.8.0, it should at least make it in 3.8.1)

I should also add that mutter triggers keybindings on KeyPress, so the keybindings that behave differently are the non-repeatable ones ...
Comment 12 Bastien Nocera 2013-03-01 12:53:31 UTC
Review of attachment 237679 [details] [review]:

::: plugins/media-keys/gsd-media-keys-manager.c
@@ -400,3 @@
-	if (key->key != NULL) {
-		need_flush = TRUE;
-		ungrab_key_unsafe (key->key, manager->priv->screens);

As ->screens won't be used after this patch, could you please remove it in this patch?

@@ +2185,2 @@
+                if (key->key_type == CUSTOM_KEY)
+                        do_custom_action (manager, key, GDK_CURRENT_TIME);

Could you create a new patch that'll pass the device-id to the custom-action keybindings as well?
Comment 13 Bastien Nocera 2013-03-01 12:59:07 UTC
Review of attachment 237680 [details] [review]:

Ignore my comment in the previous patch.
Comment 14 Bastien Nocera 2013-03-01 13:01:42 UTC
Review of attachment 237681 [details] [review]:

Looks good.
Comment 15 Bastien Nocera 2013-03-01 13:02:48 UTC
I would also like another patch to remove all the unused stuff from plugins/common/gsd-keygrab.h
Comment 16 Florian Müllner 2013-03-01 14:34:12 UTC
Created attachment 237712 [details] [review]
media-keys: Also pass deviceid for custom actions

(In reply to comment #12)
> Could you create a new patch that'll pass the device-id to the custom-action
> keybindings as well?

Just like this, or is there anything useful I'm supposed to do with it?
Comment 17 Florian Müllner 2013-03-01 15:09:48 UTC
Created attachment 237714 [details] [review]
common: Remove now unused key grab functions

(In reply to comment #15)
> I would also like another patch to remove all the unused stuff from
> plugins/common/gsd-keygrab.h

OK - Rui still intends to move the input source switcher into mutter/shell this cycle, at which point everything except for grab_button() will be obsolete. Still, while I was waiting on your feedback on leaving the code removal to this point, the patch was already written ... :)
Comment 18 Bastien Nocera 2013-03-01 15:36:36 UTC
Review of attachment 237712 [details] [review]:

Looks good, thanks.
Comment 19 Florian Müllner 2013-03-01 16:11:34 UTC
Attachment 237679 [details] pushed as b0cee1d - media-keys: Refer key grabbing to the shell
Attachment 237680 [details] pushed as 9e03278 - media-keys: Remove multihead support
Attachment 237681 [details] pushed as 1c9ded7 - media-keys: Pass appropriate GrabModes to grab_accelerator()
Attachment 237712 [details] pushed as 7e6854d - media-keys: Also pass deviceid for custom actions
Attachment 237714 [details] pushed as b7f766d - common: Remove now unused key grab functions
Comment 20 Ray Strode [halfline] 2013-03-01 20:38:13 UTC
*** Bug 694952 has been marked as a duplicate of this bug. ***