Skip to content

use set_keymap and get_keymap to proper handle keymap#1903

Open
Bot-wxt1221 wants to merge 2 commits intoSmithay:masterfrom
Bot-wxt1221:virtual_keyboard
Open

use set_keymap and get_keymap to proper handle keymap#1903
Bot-wxt1221 wants to merge 2 commits intoSmithay:masterfrom
Bot-wxt1221:virtual_keyboard

Conversation

@Bot-wxt1221
Copy link
Copy Markdown
Contributor

@Bot-wxt1221 Bot-wxt1221 commented Jan 11, 2026

WM need keymap to process input. So change_keymap is neccessary.

Follow by #1803.

Fix #1926

Applied #1907 (I changed it a little bit as I was overflowded by the complie error. I wonder if it's the best practice.)

Problem mainly on niri-wm/niri#2314

Current impl is stupid. The correct way should be simulate a virtual keyboard handler like libinput backend.

But I have no interest in it. So let's just make it possible to solve all issue.

I believe it will solve all the problem.

By the way, I'm not familiar with rust so maybe a rust expert should review my code.

UPD: modifiers is much more natural and effective in my opinion.

@Bot-wxt1221 Bot-wxt1221 force-pushed the virtual_keyboard branch 2 times, most recently from 3d6c503 to a9a6e0a Compare January 11, 2026 10:22
@Bot-wxt1221
Copy link
Copy Markdown
Contributor Author

@PolyMeilex

@Bot-wxt1221 Bot-wxt1221 changed the title fix: use change_keymap to allow WM handle keycode with the correct keymap fix: allow ignore keymap reset to fix virtual_keyboard Jan 12, 2026
@Bot-wxt1221 Bot-wxt1221 force-pushed the virtual_keyboard branch 5 times, most recently from 67f4c7e to b114ff2 Compare January 12, 2026 15:45
@Bot-wxt1221 Bot-wxt1221 marked this pull request as draft January 12, 2026 15:47
@Bot-wxt1221 Bot-wxt1221 changed the title fix: allow ignore keymap reset to fix virtual_keyboard fix: use change_keymap to edit virtual_keyboard's keymap Jan 17, 2026
@Bot-wxt1221 Bot-wxt1221 marked this pull request as ready for review January 17, 2026 16:00
@Bot-wxt1221
Copy link
Copy Markdown
Contributor Author

@PolyMeilex

@YaLTeR
Copy link
Copy Markdown
Contributor

YaLTeR commented Jan 18, 2026

Seems this PR is necessary to unbreak wtype that broke after the last virtual keyboard PR.

@Bot-wxt1221 with this PR, wtype works for clients, but for compositor binds it still uses the wrong keymap. I'm actually not sure what's happening. In winit backend, wtype -M alt -k p -m alt results in

2026-01-18T05:53:17.396689Z DEBUG niri::input: on_keyboard modified=XK_Escape pressed=true
2026-01-18T05:53:17.400344Z DEBUG niri::input: on_keyboard modified=XK_Escape pressed=false

