From ac7c3297fa28cf10dfda4402856d681adeef7fba Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sun, 20 Aug 2023 19:20:25 +0200 Subject: [PATCH] Undo commit 0a31225 which killed "caps lock" --- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index ae47da1ec..4d71ae906 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -538,7 +538,8 @@ static void remove_int_vector(Fl_Int_Vector& v, int val) { static int process_wld_key(struct xkb_state *xkb_state, uint32_t key, - uint32_t *p_keycode, xkb_keysym_t *p_sym) { + uint32_t *p_keycode, xkb_keysym_t *p_sym, + struct xkb_keymap *xkb_keymap) { uint32_t keycode = key + 8; xkb_keysym_t sym = xkb_state_key_get_one_sym(xkb_state, keycode); if (sym == 0xfe20) sym = FL_Tab; @@ -547,9 +548,10 @@ static int process_wld_key(struct xkb_state *xkb_state, uint32_t key, // Special processing for number keys == keysym in ['0'-'9'] : // compute sym2 = keysym for same key with opposite shift state int depressed = xkb_state_mod_name_is_active(xkb_state, XKB_MOD_NAME_SHIFT, XKB_STATE_MODS_DEPRESSED) ? 0 : 1; - xkb_state_update_mask(xkb_state, depressed, 0, 0, 0, 0, 0); - xkb_keysym_t sym2 = xkb_state_key_get_one_sym(xkb_state, keycode); - xkb_state_update_mask(xkb_state, 1-depressed, 0, 0, 0, 0, 0); + struct xkb_state *xkb_state2 = xkb_state_new(xkb_keymap); + xkb_state_update_mask(xkb_state2, depressed, 0, 0, 0, 0, 0); + xkb_keysym_t sym2 = xkb_state_key_get_one_sym(xkb_state2, keycode); + xkb_state_unref(xkb_state2); // use that other keysym if it matches a number key if (sym2 >= '0' && sym2 <= '9') { for_key_vector = sym2; @@ -571,7 +573,7 @@ static void wl_keyboard_enter(void *data, struct wl_keyboard *wl_keyboard, for (uint32_t *p = (uint32_t *)(keys)->data; (const char *) p < ((const char *) (keys)->data + (keys)->size); (p)++) { - int for_key_vector = process_wld_key(seat->xkb_state, *p, NULL, NULL); + int for_key_vector = process_wld_key(seat->xkb_state, *p, NULL, NULL, seat->xkb_keymap); //fprintf(stderr, "%d ", for_key_vector); if (search_int_vector(key_vector, for_key_vector) < 0) key_vector.push_back(for_key_vector); } @@ -711,7 +713,7 @@ static void wl_keyboard_key(void *data, struct wl_keyboard *wl_keyboard, static char buf[128]; uint32_t keycode; xkb_keysym_t sym; - int for_key_vector = process_wld_key(seat->xkb_state, key, &keycode, &sym); + int for_key_vector = process_wld_key(seat->xkb_state, key, &keycode, &sym, seat->xkb_keymap); /*xkb_keysym_get_name(sym, buf, sizeof(buf)); const char *action = (state == WL_KEYBOARD_KEY_STATE_PRESSED ? "press" : "release"); fprintf(stderr, "key %s: sym: %-12s(%d) code:%u fl_win=%p, ", action, buf, sym, keycode, Fl_Wayland_Window_Driver::surface_to_window(seat->keyboard_surface));*/