Skip to content

Fix virtual keyboard edge-cases around keyboard grabs - #2204

Open
pgaskin wants to merge 2 commits into
Smithay:masterfrom
pgaskin:virtual-input-fixes
Open

pgaskin wants to merge 2 commits into
Smithay:masterfrom
pgaskin:virtual-input-fixes

Conversation

@pgaskin

@pgaskin pgaskin commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

Mostly edge cases around clients with keyboard grabs also sending virtual keyboard events, e.g. fcitx.

niri-wm/niri#4548 (comment)

Checklist

@pgaskin
pgaskin force-pushed the virtual-input-fixes branch 3 times, most recently from 32c038f to e4701e7 Compare October 10, 2026 05:12
If a virtual keyboard uses the seat's keymap, modifier state is shared
with other input devices, and resetting it to zero may clear modifiers
set by other devices (e.g., numlock, capslock).

This affects, e.g., fcitx, which destroys its virtual keyboard when it
loses focus, which previously would have reset the modifiers, including
ones set through other devices.

The compositor is now responsible for choosing if/how to reconcile the
modifier state on virtual keyboard removal (e.g., by tracking the bits
set by it).
@pgaskin
pgaskin force-pushed the virtual-input-fixes branch from e4701e7 to 8f5bb53 Compare October 10, 2026 05:37
@pgaskin pgaskin changed the title More virtual keyboard fixes for edge cases Fix virtual keyboard edge-cases around keyboard grabs Oct 10, 2026
@pgaskin
pgaskin marked this pull request as ready for review October 10, 2026 05:38
@pgaskin

pgaskin commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

cc @YaLTeR @Drakulix @ids1024

Comment thread src/wayland/virtual_keyboard/mod.rs Outdated
Comment thread src/input/keyboard/mod.rs Outdated
IMEs like fcitx which grab the keyboard may pass through unhandled keys
through a virtual keyboard, which would previously result in a busy
loop. By adding a client/source getter to the virtual keyboard and a
function to forward input events bypassing the grab, this situation can
be avoided.

Assigning a KeyboardSource to each virtual keyboard also fixes fcitx
dropping held modifiers also held by other keyboards on deactivation.
This happens since fcitx echoes every key it receives through its
virtual keyboard, and destroying that keyboard on focus-out causes key
releases to be sent for the keys still down, which used to release the
physical keyboard's keys too. Keys are now released by the last holder
rather than the first. Shortcuts across physical and virtual devices
still work.
@pgaskin
pgaskin force-pushed the virtual-input-fixes branch from 8f5bb53 to 8c09dac Compare October 10, 2026 08:46
@pgaskin
pgaskin requested a review from YaLTeR October 10, 2026 08:46

@YaLTeR YaLTeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ok; someone else please check.

Also insert the usual smithay needs to have stacked grabs etc, but with the current system this will do I guess. I think it matches the behavior pre virtual keyboard rework?

@pgaskin

pgaskin commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

I think it matches the behavior pre virtual keyboard rework

More or less, depending on how the compositor chooses to wire it up.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants