Skip to content

Prevent bogus repeated keypresses when reloading config#9106

Open
WhyNotHugo wants to merge 1 commit into
swaywm:masterfrom
WhyNotHugo:reload-key-event
Open

Prevent bogus repeated keypresses when reloading config#9106
WhyNotHugo wants to merge 1 commit into
swaywm:masterfrom
WhyNotHugo:reload-key-event

Conversation

@WhyNotHugo
Copy link
Copy Markdown
Contributor

When reloading the configuration, each time that a configuration applies to a keyboard, an additional bogus keypress is sent to clients.

This seems to happen due to handle_keyboard_group_leave updating the pressed keys, but handle_keyboard_group_enter not doing the reverse, so the state of pressed keys is inconsistent.

Extend handle_keyboard_group_enter to mirror
handle_keyboard_group_leave, ensure state is consistent and no spurious key events are sent.

@WhyNotHugo
Copy link
Copy Markdown
Contributor Author

Actually, I copied this from handle_keyboard_group_leave thinking I'd need to invert some booleans or replace some bits, but it ended up being identical. I think I can refactor.

When reloading the configuration, each time that a configuration applies
to a keyboard, an additional bogus keypress is sent to clients.

This seems to happen due to handle_keyboard_group_leave updating the
pressed keys, but handle_keyboard_group_enter not doing the reverse, so
the state of pressed keys is inconsistent.

Extend handle_keyboard_group_enter to mirror
handle_keyboard_group_leave, ensure state is consistent and no spurious
key events are sent.

Fixes: swaywm#8852
@WhyNotHugo
Copy link
Copy Markdown
Contributor Author

I think that's tidier. The diff would have been smaller putting keyboard_group_refocus at the end, but that requires an additional forward declaration and didn't seem worth it.

@emersion
Copy link
Copy Markdown
Member

I can't reproduce the bug. I run Sway with wev -f wl_keyboard & sleep 5; swaymsg reload, then focus the wev window and press some keys. The behavior is the same with or without this patch.

@WhyNotHugo
Copy link
Copy Markdown
Contributor Author

The easiest reproducer is to just type swaymsg reload and press enter. The terminal will receive multiple Enter events.

I have an impression that having more input blocks affects this further, I have:

input type:keyboard {
  xkb_layout us
  xkb_variant intl
  xkb_numlock enable
}

input "13364:528:Keychron_Keychron_K1_Pro"                  xkb_options caps:escape,compose:ralt
input "13364:528:Keychron_Keychron_K1_Pro_Consumer_Control" xkb_options caps:escape,compose:ralt

# …

Can you try an equivalent configuration?

@emersion
Copy link
Copy Markdown
Member

Yeah, no dice. Could you find a way to make these "bogus repeated keypresses" visible in a wev or WAYLAND_DEBUG log?

@WhyNotHugo
Copy link
Copy Markdown
Contributor Author

WhyNotHugo commented Apr 12, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants