From b3a7e95c69be82d7950dc87747a402562c41d992 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Sat, 9 Aug 2025 21:19:08 +0200 Subject: [PATCH] added SHIFT_SPACE_IS_TAB as compile time parameter for the mobile layout, we want shift+space to produce tab , which needed to be implemented in the main code. For the desktop layout, we don't want this though, a config parameter now handles this at compile time. Ref: https://github.com/jjsullivan5196/wvkbd/pull/103 --- config.mobintl.h | 1 + keyboard.c | 4 ++-- keyboard.h | 1 + main.c | 5 +++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config.mobintl.h b/config.mobintl.h index 74dd9ce..79d8854 100644 --- a/config.mobintl.h +++ b/config.mobintl.h @@ -3,6 +3,7 @@ #define DEFAULT_FONT "Sans 14" #define DEFAULT_ROUNDING 5 +#define SHIFT_SPACE_IS_TAB static const int transparency = 255; struct clr_scheme schemes[] = { diff --git a/keyboard.c b/keyboard.c index d158403..8aab410 100644 --- a/keyboard.c +++ b/keyboard.c @@ -301,7 +301,7 @@ kbd_unpress_key(struct kbd *kb, uint32_t time) zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key WL_KEYBOARD_KEY_STATE_RELEASED); } else { - if ((kb->last_press->code == KEY_SPACE) && (unlatch_shift)) { + if ((kb->shift_space_is_tab) && (kb->last_press->code == KEY_SPACE) && (unlatch_shift)) { // shift + space is tab zwp_virtual_keyboard_v1_key(kb->vkbd, time, KEY_TAB, WL_KEYBOARD_KEY_STATE_RELEASED); @@ -404,7 +404,7 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) } kb->last_swipe = kb->last_press = k; kbd_draw_key(kb, k, Press); - if ((k->code == KEY_SPACE) && (kb->mods & Shift)) { + if ((kb->shift_space_is_tab) && (k->code == KEY_SPACE) && (kb->mods & Shift)) { // shift space is tab zwp_virtual_keyboard_v1_modifiers(kb->vkbd, 0, 0, 0, 0); zwp_virtual_keyboard_v1_key(kb->vkbd, time, KEY_TAB, diff --git a/keyboard.h b/keyboard.h index 14d2d12..877805e 100644 --- a/keyboard.h +++ b/keyboard.h @@ -101,6 +101,7 @@ struct kbd { double scale; double preferred_scale, preferred_fractional_scale; bool landscape; + bool shift_space_is_tab; uint8_t mods; uint8_t compose; struct key *last_press; diff --git a/main.c b/main.c index c1c8f01..4ab48c3 100644 --- a/main.c +++ b/main.c @@ -1058,6 +1058,11 @@ main(int argc, char **argv) if (keyboard.vkbd == NULL) { die("failed to init virtual keyboard_manager\n"); } + #ifdef SHIFT_SPACE_IS_TAB + keyboard.shift_space_is_tab = true; + #else + keyboard.shift_space_is_tab = false; + #endif kbd_init(&keyboard, (struct layout *)&layouts, layer_names_list, landscape_layer_names_list);