Blob Blame History Raw
From 80c1053d9100f604754ebc44b99d0d7bb37d6814 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Thu, 11 Dec 2014 17:32:55 +0100
Subject: [PATCH 1/3] media-keys: Adjust to ShellKeyGrabber changes

The AcceleratorActivated signal now uses a dictionary for additional
parameters to make future additions easier.
---
 plugins/media-keys/gsd-media-keys-manager.c      | 13 +++++++++++--
 plugins/media-keys/org.gnome.ShellKeyGrabber.xml |  3 +--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index dcd14f2..1c00b85 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -2182,11 +2182,20 @@ do_action (GsdMediaKeysManager *manager,
 static void
 on_accelerator_activated (ShellKeyGrabber     *grabber,
                           guint                accel_id,
-                          guint                deviceid,
-                          guint                timestamp,
+                          GVariant            *parameters,
                           GsdMediaKeysManager *manager)
 {
+        GVariantDict dict;
         guint i;
+        guint deviceid;
+        guint timestamp;
+
+        g_variant_dict_init (&dict, parameters);
+
+        if (!g_variant_dict_lookup (&dict, "device-id", "u", &deviceid))
+              deviceid = 0;
+        if (!g_variant_dict_lookup (&dict, "timestamp", "u", &timestamp))
+              timestamp = GDK_CURRENT_TIME;
 
         for (i = 0; i < manager->priv->keys->len; i++) {
                 MediaKey *key;
diff --git a/plugins/media-keys/org.gnome.ShellKeyGrabber.xml b/plugins/media-keys/org.gnome.ShellKeyGrabber.xml
index b47e9c8..a245481 100644
--- a/plugins/media-keys/org.gnome.ShellKeyGrabber.xml
+++ b/plugins/media-keys/org.gnome.ShellKeyGrabber.xml
@@ -16,8 +16,7 @@
     </method>
     <signal name="AcceleratorActivated">
       <arg type="u" name="action"/>
-      <arg type="u" name="device"/>
-      <arg type="u" name="timestamp"/>
+      <arg type="a{sv}" name="parameters"/>
     </signal>
   </interface>
 </node>
-- 
2.3.6


From 8d3d496a3c36f2e884d6b3d5b3b050b4198bf8ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Fri, 19 Dec 2014 14:30:15 +0100
Subject: [PATCH 2/3] media-keys: Make power-actions non-interactive based on
 mode

gnome-shell does not allow to grab any particular key combo more
than once, even when the corresponding keybinding modes don't
overlap, so the FOO_KEY_NO_DIALOG shortcuts introduced in commit
b7827c13d823 never actually worked.
Instead, use the new 'action-mode' parameter that was added to the
'Activated' signal to determine whether to a power action should
be interactive or not.

https://bugzilla.gnome.org/show_bug.cgi?id=741762
---
 plugins/media-keys/gsd-media-keys-manager.c | 28 +++++++++++-----------------
 plugins/media-keys/media-keys.h             |  4 ----
 plugins/media-keys/shortcuts-list.h         | 13 ++++---------
 3 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 1c00b85..1108194 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -2014,11 +2014,14 @@ do_custom_action (GsdMediaKeysManager *manager,
 static gboolean
 do_action (GsdMediaKeysManager *manager,
            guint                deviceid,
+           guint                mode,
            MediaKeyType         type,
            gint64               timestamp)
 {
         g_debug ("Launching action for key type '%d' (on device id %d)", type, deviceid);
 
+        gboolean power_action_interactive = !(POWER_KEYS_MODE_NO_DIALOG & mode);
+
         switch (type) {
         case TOUCHPAD_KEY:
                 do_touchpad_action (manager);
@@ -2138,28 +2141,16 @@ do_action (GsdMediaKeysManager *manager,
 		do_toggle_contrast_action (manager);
 		break;
         case POWER_KEY:
-                do_config_power_action (manager, "button-power", FALSE);
+                do_config_power_action (manager, "button-power", power_action_interactive);
                 break;
         case SLEEP_KEY:
-                do_config_power_action (manager, "button-sleep", FALSE);
+                do_config_power_action (manager, "button-sleep", power_action_interactive);
                 break;
         case SUSPEND_KEY:
-                do_config_power_action (manager, "button-suspend", FALSE);
+                do_config_power_action (manager, "button-suspend", power_action_interactive);
                 break;
         case HIBERNATE_KEY:
-                do_config_power_action (manager, "button-hibernate", FALSE);
-                break;
-        case POWER_KEY_NO_DIALOG:
-                do_config_power_action (manager, "button-power", TRUE);
-                break;
-        case SLEEP_KEY_NO_DIALOG:
-                do_config_power_action (manager, "button-sleep", TRUE);
-                break;
-        case SUSPEND_KEY_NO_DIALOG:
-                do_config_power_action (manager, "button-suspend", TRUE);
-                break;
-        case HIBERNATE_KEY_NO_DIALOG:
-                do_config_power_action (manager, "button-hibernate", TRUE);
+                do_config_power_action (manager, "button-hibernate", power_action_interactive);
                 break;
         case SCREEN_BRIGHTNESS_UP_KEY:
         case SCREEN_BRIGHTNESS_DOWN_KEY:
@@ -2189,6 +2180,7 @@ on_accelerator_activated (ShellKeyGrabber     *grabber,
         guint i;
         guint deviceid;
         guint timestamp;
+        guint mode;
 
         g_variant_dict_init (&dict, parameters);
 
@@ -2196,6 +2188,8 @@ on_accelerator_activated (ShellKeyGrabber     *grabber,
               deviceid = 0;
         if (!g_variant_dict_lookup (&dict, "timestamp", "u", &timestamp))
               timestamp = GDK_CURRENT_TIME;
+        if (!g_variant_dict_lookup (&dict, "action-mode", "u", &mode))
+              mode = 0;
 
         for (i = 0; i < manager->priv->keys->len; i++) {
                 MediaKey *key;
@@ -2208,7 +2202,7 @@ on_accelerator_activated (ShellKeyGrabber     *grabber,
                 if (key->key_type == CUSTOM_KEY)
                         do_custom_action (manager, deviceid, key, timestamp);
                 else
-                        do_action (manager, deviceid, key->key_type, timestamp);
+                        do_action (manager, deviceid, mode, key->key_type, timestamp);
                 return;
         }
 }
diff --git a/plugins/media-keys/media-keys.h b/plugins/media-keys/media-keys.h
index dd1ffd2..970415b 100644
--- a/plugins/media-keys/media-keys.h
+++ b/plugins/media-keys/media-keys.h
@@ -72,10 +72,6 @@ typedef enum {
         SLEEP_KEY,
         SUSPEND_KEY,
         HIBERNATE_KEY,
-        POWER_KEY_NO_DIALOG,
-        SLEEP_KEY_NO_DIALOG,
-        SUSPEND_KEY_NO_DIALOG,
-        HIBERNATE_KEY_NO_DIALOG,
         SCREEN_BRIGHTNESS_UP_KEY,
         SCREEN_BRIGHTNESS_DOWN_KEY,
         KEYBOARD_BRIGHTNESS_UP_KEY,
diff --git a/plugins/media-keys/shortcuts-list.h b/plugins/media-keys/shortcuts-list.h
index de9fde2..a9958f1 100644
--- a/plugins/media-keys/shortcuts-list.h
+++ b/plugins/media-keys/shortcuts-list.h
@@ -28,11 +28,12 @@
                                       SHELL_KEYBINDING_MODE_OVERVIEW)
 #define SCREENSAVER_MODE SHELL_KEYBINDING_MODE_ALL & ~SHELL_KEYBINDING_MODE_UNLOCK_SCREEN
 #define NO_LOCK_MODE SCREENSAVER_MODE & ~SHELL_KEYBINDING_MODE_LOCK_SCREEN
-#define POWER_KEYS_MODE (SHELL_KEYBINDING_MODE_NORMAL | \
-			 SHELL_KEYBINDING_MODE_OVERVIEW | \
-			 SHELL_KEYBINDING_MODE_LOGIN_SCREEN)
 #define POWER_KEYS_MODE_NO_DIALOG (SHELL_KEYBINDING_MODE_LOCK_SCREEN | \
 				   SHELL_KEYBINDING_MODE_UNLOCK_SCREEN)
+#define POWER_KEYS_MODE (SHELL_KEYBINDING_MODE_NORMAL | \
+			 SHELL_KEYBINDING_MODE_OVERVIEW | \
+			 SHELL_KEYBINDING_MODE_LOGIN_SCREEN |\
+                         POWER_KEYS_MODE_NO_DIALOG)
 
 static struct {
         MediaKeyType key_type;
@@ -100,12 +101,6 @@ static struct {
         { SLEEP_KEY, NULL, N_("Sleep"), "XF86Suspend", POWER_KEYS_MODE },
         { SUSPEND_KEY, NULL, N_("Suspend"), "XF86Sleep", POWER_KEYS_MODE },
         { HIBERNATE_KEY, NULL, N_("Hibernate"), "XF86Hibernate", POWER_KEYS_MODE },
-        { POWER_KEY_NO_DIALOG, NULL, N_("Power Off"), "XF86PowerOff", POWER_KEYS_MODE_NO_DIALOG },
-        /* the kernel / Xorg names really are like this... */
-        /* translators: "Sleep" means putting the machine to sleep, either through hibernate or suspend */
-        { SLEEP_KEY_NO_DIALOG, NULL, N_("Sleep"), "XF86Suspend", POWER_KEYS_MODE_NO_DIALOG },
-        { SUSPEND_KEY_NO_DIALOG, NULL, N_("Suspend"), "XF86Sleep", POWER_KEYS_MODE_NO_DIALOG },
-        { HIBERNATE_KEY_NO_DIALOG, NULL, N_("Hibernate"), "XF86Hibernate", POWER_KEYS_MODE_NO_DIALOG },
         { SCREEN_BRIGHTNESS_UP_KEY, NULL, N_("Brightness Up"), "XF86MonBrightnessUp", SHELL_KEYBINDING_MODE_ALL },
         { SCREEN_BRIGHTNESS_DOWN_KEY, NULL, N_("Brightness Down"), "XF86MonBrightnessDown", SHELL_KEYBINDING_MODE_ALL },
         { KEYBOARD_BRIGHTNESS_UP_KEY, NULL, N_("Keyboard Brightness Up"), "XF86KbdBrightnessUp", SHELL_KEYBINDING_MODE_ALL },
-- 
2.3.6


From 89d8fa73f87f4a93f4fd328ca427d91cd6dfb562 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Wed, 1 Apr 2015 11:34:14 +0200
Subject: [PATCH 3/3] media-keys: Fix logic error when handling power keys
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In the lock screen, means non-interactive action:
in_lock_screen == !power_action_interactive

Rename the variable to avoid having to invert it twice.

Spotted by Clément Guérin <geecko.dev@free.fr>

https://bugzilla.gnome.org/show_bug.cgi?id=746980
---
 plugins/media-keys/gsd-media-keys-manager.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 1108194..db14c7f 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -2020,7 +2020,7 @@ do_action (GsdMediaKeysManager *manager,
 {
         g_debug ("Launching action for key type '%d' (on device id %d)", type, deviceid);
 
-        gboolean power_action_interactive = !(POWER_KEYS_MODE_NO_DIALOG & mode);
+        gboolean power_action_noninteractive = (POWER_KEYS_MODE_NO_DIALOG & mode);
 
         switch (type) {
         case TOUCHPAD_KEY:
@@ -2141,16 +2141,16 @@ do_action (GsdMediaKeysManager *manager,
 		do_toggle_contrast_action (manager);
 		break;
         case POWER_KEY:
-                do_config_power_action (manager, "button-power", power_action_interactive);
+                do_config_power_action (manager, "button-power", power_action_noninteractive);
                 break;
         case SLEEP_KEY:
-                do_config_power_action (manager, "button-sleep", power_action_interactive);
+                do_config_power_action (manager, "button-sleep", power_action_noninteractive);
                 break;
         case SUSPEND_KEY:
-                do_config_power_action (manager, "button-suspend", power_action_interactive);
+                do_config_power_action (manager, "button-suspend", power_action_noninteractive);
                 break;
         case HIBERNATE_KEY:
-                do_config_power_action (manager, "button-hibernate", power_action_interactive);
+                do_config_power_action (manager, "button-hibernate", power_action_noninteractive);
                 break;
         case SCREEN_BRIGHTNESS_UP_KEY:
         case SCREEN_BRIGHTNESS_DOWN_KEY:
-- 
2.3.6