aboutsummaryrefslogtreecommitdiff
path: root/x11
diff options
context:
space:
mode:
authorGuido Falsi <madpilot@FreeBSD.org>2020-07-16 08:48:39 +0000
committerGuido Falsi <madpilot@FreeBSD.org>2020-07-16 08:48:39 +0000
commit97f0d0ef348d7279d40fae8164a30b696258daa3 (patch)
tree389c7ea05de243f6c8b734c80b7dc5bae8b92e34 /x11
parent9dc5efc0fe5f76503594da2c1f94a9b8692e4d9c (diff)
downloadports-97f0d0ef348d7279d40fae8164a30b696258daa3.tar.gz
ports-97f0d0ef348d7279d40fae8164a30b696258daa3.zip
MFH: r542258
Update patch to Fix leaked keygrabs when layout changes to code merged upstream. PR: 244290 Submitted by: Aryeh Friedman <aryeh.friedman AT gmail.com>, many others Obtained from: https://gitlab.xfce.org/xfce/libxfce4ui/-/merge_requests/2 Differential Revision: https://reviews.freebsd.org/D24995 Approved by: portmgr (joneum)
Notes
Notes: svn path=/branches/2020Q3/; revision=542340
Diffstat (limited to 'x11')
-rw-r--r--x11/libxfce4menu/Makefile2
-rw-r--r--x11/libxfce4menu/files/patch-libxfce4kbd-private_xfce-shortcuts-grabber.c123
2 files changed, 50 insertions, 75 deletions
diff --git a/x11/libxfce4menu/Makefile b/x11/libxfce4menu/Makefile
index c880d9f0a113..1e8924e56264 100644
--- a/x11/libxfce4menu/Makefile
+++ b/x11/libxfce4menu/Makefile
@@ -3,7 +3,7 @@
PORTNAME= libxfce4menu
PORTVERSION= 4.14.1
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= x11 xfce
MASTER_SITES= XFCE
DISTNAME= libxfce4ui-${DISTVERSIONFULL}
diff --git a/x11/libxfce4menu/files/patch-libxfce4kbd-private_xfce-shortcuts-grabber.c b/x11/libxfce4menu/files/patch-libxfce4kbd-private_xfce-shortcuts-grabber.c
index 45a0ada41560..cc012aa82466 100644
--- a/x11/libxfce4menu/files/patch-libxfce4kbd-private_xfce-shortcuts-grabber.c
+++ b/x11/libxfce4menu/files/patch-libxfce4kbd-private_xfce-shortcuts-grabber.c
@@ -1,99 +1,74 @@
---- libxfce4kbd-private/xfce-shortcuts-grabber.c.orig 2020-04-08 15:05:21 UTC
+--- libxfce4kbd-private/xfce-shortcuts-grabber.c.orig 2019-08-11 16:02:06 UTC
+++ libxfce4kbd-private/xfce-shortcuts-grabber.c
-@@ -74,6 +74,16 @@ struct _XfceKey
+@@ -72,8 +72,9 @@ struct _XfceShortcutsGrabberPrivate
+
+ struct _XfceKey
{
- guint keyval;
- guint modifiers;
-+ /*
-+ * Cache of old keycodes grabbed by this key. Used to ungrab the keycodes we
-+ * actually grabbed.
-+ *
-+ * An arbitrary number of keys may generate the same keyval. Rather than add
-+ * memory allocation to this path, I just constrained the unmapping behavior
-+ * to 8 identically coded keys. It seems unlikely? But I am no xkeyboard
-+ * expert.
-+ */
-+ int keycodes[8];
+- guint keyval;
+- guint modifiers;
++ guint keyval;
++ guint modifiers;
++ GArray *keycodes;
};
-@@ -269,12 +279,20 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
- }
-
- /* Get all keys generating keyval */
-- if (!gdk_keymap_get_entries_for_keyval (keymap,key->keyval,
-+ if (grab && !gdk_keymap_get_entries_for_keyval (keymap,key->keyval,
- &keys, &n_keys))
- {
- TRACE ("Got no keys for keyval");
- return;
- }
-+ if (grab)
-+ {
-+ if (n_keys > G_N_ELEMENTS(key->keycodes))
-+ TRACE ("Got %d keys for keyval but can remember only %d", n_keys,
-+ (int)G_N_ELEMENTS(key->keycodes));
-+ }
-+ else
-+ n_keys = G_N_ELEMENTS(key->keycodes);
-
- if (n_keys == 0)
- {
-@@ -290,9 +308,9 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
- for (i = 0; i < n_keys; i ++)
- {
- /* Grab all hardware keys generating keyval */
-+ if (grab)
-+ TRACE ("New Keycode: %d", keys[i].keycode);
-
-- TRACE ("Keycode: %d", keys[i].keycode);
--
- for (j = 0; j < screens; j++)
- {
- /* Do the grab on all screens */
-@@ -338,11 +356,14 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
- False,
+@@ -339,10 +340,14 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
GrabModeAsync,
GrabModeAsync);
-- else
-+ else {
-+ if (key->keycodes[i] == -1)
-+ break;
- XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
+ else
+- XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
- keys[i].keycode,
-+ key->keycodes[i],
- modifiers | mod_masks [k],
- root_window);
-+ }
+- modifiers | mod_masks [k],
+- root_window);
++ {
++ if (i >= key->keycodes->len)
++ break;
++ XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
++ g_array_index (key->keycodes, guint, i),
++ modifiers | mod_masks [k],
++ root_window);
++ }
}
gdk_flush ();
-@@ -355,9 +376,18 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
+@@ -355,8 +360,20 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *gra
TRACE ("Failed to ungrab");
}
}
+ /* Remember the old keycode, as we need it to ungrab. */
-+ if (grab && i < G_N_ELEMENTS (key->keycodes))
-+ key->keycodes[i] = keys[i].keycode;
-+ else if (!grab)
-+ key->keycodes[i] = -1;
++ if (grab)
++ g_array_append_val (key->keycodes, keys[i].keycode);
++ else
++ g_array_index(key->keycodes, guint, i) = UINT_MAX;
}
-- g_free (keys);
-+ if (grab) {
-+ g_free (keys);
-+ for (; i < G_N_ELEMENTS (key->keycodes); i++)
-+ key->keycodes[i] = -1;
-+ }
++ /* Cleanup elements containing UINT_MAX from the key->keycodes array */
++ for (i = key->keycodes->len - 1; i >= 0; i --)
++ {
++ if (g_array_index(key->keycodes, guint, i) == UINT_MAX)
++ g_array_remove_index_fast(key->keycodes, i);
++ }
++
+ g_free (keys);
}
-
-@@ -514,6 +544,8 @@ xfce_shortcuts_grabber_add (XfceShortcutsGrabber *grab
+@@ -514,6 +531,7 @@ xfce_shortcuts_grabber_add (XfceShortcutsGrabber *grab
g_return_if_fail (shortcut != NULL);
key = g_new0 (XfceKey, 1);
-+ for (size_t i = 0; i < G_N_ELEMENTS (key->keycodes); i++)
-+ key->keycodes[i] = -1;
++ key->keycodes = g_array_new (FALSE, TRUE, sizeof (guint));
gtk_accelerator_parse (shortcut, &key->keyval, &key->modifiers);
+@@ -523,7 +541,10 @@ xfce_shortcuts_grabber_add (XfceShortcutsGrabber *grab
+ g_hash_table_insert (grabber->priv->keys, g_strdup (shortcut), key);
+ }
+ else
+- g_free (key);
++ {
++ g_array_free (key->keycodes, TRUE);
++ g_free (key);
++ }
+ }
+
+