From dd02daedca0516d1d57f27f2916e21aa4cb58b87 Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 3 May 2026 03:03:23 +0900 Subject: [PATCH 1/2] src/input/keyboard.c: use switch instead of if --- src/input/keyboard.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/input/keyboard.c b/src/input/keyboard.c index 98be5d11..ff38fb0d 100644 --- a/src/input/keyboard.c +++ b/src/input/keyboard.c @@ -467,19 +467,18 @@ handle_cycle_view_key(struct keyinfo *keyinfo) /* cycle to next */ for (int i = 0; i < keyinfo->translated.nr_syms; i++) { - if (keyinfo->translated.syms[i] == XKB_KEY_Escape) { + switch (keyinfo->translated.syms[i]) { + case XKB_KEY_Escape: /* Esc deactivates window switcher */ cycle_finish(/*switch_focus*/ false); return true; - } - if (keyinfo->translated.syms[i] == XKB_KEY_Up - || keyinfo->translated.syms[i] == XKB_KEY_Left) { + case XKB_KEY_Up: + case XKB_KEY_Left: /* Up/Left cycles the window backward */ cycle_step(LAB_CYCLE_DIR_BACKWARD); return true; - } - if (keyinfo->translated.syms[i] == XKB_KEY_Down - || keyinfo->translated.syms[i] == XKB_KEY_Right) { + case XKB_KEY_Down: + case XKB_KEY_Right: /* Down/Right cycles the window forward */ cycle_step(LAB_CYCLE_DIR_FORWARD); return true; From 26d40241c0028123da13f109ec28bb79a9e14563 Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 3 May 2026 03:05:20 +0900 Subject: [PATCH 2/2] cycle: accept Enter to finish window switcher Accept Enter key to finish window switcher and focus the selected window. This follows Openbox's behavior. This is useful when the user binds NextWindow/PreviousWindow to a key without modifiers. --- src/input/keyboard.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/input/keyboard.c b/src/input/keyboard.c index ff38fb0d..680cf6e2 100644 --- a/src/input/keyboard.c +++ b/src/input/keyboard.c @@ -472,6 +472,11 @@ handle_cycle_view_key(struct keyinfo *keyinfo) /* Esc deactivates window switcher */ cycle_finish(/*switch_focus*/ false); return true; + case XKB_KEY_Return: + case XKB_KEY_KP_Enter: + /* Enter accepts the currently selected window */ + cycle_finish(/*switch_focus*/ true); + return true; case XKB_KEY_Up: case XKB_KEY_Left: /* Up/Left cycles the window backward */