From 48122df00c55d314fe59eb2d5c32dad8455696ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 26 Jul 2021 16:28:04 +0200 Subject: Don't keep menu open after release unless arrow keys are set I am personally partial to this Mac-like behavior, as it avoids introducing a modality to the user interface, which is almost always annoying. If menus are kept open after button release, then the user is left in a different mode than earlier, in which key presses are not sent to the active window, but to the active menu. This is sometimes useful, but more often than not annoying. --- src/key.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/key.c') diff --git a/src/key.c b/src/key.c index 5cedd3d..4f0f146 100644 --- a/src/key.c +++ b/src/key.c @@ -485,6 +485,30 @@ ValidateKeys() } +/** Return true if arrow keys are defined. */ +int +HasArrowKeys() +{ + KeyNode *kp; + static int r = -1; + + if(r != -1) { + return r; + } + + for(kp = bindings; kp; kp = kp->next) { + if((kp->key & 0xFF) == KEY_UP + || (kp->key & 0xFF) == KEY_DOWN + || (kp->key & 0xFF) == KEY_RIGHT + || (kp->key & 0xFF) == KEY_LEFT) { + r = 1; + return 1; + } + } + r = 0; + return 0; +} + /** Return true if the key event matches any switching key or its modifiers. */ int Switching(const XKeyEvent *event) -- cgit v1.2.3