Skip to content

WIP virtual-keyboard fixes - #2977

Draft
ids1024 wants to merge 8 commits into
masterfrom
virtual-keyboard
Draft

ids1024 wants to merge 8 commits into
masterfrom
virtual-keyboard

Conversation

@ids1024

@ids1024 ids1024 commented Oct 21, 2026

Copy link
Copy Markdown
Member

Fixes for some of the issues mentioned in #2959, in addition to popup grabs not working when fcitx5 is running.

I still need to update some things around libei input, the modifier restoration mentioned in that issue, and do some more testing.

Currently requires Smithay/smithay#2219.


  • I have not included any LLM (also known as AI) generated content in this PR, including code, comments, and descriptions.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.
  • I have read and followed all of the above requirements. For more information, see our contributor guide.

@pgaskin

pgaskin commented Oct 24, 2026

Copy link
Copy Markdown

Also see Smithay/smithay#2240.

I'm not currently planning to test this PR locally, but I'll review the code tonight.

@pgaskin pgaskin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a partial review from just skimming the code, I may have missed things.

Still missing (at least):

  • Restoring the original keymap on DeviceRemoved.
  • Other input mechanisms (like libei) still don't restore the keymap correctly.
  • niri-wm/niri#4738
  • libei doesn't get updated modifiers from a vk modifiers request.

Should probably also consider reusing the keymap memfds instead of making a new one each time.

Comment thread src/input/mod.rs
Comment on lines 318 to 321
// Virtual keyboard event generated by IME client
keyboard
.input_forward_bypassing_grab(self, keycode, state, serial, time, true);
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This skips the numlock and xwayland stuff.

Comment thread src/input/mod.rs
Comment on lines 324 to 325
if let Some((action, pattern)) = keyboard
.input(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wrong KeyboardSource, need to use the one from the VK.

Comment on lines 121 to 138
if keyboard.is_grabbed()
&& !(keyboard.has_grab(serial)
|| keyboard.has_grab(grab.previous_serial().unwrap_or(serial)))
&& !keyboard
.with_grab(|_, g| g.is::<InputMethodKeyboardGrab>())
.unwrap_or(false)
{
grab.ungrab(PopupUngrabStrategy::All);
return;
}
Shell::set_focus(
self,
grab.current_grab().as_ref(),
&seat,
Some(serial),
false,
);
keyboard.set_grab(self, PopupKeyboardGrab::new(&grab), serial);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Popup/IME grab replaces each other (last one wins); in niri, the IME grab takes precedence. Up to you.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Without this change on cosmic-comp (unlike niri), popups are immediately dismissed while fcitx5 is running. So one way or another that needs to be prevented.

(Ultimately we probably need some way to have multiple grabs, or use something different than grabs here.)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If only grabs supported passthrough and layering as part of the protocol, we wouldn't be having most of the the edge-cases we've hit so far...

@ids1024
ids1024 force-pushed the virtual-keyboard branch 4 times, most recently from 3685e2d to 1491fef Compare October 28, 2026 02:32
Update for virtual-keyboard `KeymapFile` change from
Smithay/smithay#2219, and libei keysym/UTF-8
change from Smithay/smithay#2233.
Fixes popups (for instance menus in `cosmic-term`) not opening while
`fcitx5` is running.

Smithay may need some mechanism to allow multiple grabs at once in some
way, but for now this should be an improvement.
This should be the correct behavior; if we ever actually have
multi-seat.
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