Skip to content

image-copy-capture: tell cursor capture sessions where the pointer is - #246

Open
sachahjkl wants to merge 1 commit into
bea4dev:mainfrom
sachahjkl:feat/cursor-capture-session
Open

sachahjkl wants to merge 1 commit into
bea4dev:mainfrom
sachahjkl:feat/cursor-capture-session

Conversation

@sachahjkl

Copy link
Copy Markdown
Contributor

Problem

Wayland tells a client nothing about the pointer outside its own surfaces. The standard way for a screenshot tool to find the screen (or the window) under the pointer is an ext-image-copy-capture-v1 pointer cursor session on an output or a toplevel: the session sends enter, position and leave. ShojiWM created no cursor session at all. smithay keeps a cursor session only when the handler returns buffer constraints for it, and the default returns none.

Fix

  • handlers/mod.rs:
    • cursor_capture_constraints returns constraints for a source that resolves to a size: a square of the cursor theme size times the source's scale, Argb8888 shm. The cursor image itself is not rendered yet: cursor frames still fail through the trait's default cursor_frame.
    • new_cursor_session keeps the session and sends the current position at once. cursor_session_destroyed drops it.
    • ShojiWM::update_cursor_capture_sessions sets each session's cursor position: the pointer's logical offset in the output or window geometry, scaled to the source's buffer size, or None when the pointer is not on the source. Captures are rendered upright, so no transform is applied. smithay sends events only for changes.
    • Helpers source_window, source_scale and cursor_position_on_source.
  • state.rs: new field image_copy_cursor_sessions. The update runs after warp_cursor_to_output_center, and after an output configuration is applied (an output that moves or changes scale moves the pointer on it).
  • input.rs: the update runs after pointer motion (request_redraw_for_pointer_motion) and in forward_locked_pointer_motion.

Tests

New integration test src/shojiwm_rs/tests/cursor_capture_session.rs, cursor_session_follows_the_pointer_on_its_output: with the pointer off the only output, the session sends nothing; moving onto it gives enter and position(100, 200); a second motion gives only position; moving off gives leave.

cargo test --workspace passes, except two tests that also fail on upstream main in our environment: evaluator::tests::embedded_runtime_ipc_does_not_leak_fds_across_reloads and input_method_keyboard_grab_gets_the_keymap_of_the_keys_it_is_sent.

This change has been running daily in the author's own session (a Windows-7-like desktop on ShojiWM).

ext-image-copy-capture-v1 lets a client ask, with a pointer cursor
session on an output or a toplevel, whether and where the pointer is on
it: the standard way for a screenshot tool to take the screen under the
pointer, since Wayland says nothing of the pointer outside a client's
own surfaces. ShojiWM made no cursor session at all. Keep them, give
each the pointer's place in its source's buffer after every motion and
output change, and announce cursor buffer constraints so smithay keeps
the sessions (cursor frames themselves still fail).

This branch has not been deployed

No deployments
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.

1 participant