Blame SOURCES/0015-windows-fix-nonuniform-behavior-of-zoom-hotkeys.patch

0f5b8b
From a40c8f4508e96c29ea5a24042906d5ded90241fb Mon Sep 17 00:00:00 2001
0f5b8b
From: =?UTF-8?q?Jakub=20Jank=C5=AF?= <jjanku@redhat.com>
0f5b8b
Date: Thu, 3 Dec 2020 13:40:33 +0100
0f5b8b
Subject: [PATCH] windows: fix nonuniform behavior of zoom hotkeys
0f5b8b
MIME-Version: 1.0
0f5b8b
Content-Type: text/plain; charset=UTF-8
0f5b8b
Content-Transfer-Encoding: 8bit
0f5b8b
0f5b8b
If a vv file is used or the hotkeys are customized using the
0f5b8b
--hotkeys cmd option, all hotkeys that are not explicitly
0f5b8b
requested get disabled, this includes the zomm hotkeys.
0f5b8b
0f5b8b
As a consequence, the labels for zoom actions in the menu
0f5b8b
disappear. However, the user can still perform these actions
0f5b8b
using the keys on the numpad which are handled separately.
0f5b8b
0f5b8b
To fix it, check that the normal zoom hotkeys are enabled
0f5b8b
before enabling the keypad ones.
0f5b8b
0f5b8b
Related to: https://bugzilla.redhat.com/show_bug.cgi?id=1791261
0f5b8b
0f5b8b
Signed-off-by: Jakub Janků <jjanku@redhat.com>
0f5b8b
---
0f5b8b
 src/virt-viewer-window.c | 24 +++++++++++++++---------
0f5b8b
 1 file changed, 15 insertions(+), 9 deletions(-)
0f5b8b
0f5b8b
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
0f5b8b
index eed3086..5647023 100644
0f5b8b
--- a/src/virt-viewer-window.c
0f5b8b
+++ b/src/virt-viewer-window.c
0f5b8b
@@ -887,6 +887,7 @@ virt_viewer_window_enable_modifiers(VirtViewerWindow *self)
0f5b8b
     VirtViewerWindowPrivate *priv = self->priv;
0f5b8b
     GSList *accels;
0f5b8b
     guint i;
0f5b8b
+    GtkAccelKey key;
0f5b8b
 
0f5b8b
     if (priv->accel_enabled)
0f5b8b
         return;
0f5b8b
@@ -904,15 +905,20 @@ virt_viewer_window_enable_modifiers(VirtViewerWindow *self)
0f5b8b
                  "gtk-enable-mnemonics", priv->enable_mnemonics_save,
0f5b8b
                  NULL);
0f5b8b
 
0f5b8b
-    g_action_map_add_action_entries(G_ACTION_MAP(priv->window),
0f5b8b
-                                    keypad_action_entries, G_N_ELEMENTS(keypad_action_entries),
0f5b8b
-                                    self);
0f5b8b
-    for (i = 0; i < G_N_ELEMENTS(keypad_action_entries); i++) {
0f5b8b
-        gchar *detailed_name = g_strdup_printf("win.%s", keypad_action_entries[i].name);
0f5b8b
-        gtk_application_set_accels_for_action(GTK_APPLICATION(priv->app),
0f5b8b
-                                              detailed_name,
0f5b8b
-                                              keypad_action_accels[i]);
0f5b8b
-        g_free(detailed_name);
0f5b8b
+    /* if zoom actions using "normal" +/-/0 keys are enabled,
0f5b8b
+     * allow the user to use the numpad +/-/0 keys as well */
0f5b8b
+    if (gtk_accel_map_lookup_entry("<virt-viewer>/view/zoom-out", &key)
0f5b8b
+        && key.accel_key != 0) {
0f5b8b
+        g_action_map_add_action_entries(G_ACTION_MAP(priv->window),
0f5b8b
+                                        keypad_action_entries, G_N_ELEMENTS(keypad_action_entries),
0f5b8b
+                                        self);
0f5b8b
+        for (i = 0; i < G_N_ELEMENTS(keypad_action_entries); i++) {
0f5b8b
+            gchar *detailed_name = g_strdup_printf("win.%s", keypad_action_entries[i].name);
0f5b8b
+            gtk_application_set_accels_for_action(GTK_APPLICATION(priv->app),
0f5b8b
+                                                  detailed_name,
0f5b8b
+                                                  keypad_action_accels[i]);
0f5b8b
+            g_free(detailed_name);
0f5b8b
+        }
0f5b8b
     }
0f5b8b
 
0f5b8b
     priv->accel_enabled = TRUE;
0f5b8b
-- 
0f5b8b
2.29.2
0f5b8b