Skip to content

Implement zwlr_virtual_pointer_v1 and zwp_virtual_keyboard_v1 for better pointer and keyboard support on monitor overlays#539

Open
SparkyTD wants to merge 3 commits into
wayvr-org:mainfrom
SparkyTD:wl_virtual_hid
Open

Implement zwlr_virtual_pointer_v1 and zwp_virtual_keyboard_v1 for better pointer and keyboard support on monitor overlays#539
SparkyTD wants to merge 3 commits into
wayvr-org:mainfrom
SparkyTD:wl_virtual_hid

Conversation

@SparkyTD

Copy link
Copy Markdown

This PR implements the wayland protocols zwlr_virtual_pointer_v1 and zwp_virtual_keyboard_v1 as an optional replacement for the current UInput method for better overlay input support on Wayland. On desktops that do not implement these protocols, the code still falls back to the existing UInput logic.

This solves an issue caused by the input event handling logic on certain desktops (e.g. Hyprland), where pointer motion events aren't being correctly forwarded to the focused application, which results in pointer "jumping" on clicks, accidental drag selections, and overall poor usability

The protocols implemented by this PR are made specifically for this use, and they provide a more stable, Wayland-firendly and idiomatic way of controlling the pointer and a mouse.

Comment on lines +21 to +24
let (provider, toast) = hid::provider::wl_virtual::initialize_wl_virtual()
.or_else(|_| hid::provider::uinput::initialize_uinput())
.map(|provider| (provider, None))
.unwrap_or_else(|toast| (Box::new(DummyProvider {}), Some(toast)));

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.

we only know how it behaves on hyprland so it should not be the default method

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

On any environment that doesn't support those protocols, it will silently fall back to the old uinput method. So far I've tested it on KDE and Ubuntu, and there are no unexpected crashes, the code behaves as it did before.

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