Add wp_pointer_warp_v1 protocol support#4001
Open
zakissimo wants to merge 1 commit into
Open
Conversation
Implements the staging protocol (wayland-protocols 1.45) with a lenient policy: focus + bounds, no implicit-grab requirement. The protocol's "should" rules say "honor it if the surface has pointer focus, *including* when it has an implicit pointer grab" — focus alone is sufficient. Adds two free helpers in src/utils/mod.rs (get_surface_toplevel_coords walks subsurface chains, get_surface_size reads the surface's logical size), an impl PointerWarpHandler for State in src/handlers/mod.rs, and per-window window_visual_rectangle at the four layout layers parallel to the existing active_window_visual_rectangle. Closes niri-wm#3988.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3988.
Adds support for the
wp_pointer_warp_v1staging protocol (wayland-protocols 1.45).Niri's pinned Smithay already includes the server-side handler from
Smithay#1757; this PR is the compositor
wiring + validation policy + the niri-side helpers.
Validation policy
Implements the protocol's three "should" rules with lenient (KWin-style) semantics:
focus + bounds, no
button_count > 0requirement. The protocol says "honor it if thesurface has pointer focus, including when it has an implicit pointer grab" — "including"
reads as "focus is sufficient; implicit grab is one valid case", not as a requirement.
Most legitimate
SetCursorPos-class callers (Wine apps, mouselook recentering,drag-completion, menu navigation) happen outside a button-down, so the strict reading
rejects most of them.
Reference implementations
(Per @YaLTeR's request in #3988.)
Validation in
src/pointer_input.cpp:152-164— focus + bounds, no grab requirement. Lenient.Validation in
meta_wayland_pointer_can_warp— addsbutton_count > 0. Strict.Implementation overview
src/utils/mod.rs:get_surface_toplevel_coords— walks the subsurface chain accumulating offsets viaSubsurfaceCachedState.location. Parallel to Smithay's existingget_popup_toplevel_coords(which handles xdg_popup chains).
get_surface_size— readsRendererSurfaceState::surface_size().impl PointerWarpHandler for Stateinsrc/handlers/mod.rs: serial check viapointer.last_enter(), surface-local bounds check,find_window_and_output→window-rect → output-global four-term composition,
self.move_cursor(target).window_visual_rectangle(id) -> Option<Rectangle<f64, Logical>>at allfour layout layers (floating/scrolling/workspace/monitor), parallel to the existing
active_window_visual_rectangle. Dispatches monitor → workspace → (floating | scrolling).PointerWarpManagerinsrc/niri.rsandsrc/handlers/mod.rs.Testing
Verified end-to-end with Wine MR !10830
— the matching client-side
winewayland.drvpatch.SetCursorPoscalled 12 times by a test program (3 laps × 4 corners of a square).each target.
GetCursorPosreturns the requested position — full roundtrip works.Tested both nested (winit backend) and as a real session.