lbonn / rofi

Rofi: A window switcher, run dialog and dmenu replacement - fork with wayland support
Other
876 stars 35 forks source link

[BUG] rofi-wayland doesn't follow changed keyboard layout #92

Closed Nemo157 closed 9 months ago

Nemo157 commented 9 months ago

Rofi version (rofi -v or git commit in case of build issue)

Version: 1.7.5+wayland2

Configuration

https://gist.github.com/Nemo157/d3a398d548d5e11e868287b5abdb7135

Theme

https://gist.github.com/Nemo157/41e5fcec566c5f8a2630cde5c80e9e4d

Timing report

No response

Launch command

rofi -show drun

Step to reproduce

input {
  kb_layout = us,us
  kb_variant = ,dvp
  kb_options = caps:escape,compose:ralt,grp:win_space_toggle
}

Expected behavior

Rofi should use the current keyboard layout when it changes

Actual behavior

All input is as if the first keyboard layout remained selected

Additional information

Tested on NixOS 23.05 with Hyprland 0.25.0+date=2023-05-03_f27873a

Testing upstream rofi under xwayland it does correctly switch layouts.

Testing 9d11a2b4a9095b3f0a092155f749900f7eb8e047 it similarly doesn't work there.

Using wayland display server protocol

I've checked if the issue exists in the latest stable release

Nemo157 commented 9 months ago

I added logging to wayland_keyboard_keymap and I can see that it's getting a keymap with multiple groups defined. wayland_keyboard_modifiers seems to just be discarding the group parameter so it never detects which group it should use.

Nemo157 commented 9 months ago

Passing the group into all three layouts seemed to work (xkb_layout_index_t docs mention that layouts == groups):

diff --git source/wayland/display.c source/wayland/display.c
index 6b75213f..749982a5 100644
--- source/wayland/display.c
+++ source/wayland/display.c
@@ -459,7 +459,7 @@ static void wayland_keyboard_modifiers(void *data, struct wl_keyboard *keyboard,
                                        uint32_t mods_locked, uint32_t group) {
   wayland_seat *self = data;
   nk_bindings_seat_update_mask(wayland->bindings_seat, NULL, mods_depressed,
-                               mods_latched, mods_locked, 0, 0, 0);
+                               mods_latched, mods_locked, group, group, group);

   RofiViewState *state = rofi_view_get_active();
   if (state != NULL) {

I'm not sure if there's a reason to distinguish between the three separate parameters though.

lbonn commented 9 months ago

@Nemo157 This looks like a duplicate of #56, thanks a lot for tracking it down!

Would you like to open a PR?

Nemo157 commented 9 months ago

Not sure how I missed that issue when I was searching earlier.