Conversation
Fixes a bunch of virtual input bugs, most notable keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
Fixes a bunch of virtual input bugs, most notably keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
d0cc397 to
3c1b1be
Compare
|
Made a few changes:
|
Fixes a bunch of virtual input bugs, most notably keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
3c1b1be to
dea3902
Compare
Fixes a bunch of virtual input bugs, most notably keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
dea3902 to
8d0de20
Compare
Fixes a bunch of virtual input bugs, most notably keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
|
I did some more testing and review of niri-wm/niri#4548 against wlroots. The differences are:
And the wlroots quirks I implemented on purpose here for compatibility:
|
8d0de20 to
cd7f25d
Compare
Fixes a bunch of virtual input bugs, most notably keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
cd7f25d to
0274d0f
Compare
Fixes a bunch of virtual input bugs, most notably keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
|
I need to test this a bit more to ensure the recent tweaks and fixes I did didn't introduce any regressions compared to the build I've been using for the last few months. I'll post another comment here once I do. |
Fixes a bunch of virtual input bugs, most notably keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
0274d0f to
4af361a
Compare
|
I think I'm happy with this now, and it should be ready to fully review/merge (as long as no issues are found with niri-wm/niri#4548). I tested this on niri with various edge cases including:
I've also been using this (along with niri-wm/niri#4554) for multiple hours today with RealVNC on xwlrvnc (also with x11vnc on xwlrvnc), and I've also tested it with wayvnc. |
YaLTeR
left a comment
There was a problem hiding this comment.
This and the niri change look ok to me; someone else please take a look
Fixes a bunch of virtual input bugs, most notably keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
4af361a to
dbb464b
Compare
Fixes a bunch of virtual input bugs, most notably keybind handling and virtual keyboard keymaps. needs Smithay/smithay#2159 closes niri-wm#3309 fixes niri-wm#3394 fixes niri-wm#403 closes niri-wm#2246 fixes niri-wm#3595 fixes niri-wm#3274
…nt zwp_virtual_keyboard_v1 Previously, virtual keyboards would bypass the compositor's event handling, directly writing events to wl_keyboards. This results in compositor bindings, keyboard grabs, shortcut inhibition, and focus not being handled correctly. This commit makes virtual keyboards work the same way as real input devices, similar to how the libei backend works. The device is only created once a keymap is uploaded from the client since all keycodes are interpreted using it. The compositor is now responsible for switching the keymap when handling events from the virtual device. Previously, it was changed silently by smithay behind the compositor's back. Since KeymapChanged and Modifiers don't have a counterpart in InputEvent, they are sent as InputEvent::Special. This also fixes a bug where the client could cause the server to panic by specifying an invalid seat in create_virtual_keyboard. The new XkbContext::set_modifier_mask function allows the modifier state to be set from a raw xkb mask, and is necessary since KeyboardHandle::set_modifier_state is lossy due to serialize_back. It handles leds_state the same way as set_layout. Also see Smithay#1903.
Similar to the virtual_keyboard zwp_virtual_keyboard_v1 implementation. There are some protocol deviations for wlroots compatibility: - Button state is treated as a C-style boolean rather than an enum. - Missing axis_source defaults to Wheel. - Accumulated axis values are cleared on axis_stop. The absolute positions from the client are normalized to 0.0..=1.0 based on the requested extents.
dbb464b to
e78f406
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2159 +/- ##
==========================================
- Coverage 17.39% 17.15% -0.25%
==========================================
Files 187 189 +2
Lines 31162 30888 -274
==========================================
- Hits 5420 5298 -122
+ Misses 25742 25590 -152
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Keyboard
Previously, virtual keyboards would bypass the compositor's event handling, directly writing events to wl_keyboards. This results in compositor bindings, keyboard grabs, shortcut inhibition, and focus not being handled correctly.
This commit makes virtual keyboards work the same way as real input devices, similar to how the libei backend works.
The device is only created once a keymap is uploaded from the client since all keycodes are interpreted using it.
The compositor is now responsible for switching the keymap when handling events from the virtual device. Previously, it was changed silently by smithay behind the compositor's back.
Since KeymapChanged and Modifiers don't have a counterpart in InputEvent, they are sent as InputEvent::Special.
This also fixes a bug where the client could cause the server to panic by specifying an invalid seat in create_virtual_keyboard.
The new XkbContext::set_modifier_mask function allows the modifier state to be set from a raw xkb mask, and is necessary since KeyboardHandle::set_modifier_state is lossy due to serialize_back. It handles leds_state the same way as set_layout.
The keyboard behaviour differs slightly from wlroots in that modifiers are shared. On wlroots, the per-keyboard modifiers are more a result of how input works than an explicit design choice for virtual keyboards. The
zwp_virtual_keyboard_v1protocol only states that it should "emulate the behaviour of a physical keyboard", which is what this does.Also see #1903 and niri-wm/niri#403.
Pointer
The new virtual pointer implementation works similarly.
There are some protocol deviations for wlroots compatibility:
The absolute positions from the client are normalized to 0.0..=1.0 based on the requested extents.
AI usage
I used AI to help figure out a design consistent with the rest of the codebase, and to compare the implementation to wlroots for compatibility. I also used it to generate the Dispatch boilerplate.
The actual logic and all prose (comments, commit messages, this PR) was hand-written by me.
Testing
I previously implemented
wl-uinput-proxyas a workaround, and learned a LOT about wayland and xkb while doing so (this was my first ever wayland-related project, one of my first rust projects, but not my first virtual input or remote-desktop related project).I have been using this (along with RealVNC via
xwlrvnc, and wayvnc) daily since mid-June, and am pretty confident in the correctness and completeness.I have also tested this with wtype and a few one-off scripts.
See niri-wm/niri#4548 for the niri side.
Checklist
closes #2036 (vibe-coded incomplete virtual-pointer impl)
closes #1903 (modifies virtual_keyboard to do a similar keymap-swapping trick, but less cleanly)
closes #1597 (same idea as the set_modifier_mask thing I added)
fixes #1937
see niri-wm/niri#403
see niri-wm/niri#3595