View | Details | Raw Unified | Return to bug 244290 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (-1 / +1 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	libxfce4menu
4
PORTNAME=	libxfce4menu
5
PORTVERSION=	4.14.1
5
PORTVERSION=	4.14.1
6
PORTREVISION=	1
6
PORTREVISION=	2
7
CATEGORIES=	x11 xfce
7
CATEGORIES=	x11 xfce
8
MASTER_SITES=	XFCE
8
MASTER_SITES=	XFCE
9
DISTNAME=	libxfce4ui-${DISTVERSIONFULL}
9
DISTNAME=	libxfce4ui-${DISTVERSIONFULL}
(-)files/patch-libxfce4kbd-private_xfce-shortcuts-grabber.c (-74 / +49 lines)
Lines 1-99 Link Here
1
--- libxfce4kbd-private/xfce-shortcuts-grabber.c.orig	2020-04-08 15:05:21 UTC
1
--- libxfce4kbd-private/xfce-shortcuts-grabber.c.orig	2019-08-11 16:02:06 UTC
2
+++ libxfce4kbd-private/xfce-shortcuts-grabber.c
2
+++ libxfce4kbd-private/xfce-shortcuts-grabber.c
3
@@ -74,6 +74,16 @@ struct _XfceKey
3
@@ -72,8 +72,9 @@ struct _XfceShortcutsGrabberPrivate
4
 
5
 struct _XfceKey
4
 {
6
 {
5
   guint keyval;
7
-  guint keyval;
6
   guint modifiers;
8
-  guint modifiers;
7
+  /*
9
+  guint   keyval;
8
+   * Cache of old keycodes grabbed by this key.  Used to ungrab the keycodes we
10
+  guint   modifiers;
9
+   * actually grabbed.
11
+  GArray *keycodes;
10
+   *
11
+   * An arbitrary number of keys may generate the same keyval.  Rather than add
12
+   * memory allocation to this path, I just constrained the unmapping behavior
13
+   * to 8 identically coded keys.  It seems unlikely?  But I am no xkeyboard
14
+   * expert.
15
+   */
16
+  int keycodes[8];
17
 };
12
 };
18
 
13
 
19
 
14
 
20
@@ -269,12 +279,20 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
15
@@ -339,10 +340,14 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
21
     }
22
 
23
   /* Get all keys generating keyval */
24
-  if (!gdk_keymap_get_entries_for_keyval (keymap,key->keyval,
25
+  if (grab && !gdk_keymap_get_entries_for_keyval (keymap,key->keyval,
26
                                           &keys, &n_keys))
27
     {
28
       TRACE ("Got no keys for keyval");
29
       return;
30
     }
31
+  if (grab)
32
+    {
33
+      if (n_keys > G_N_ELEMENTS(key->keycodes))
34
+        TRACE ("Got %d keys for keyval but can remember only %d", n_keys,
35
+          (int)G_N_ELEMENTS(key->keycodes));
36
+    }
37
+  else
38
+    n_keys = G_N_ELEMENTS(key->keycodes);
39
 
40
   if (n_keys == 0)
41
     {
42
@@ -290,9 +308,9 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
43
   for (i = 0; i < n_keys; i ++)
44
     {
45
       /* Grab all hardware keys generating keyval */
46
+      if (grab)
47
+        TRACE ("New Keycode: %d", keys[i].keycode);
48
 
49
-      TRACE ("Keycode: %d", keys[i].keycode);
50
-
51
       for (j = 0; j < screens; j++)
52
         {
53
           /* Do the grab on all screens */
54
@@ -338,11 +356,14 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
55
                           False,
56
                           GrabModeAsync,
16
                           GrabModeAsync,
57
                           GrabModeAsync);
17
                           GrabModeAsync);
58
-              else
18
               else
59
+              else {
19
-                XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
60
+                if (key->keycodes[i] == -1)
61
+                  break;
62
                 XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
63
-                            keys[i].keycode,
20
-                            keys[i].keycode,
64
+                            key->keycodes[i],
21
-                            modifiers | mod_masks [k],
65
                             modifiers | mod_masks [k],
22
-                            root_window);
66
                             root_window);
23
+                {
67
+              }
24
+                  if (i >= key->keycodes->len)
25
+                    break;
26
+                  XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
27
+                              g_array_index (key->keycodes, guint, i),
28
+                              modifiers | mod_masks [k],
29
+                              root_window);
30
+                }
68
             }
31
             }
69
 
32
 
70
           gdk_flush ();
33
           gdk_flush ();
71
@@ -355,9 +376,18 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
34
@@ -355,8 +360,20 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
72
                 TRACE ("Failed to ungrab");
35
                 TRACE ("Failed to ungrab");
73
             }
36
             }
74
         }
37
         }
75
+      /* Remember the old keycode, as we need it to ungrab. */
38
+      /* Remember the old keycode, as we need it to ungrab. */
76
+      if (grab && i < G_N_ELEMENTS (key->keycodes))
39
+      if (grab)
77
+        key->keycodes[i] = keys[i].keycode;
40
+        g_array_append_val (key->keycodes, keys[i].keycode);
78
+      else if (!grab)
41
+      else
79
+        key->keycodes[i] = -1;
42
+        g_array_index(key->keycodes, guint, i) = UINT_MAX;
80
     }
43
     }
81
 
44
 
82
-  g_free (keys);
45
+  /* Cleanup elements containing UINT_MAX from the key->keycodes array */
83
+  if (grab) {
46
+  for (i = key->keycodes->len - 1; i >= 0; i --)
84
+    g_free (keys);
47
+    {
85
+    for (; i < G_N_ELEMENTS (key->keycodes); i++)
48
+      if (g_array_index(key->keycodes, guint, i) == UINT_MAX)
86
+      key->keycodes[i] = -1;
49
+        g_array_remove_index_fast(key->keycodes, i);
87
+  }
50
+    }
51
+
52
   g_free (keys);
88
 }
53
 }
89
 
54
 
90
 
55
@@ -514,6 +531,7 @@ xfce_shortcuts_grabber_add (XfceShortcutsGrabber *grab
91
@@ -514,6 +544,8 @@ xfce_shortcuts_grabber_add (XfceShortcutsGrabber *grab
92
   g_return_if_fail (shortcut != NULL);
56
   g_return_if_fail (shortcut != NULL);
93
 
57
 
94
   key = g_new0 (XfceKey, 1);
58
   key = g_new0 (XfceKey, 1);
95
+  for (size_t i = 0; i < G_N_ELEMENTS (key->keycodes); i++)
59
+  key->keycodes = g_array_new (FALSE, TRUE, sizeof (guint));
96
+    key->keycodes[i] = -1;
97
 
60
 
98
   gtk_accelerator_parse (shortcut, &key->keyval, &key->modifiers);
61
   gtk_accelerator_parse (shortcut, &key->keyval, &key->modifiers);
99
 
62
 
63
@@ -523,7 +541,10 @@ xfce_shortcuts_grabber_add (XfceShortcutsGrabber *grab
64
       g_hash_table_insert (grabber->priv->keys, g_strdup (shortcut), key);
65
     }
66
   else
67
-    g_free (key);
68
+    {
69
+      g_array_free (key->keycodes, TRUE);
70
+      g_free (key);
71
+    }
72
 }
73
 
74
 

Return to bug 244290