From owner-svn-ports-all@freebsd.org Sun Apr 12 20:23:57 2020 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1A34C2C7E66; Sun, 12 Apr 2020 20:23:57 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 490jrX6vT7z4bvc; Sun, 12 Apr 2020 20:23:56 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E826375F2; Sun, 12 Apr 2020 20:23:56 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03CKNuk6036150; Sun, 12 Apr 2020 20:23:56 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03CKNubS036148; Sun, 12 Apr 2020 20:23:56 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202004122023.03CKNubS036148@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Sun, 12 Apr 2020 20:23:56 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r531554 - in head/x11/libxfce4menu: . files X-SVN-Group: ports-head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/x11/libxfce4menu: . files X-SVN-Commit-Revision: 531554 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2020 20:23:57 -0000 Author: cem (src committer) Date: Sun Apr 12 20:23:56 2020 New Revision: 531554 URL: https://svnweb.freebsd.org/changeset/ports/531554 Log: x11/libxfce4menu: Fix leaked keygrabs when layout changes As diagnosed by Jethro Nederhof, xfce-shortcuts-grabber.c attempts to update grabbed key shortcuts when xkeyboard layout changes. Unfortunately, it had no memory of which keycodes it has actually grabbed. Instead, it attempted to ungrab the *new* keycode, which obviously doesn't actually ungrab those codes. This went unnoticed for some time, probably because nothing collided with important keys. Recently, a default PrintScreen shortcut was added to Xfce, which for whatever reason seems to collide with Up in initial layout. When the kbd layout changes, the shortcut ungrabs the *new* Printscreen keycode and then re-grabs the same keycode, leaving the Up keycode grabbed. Fix this by giving xfce-shortcuts-grabber some memory of which keycodes it has grabbed. When it grabs a key, it remembers the keycode it grabbed in the XfceKey object. When it ungrabs a key, it ungrabs the keycodes in the XfceKey object, rather than those for the new keyboard layout. PR: 244290 Reported by: Aryeh Friedman , many others Approved by: madpilot Differential Revision: https://reviews.freebsd.org/D24338 Added: head/x11/libxfce4menu/files/ head/x11/libxfce4menu/files/patch-libxfce4kbd-private_xfce-shortcuts-grabber.c (contents, props changed) Modified: head/x11/libxfce4menu/Makefile Modified: head/x11/libxfce4menu/Makefile ============================================================================== --- head/x11/libxfce4menu/Makefile Sun Apr 12 20:16:31 2020 (r531553) +++ head/x11/libxfce4menu/Makefile Sun Apr 12 20:23:56 2020 (r531554) @@ -3,6 +3,7 @@ PORTNAME= libxfce4menu PORTVERSION= 4.14.1 +PORTREVISION= 1 CATEGORIES= x11 xfce MASTER_SITES= XFCE DISTNAME= libxfce4ui-${DISTVERSIONFULL} Added: head/x11/libxfce4menu/files/patch-libxfce4kbd-private_xfce-shortcuts-grabber.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/x11/libxfce4menu/files/patch-libxfce4kbd-private_xfce-shortcuts-grabber.c Sun Apr 12 20:23:56 2020 (r531554) @@ -0,0 +1,99 @@ +--- libxfce4kbd-private/xfce-shortcuts-grabber.c.orig 2020-04-08 15:05:21 UTC ++++ libxfce4kbd-private/xfce-shortcuts-grabber.c +@@ -74,6 +74,16 @@ 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]; + }; + + +@@ -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, + GrabModeAsync, + GrabModeAsync); +- else ++ else { ++ if (key->keycodes[i] == -1) ++ break; + XUngrabKey (GDK_DISPLAY_XDISPLAY (display), +- keys[i].keycode, ++ key->keycodes[i], + modifiers | mod_masks [k], + root_window); ++ } + } + + gdk_flush (); +@@ -355,9 +376,18 @@ 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; + } + +- g_free (keys); ++ if (grab) { ++ g_free (keys); ++ for (; i < G_N_ELEMENTS (key->keycodes); i++) ++ key->keycodes[i] = -1; ++ } + } + + +@@ -514,6 +544,8 @@ 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; + + gtk_accelerator_parse (shortcut, &key->keyval, &key->modifiers); +