[gnome-settings-daemon] media-keys: Make power-actions non-interactive based on mode



commit 8d417087fce833f77c115baad523d710451f2bd5
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Dec 19 14:30:15 2014 +0100

    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 f9d5a75..c5cbebd 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -2023,11 +2023,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);
@@ -2147,28 +2150,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:
@@ -2198,6 +2189,7 @@ on_accelerator_activated (ShellKeyGrabber     *grabber,
         guint i;
         guint deviceid;
         guint timestamp;
+        guint mode;
 
         g_variant_dict_init (&dict, parameters);
 
@@ -2205,6 +2197,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;
@@ -2217,7 +2211,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 4b1eacd..e8ab8ea 100644
--- a/plugins/media-keys/shortcuts-list.h
+++ b/plugins/media-keys/shortcuts-list.h
@@ -28,11 +28,12 @@
                                   SHELL_ACTION_MODE_OVERVIEW)
 #define SCREENSAVER_MODE SHELL_ACTION_MODE_ALL & ~SHELL_ACTION_MODE_UNLOCK_SCREEN
 #define NO_LOCK_MODE SCREENSAVER_MODE & ~SHELL_ACTION_MODE_LOCK_SCREEN
-#define POWER_KEYS_MODE (SHELL_ACTION_MODE_NORMAL | \
-                        SHELL_ACTION_MODE_OVERVIEW | \
-                        SHELL_ACTION_MODE_LOGIN_SCREEN)
 #define POWER_KEYS_MODE_NO_DIALOG (SHELL_ACTION_MODE_LOCK_SCREEN | \
                                   SHELL_ACTION_MODE_UNLOCK_SCREEN)
+#define POWER_KEYS_MODE (SHELL_ACTION_MODE_NORMAL | \
+                        SHELL_ACTION_MODE_OVERVIEW | \
+                        SHELL_ACTION_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_ACTION_MODE_ALL 
},
         { SCREEN_BRIGHTNESS_DOWN_KEY, NULL, N_("Brightness Down"), "XF86MonBrightnessDown", 
SHELL_ACTION_MODE_ALL },
         { KEYBOARD_BRIGHTNESS_UP_KEY, NULL, N_("Keyboard Brightness Up"), "XF86KbdBrightnessUp", 
SHELL_ACTION_MODE_ALL },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]