From a8b8eaf06d83451c1023dab3d4e1288e76c26b81 Mon Sep 17 00:00:00 2001 From: Feynman Liang Date: Tue, 21 Jan 2020 16:43:23 -0800 Subject: [PATCH] Support F-key shortcuts Keypresses of F-keys do not get a string returned from `XK.keysym_to_string` and hence (1) do not get added to `pressed` and (2) do not trigger a `replay` even when they are not handled. This breaks the F-key shortcuts which are a big part of Inkscape. This PR introduces a change which `replay`s all the `event`s received whenever our application doesn't handle it (previously it only replayed when it receives an `event` representing a `KeyPress` of **a key which `keysym_to_string` can interpret as a char) --- normal.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/normal.py b/normal.py index f8c9e90..7fadcc9 100644 --- a/normal.py +++ b/normal.py @@ -47,15 +47,18 @@ def normal_mode(self, event, char): if event.type != X.KeyRelease: return + handled = False if len(pressed) > 1: paste_style(self, pressed) - - if len(pressed) == 1: + handled = True + elif len(pressed) == 1: # Get the only element in pressed ev = next(iter(pressed)) handled = handle_single_key(self, ev) - if not handled: - replay(self) + + # replay events to Inkscape if we couldn't handle them + if not handled: + replay(self) events.clear() pressed.clear()