[Xfce4-commits] [xfce/xfwm4] 04/07: Fix keyboard shortcuts vs. layout change

noreply at xfce.org noreply at xfce.org
Fri Feb 6 22:23:09 CET 2015


This is an automated email from the git hooks/post-receive script.

olivier pushed a commit to branch master
in repository xfce/xfwm4.

commit ec233f961cdccb31c09eb22a3c50f5bb4c270f52
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Fri Feb 6 22:02:38 2015 +0100

    Fix keyboard shortcuts vs. layout change
    
    When changing keyboard layouts, if a shortcut is using a key which is
    placed at a different location (e.g. QWERTY vs. AZERTY), it would stop
    working with the different layout.
    
    Parse all shortcuts on keymap layout changes to update keys shortcut.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/settings.c |   39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/src/settings.c b/src/settings.c
index 061da7b..502e51b 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -48,6 +48,9 @@
 #define THEMERC                 "themerc"
 #define XPM_COLOR_SYMBOL_SIZE   24
 
+#define KEYMAP_UPDATE_TIMEOUT   250 /* ms */
+static guint keymap_timeout   = 0;
+
 /* Forward static decls. */
 
 static void              update_grabs      (ScreenInfo *);
@@ -1441,18 +1444,46 @@ cb_xfwm4_channel_property_changed(XfconfChannel *channel, const gchar *property_
     }
 }
 
-static void
-cb_keys_changed (GdkKeymap *keymap, ScreenInfo *screen_info)
+
+static gboolean
+keymap_reload (gpointer data)
 {
+    ScreenInfo *screen_info = (ScreenInfo *) data;
+
+    g_return_val_if_fail (screen_info != NULL, FALSE);
+    TRACE ("entering keymap_reload");
+
     /* Recompute modifiers mask in case it changed */
     initModifiers (myScreenGetXDisplay (screen_info));
 
-    /* Ungrab/regrab shortcuts */
+    /* Ungrab shortcuts and clear existing bindings */
     myScreenUngrabKeys (screen_info);
+    unloadKeyBindings (screen_info);
+
+    /* Reload new key bindings and regrab shortcuts */
+    loadKeyBindings  (screen_info);
     myScreenGrabKeys (screen_info);
 
-    /* Uupdate all grabs for mouse buttons */
+    /* Update all grabs for mouse buttons */
     clientUpdateAllFrames (screen_info, UPDATE_BUTTON_GRABS);
+
+    /* We're done */
+    keymap_timeout = 0;
+
+    return FALSE;
+}
+
+static void
+cb_keys_changed (GdkKeymap *keymap, ScreenInfo *screen_info)
+{
+    if (keymap_timeout)
+    {
+        g_source_remove (keymap_timeout);
+    }
+    keymap_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT,
+                                         KEYMAP_UPDATE_TIMEOUT,
+                                         (GSourceFunc) keymap_reload,
+                                         (gpointer) screen_info, NULL);
 }
 
 static void

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list