Blame SOURCES/0003-media-keys-Allow-the-power-key-in-more-places.patch

edfd78
From f9c12c90d84a3b79321e983d90e40e01ce54e3fa Mon Sep 17 00:00:00 2001
edfd78
From: Bastien Nocera <hadess@hadess.net>
edfd78
Date: Wed, 6 Nov 2013 17:54:53 +0100
edfd78
Subject: [PATCH 3/3] media-keys: Allow the power key in more places
edfd78
edfd78
We allow using the power key pretty much everywhere now, but
edfd78
we also ensure that we never show interactive dialogues on the
edfd78
lock screen (something that was possible with other suspend/power
edfd78
buttons already if more than more than one user was logged in,
edfd78
or an interactive shutdown was configured).
edfd78
edfd78
See https://bugzilla.redhat.com/show_bug.cgi?id=980692
edfd78
edfd78
https://bugzilla.gnome.org/show_bug.cgi?id=707095
edfd78
---
edfd78
 plugins/media-keys/gsd-media-keys-manager.c | 37 ++++++++++++++++++++---------
edfd78
 plugins/media-keys/shortcuts-list.h         | 23 ++++++++++++++----
edfd78
 2 files changed, 45 insertions(+), 15 deletions(-)
edfd78
edfd78
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
edfd78
index cab4aa2..6609165 100644
edfd78
--- a/plugins/media-keys/gsd-media-keys-manager.c
edfd78
+++ b/plugins/media-keys/gsd-media-keys-manager.c
edfd78
@@ -1767,11 +1767,12 @@ do_toggle_contrast_action (GsdMediaKeysManager *manager)
edfd78
 
edfd78
 static void