inside the self.niri.seat.get_keyboard().unwrap().input(... closure (and no r somehow?) and ^[r produced in the terminal.

If I do wtype -M alt then something really weird happens where niri still sees all the keys as normal, and compositor binds work, but keys stop doing input to any client.

@Bot-wxt1221 Bot-wxt1221 force-pushed the virtual_keyboard branch 2 times, most recently from 721e9ca to 13e102c Compare January 24, 2026 16:22
@Bot-wxt1221 Bot-wxt1221 changed the title fix: use change_keymap to edit virtual_keyboard's keymap use set_keymap and get_keymap to proper handle keymap Jan 24, 2026
@Bot-wxt1221 Bot-wxt1221 force-pushed the virtual_keyboard branch 4 times, most recently from 43ef44c to e18b18b Compare January 25, 2026 02:38
@Bot-wxt1221
Copy link
Copy Markdown
Contributor Author

@YaLTeR Fixed.

Copy link
Copy Markdown
Contributor

@YaLTeR YaLTeR left a comment

Choose a reason for hiding this comment

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

  • wvkbd no longer gets key stuck
  • but wtype is now unable to invoke compositor actions with modifiers. Here's WAYLAND_DEBUG for wtype -M alt -k r -m alt:
[1616354.165] {Default Queue}  -> zwp_virtual_keyboard_manager_v1#3.create_virtual_keyboard(wl_seat#4, new id zwp_virtual_keyboard_v1#5)
[1616354.231] {Default Queue}  -> zwp_virtual_keyboard_v1#5.keymap(1, fd 5, 229)
[1616354.238] {Default Queue}  -> wl_display#1.sync(new id wl_callback#6)
[1616359.209] {Display Queue} wl_display#1.delete_id(6)
[1616359.219] {Default Queue} wl_callback#6.done(0)
[1616359.242] {Default Queue}  -> zwp_virtual_keyboard_v1#5.modifiers(8, 0, 0, 0)
[1616359.252] {Default Queue}  -> wl_display#1.sync(new id wl_callback#6)
[1616365.517] {Display Queue} wl_display#1.delete_id(6)
[1616365.527] {Default Queue} wl_callback#6.done(0)
[1616365.533] {Default Queue}  -> zwp_virtual_keyboard_v1#5.key(0, 1, 1)
[1616365.538] {Default Queue}  -> wl_display#1.sync(new id wl_callback#6)
[1616369.365] {Display Queue} wl_display#1.delete_id(6)
[1616369.375] {Default Queue} wl_callback#6.done(0)
[1616371.443] {Default Queue}  -> zwp_virtual_keyboard_v1#5.key(0, 1, 0)
[1616371.453] {Default Queue}  -> wl_display#1.sync(new id wl_callback#6)
[1616375.324] {Display Queue} wl_display#1.delete_id(6)
[1616375.335] {Default Queue} wl_callback#6.done(0)
[1616377.618] {Default Queue}  -> zwp_virtual_keyboard_v1#5.modifiers(0, 0, 0, 0)
[1616377.633] {Default Queue}  -> wl_display#1.sync(new id wl_callback#6)
[1616381.680] {Display Queue} wl_display#1.delete_id(6)
[1616381.701] {Default Queue} wl_callback#6.done(0)
[1616381.709] {Default Queue}  -> zwp_virtual_keyboard_v1#5.destroy()

This just types "r" instead of resizing the window with Alt-r

@Bot-wxt1221
Copy link
Copy Markdown
Contributor Author

@YaLTeR Fixed again.

@Bot-wxt1221 Bot-wxt1221 requested a review from YaLTeR February 2, 2026 13:46
@Bot-wxt1221 Bot-wxt1221 force-pushed the virtual_keyboard branch 2 times, most recently from f9db7f4 to c63b655 Compare February 2, 2026 14:35
@YaLTeR
Copy link
Copy Markdown
Contributor

YaLTeR commented Feb 2, 2026

On the latest push, I checked wtype and wvkbd and I couldn't break it.

@Bot-wxt1221
Copy link
Copy Markdown
Contributor Author

@PolyMeilex could you review this?

@Bot-wxt1221
Copy link
Copy Markdown
Contributor Author

Are there any work to do?

@Bot-wxt1221
Copy link
Copy Markdown
Contributor Author

So 2 solutions here. 1. Revert previous one(It is just ok) and focus on rewriting(I would help with dorotac) 2. Finding a balance to fix most of problems.

This allows setting a pre-compiled keymap while ensuring the keymap
was created under the same keyboard handle, and more importantly, the
same xkbcommon context within the same thread.
@PolyMeilex
Copy link
Copy Markdown
Member

I'll be totally honest, I have no idea what's going on in this code. It was foolish of me to assume that I do, during #1803 review 😄

It all seems to be disproportionately complex for what it does, which might suggest a deeper design flaw unrelated to the bug at hand.

So I would be leaning towards just reverting the first PR (catacomb compositor already reverts it). Not because I don't trust your judgment, but because I don't trust mine, and I would rather not dig us into a deeper hole 😄

Sorry that I don't have time currently to properly research this stuff.

@Bot-wxt1221 Bot-wxt1221 changed the title use set_keymap and get_keymap to proper handle keymap revert #1803 Feb 18, 2026
@Bot-wxt1221 Bot-wxt1221 changed the title revert #1803 use set_keymap and get_keymap to proper handle keymap Feb 18, 2026
@Bot-wxt1221
Copy link
Copy Markdown
Contributor Author

Bot-wxt1221 commented Feb 18, 2026

@PolyMeilex But I have to say that no compositer impl this properly. And you can verify it solve all exist problem. Yet we're in a big hole, but at least It seems that we can stop at here.

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.

Modifiers broken for virtual keyboard protocol

6 participants