edfd78
 power_action (GsdMediaKeysManager *manager,
edfd78
-              const char          *action)
edfd78
+              const char          *action,
edfd78
+              gboolean             allow_interaction)
edfd78
 {
edfd78
         g_dbus_proxy_call (manager->priv->logind_proxy,
edfd78
                            action,
edfd78
-                           g_variant_new ("(b)", TRUE),
edfd78
+                           g_variant_new ("(b)", allow_interaction),
edfd78
                            G_DBUS_CALL_FLAGS_NONE,
edfd78
                            G_MAXINT,
edfd78
                            manager->priv->bus_cancellable,
edfd78
@@ -1780,7 +1781,8 @@ power_action (GsdMediaKeysManager *manager,
edfd78
 
edfd78
 static void
edfd78
 do_config_power_action (GsdMediaKeysManager *manager,
edfd78
-                        const gchar *config_key)
edfd78
+                        const gchar *config_key,
edfd78
+                        gboolean in_lock_screen)
edfd78
 {
edfd78
         GsdPowerActionType action_type;
edfd78
 
edfd78
@@ -1788,16 +1790,17 @@ do_config_power_action (GsdMediaKeysManager *manager,
edfd78
                                            config_key);
edfd78
         switch (action_type) {
edfd78
         case GSD_POWER_ACTION_SUSPEND:
edfd78
-                power_action (manager, "Suspend");
edfd78
+                power_action (manager, "Suspend", !in_lock_screen);
edfd78
                 break;
edfd78
         case GSD_POWER_ACTION_INTERACTIVE:
edfd78
-                gnome_session_shutdown (manager);
edfd78
+                if (!in_lock_screen)
edfd78
+                        gnome_session_shutdown (manager);
edfd78
                 break;
edfd78
         case GSD_POWER_ACTION_SHUTDOWN:
edfd78
-                power_action (manager, "PowerOff");
edfd78
+                power_action (manager, "PowerOff", !in_lock_screen);
edfd78
                 break;
edfd78
         case GSD_POWER_ACTION_HIBERNATE:
edfd78
-                power_action (manager, "Hibernate");
edfd78
+                power_action (manager, "Hibernate", !in_lock_screen);
edfd78
                 break;
edfd78
         case GSD_POWER_ACTION_BLANK:
edfd78
         case GSD_POWER_ACTION_NOTHING:
edfd78
@@ -2064,16 +2067,28 @@ do_action (GsdMediaKeysManager *manager,
edfd78
 		do_toggle_contrast_action (manager);
edfd78
 		break;
edfd78
         case POWER_KEY:
edfd78
-                do_config_power_action (manager, "button-power");
edfd78
+                do_config_power_action (manager, "button-power", FALSE);
edfd78
                 break;
edfd78
         case SLEEP_KEY:
edfd78
-                do_config_power_action (manager, "button-sleep");
edfd78
+                do_config_power_action (manager, "button-sleep", FALSE);
edfd78
                 break;
edfd78
         case SUSPEND_KEY:
edfd78
-                do_config_power_action (manager, "button-suspend");
edfd78
+                do_config_power_action (manager, "button-suspend", FALSE);
edfd78
                 break;
edfd78
         case HIBERNATE_KEY:
edfd78
-                do_config_power_action (manager, "button-hibernate");
edfd78
+                do_config_power_action (manager, "button-hibernate", FALSE);
edfd78
+                break;
edfd78
+        case POWER_KEY_NO_DIALOG:
edfd78
+                do_config_power_action (manager, "button-power", TRUE);
edfd78
+                break;
edfd78
+        case SLEEP_KEY_NO_DIALOG:
edfd78
+                do_config_power_action (manager, "button-sleep", TRUE);
edfd78
+                break;
edfd78
+        case SUSPEND_KEY_NO_DIALOG:
edfd78
+                do_config_power_action (manager, "button-suspend", TRUE);
edfd78
+                break;
edfd78
+        case HIBERNATE_KEY_NO_DIALOG:
edfd78
+                do_config_power_action (manager, "button-hibernate", TRUE);
edfd78
                 break;
edfd78
         case SCREEN_BRIGHTNESS_UP_KEY:
edfd78
         case SCREEN_BRIGHTNESS_DOWN_KEY:
edfd78
diff --git a/plugins/media-keys/shortcuts-list.h b/plugins/media-keys/shortcuts-list.h
edfd78
index 1ac0798..a2e6638 100644
edfd78
--- a/plugins/media-keys/shortcuts-list.h
edfd78
+++ b/plugins/media-keys/shortcuts-list.h
edfd78
@@ -75,6 +75,10 @@ typedef enum {
edfd78
         SLEEP_KEY,
edfd78
         SUSPEND_KEY,
edfd78
         HIBERNATE_KEY,
edfd78
+        POWER_KEY_NO_DIALOG,
edfd78
+        SLEEP_KEY_NO_DIALOG,
edfd78
+        SUSPEND_KEY_NO_DIALOG,
edfd78
+        HIBERNATE_KEY_NO_DIALOG,
edfd78
         SCREEN_BRIGHTNESS_UP_KEY,
edfd78
         SCREEN_BRIGHTNESS_DOWN_KEY,
edfd78
         KEYBOARD_BRIGHTNESS_UP_KEY,
edfd78
@@ -88,6 +92,11 @@ typedef enum {
edfd78
 #define GSD_KEYBINDING_MODE_LAUNCHER (SHELL_KEYBINDING_MODE_NORMAL | \
edfd78
                                       SHELL_KEYBINDING_MODE_OVERVIEW)
edfd78
 #define SCREENSAVER_MODE SHELL_KEYBINDING_MODE_ALL & ~SHELL_KEYBINDING_MODE_UNLOCK_SCREEN
edfd78
+#define POWER_KEYS_MODE (SHELL_KEYBINDING_MODE_NORMAL | \
edfd78
+			 SHELL_KEYBINDING_MODE_OVERVIEW | \
edfd78
+			 SHELL_KEYBINDING_MODE_LOGIN_SCREEN)
edfd78
+#define POWER_KEYS_MODE_NO_DIALOG (SHELL_KEYBINDING_MODE_LOCK_SCREEN | \
edfd78
+				   SHELL_KEYBINDING_MODE_UNLOCK_SCREEN)
edfd78
 
edfd78
 static struct {
edfd78
         MediaKeyType key_type;
edfd78
@@ -145,12 +154,18 @@ static struct {
edfd78
         { TOGGLE_CONTRAST_KEY, "toggle-contrast", NULL, NULL, SHELL_KEYBINDING_MODE_ALL },
edfd78
         { MAGNIFIER_ZOOM_IN_KEY, "magnifier-zoom-in", NULL, NULL, SHELL_KEYBINDING_MODE_ALL },
edfd78
         { MAGNIFIER_ZOOM_OUT_KEY, "magnifier-zoom-out", NULL, NULL, SHELL_KEYBINDING_MODE_ALL },
edfd78
-        { POWER_KEY, NULL, N_("Power Off"), "XF86PowerOff", GSD_KEYBINDING_MODE_LAUNCHER },
edfd78
+        { POWER_KEY, NULL, N_("Power Off"), "XF86PowerOff", POWER_KEYS_MODE },
edfd78
         /* the kernel / Xorg names really are like this... */
edfd78
         /* translators: "Sleep" means putting the machine to sleep, either through hibernate or suspend */
edfd78
-        { SLEEP_KEY, NULL, N_("Sleep"), "XF86Suspend", SHELL_KEYBINDING_MODE_ALL },
edfd78
-        { SUSPEND_KEY, NULL, N_("Suspend"), "XF86Sleep", SHELL_KEYBINDING_MODE_ALL },
edfd78
-        { HIBERNATE_KEY, NULL, N_("Hibernate"), "XF86Hibernate", SHELL_KEYBINDING_MODE_ALL },
edfd78
+        { SLEEP_KEY, NULL, N_("Sleep"), "XF86Suspend", POWER_KEYS_MODE },
edfd78
+        { SUSPEND_KEY, NULL, N_("Suspend"), "XF86Sleep", POWER_KEYS_MODE },
edfd78
+        { HIBERNATE_KEY, NULL, N_("Hibernate"), "XF86Hibernate", POWER_KEYS_MODE },
edfd78
+        { POWER_KEY_NO_DIALOG, NULL, N_("Power Off"), "XF86PowerOff", POWER_KEYS_MODE_NO_DIALOG },
edfd78
+        /* the kernel / Xorg names really are like this... */
edfd78
+        /* translators: "Sleep" means putting the machine to sleep, either through hibernate or suspend */
edfd78
+        { SLEEP_KEY_NO_DIALOG, NULL, N_("Sleep"), "XF86Suspend", POWER_KEYS_MODE_NO_DIALOG },
edfd78
+        { SUSPEND_KEY_NO_DIALOG, NULL, N_("Suspend"), "XF86Sleep", POWER_KEYS_MODE_NO_DIALOG },
edfd78
+        { HIBERNATE_KEY_NO_DIALOG, NULL, N_("Hibernate"), "XF86Hibernate", POWER_KEYS_MODE_NO_DIALOG },
edfd78
         { SCREEN_BRIGHTNESS_UP_KEY, NULL, N_("Brightness Up"), "XF86MonBrightnessUp", SHELL_KEYBINDING_MODE_ALL },
edfd78
         { SCREEN_BRIGHTNESS_DOWN_KEY, NULL, N_("Brightness Down"), "XF86MonBrightnessDown", SHELL_KEYBINDING_MODE_ALL },
edfd78
         { KEYBOARD_BRIGHTNESS_UP_KEY, NULL, N_("Keyboard Brightness Up"), "XF86KbdBrightnessUp", SHELL_KEYBINDING_MODE_ALL },
edfd78
-- 
edfd78
1.8.4.2
edfd78