Skip to content

feat: relative coordinates for background click and scroll - #506

Merged
avifenesh merged 1 commit into
mainfrom
feat/background-relative
Nov 24, 2026
Merged

avifenesh merged 1 commit into
mainfrom
feat/background-relative

Conversation

@avifenesh

@avifenesh avifenesh commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #480.

A client that works in window coordinates had to convert them to screen capture pixels before it could send a background click. The codex-desktop-linux bridge, whose app.click() sends window-relative points with relative: true, was patched for that on #480. The server already knows the target window's bounds and the capture scale, so it now does the conversion.

What changed:

  • click and scroll with delivery: "background" take relative: true. x and y are measured from the window screenshot's crop origin, as in a focused relative click, and are mapped with the same window coordinate map (window_coordinate_map, split out of focused_window_coordinate_map) to capture pixels.
  • The mapped point then goes through the checks every background point gets: on the GNOME and KWin pen and touch routes, on the target window and not covered; on the agent seat, the seat's own window check.
  • A relative background call without a window target, or with a point outside the window crop, fails with nothing sent. It does not fall back to focused input.
  • Element targets (element_index, a semantic selector) and coordinate_space: "atspi" still have no background route. A plain left click on an element already goes through its AT-SPI action without the pointer, and mapping element bounds to the pen adds a second path with its own scale rules. Drag stays without relative coordinates.
  • Relative click and scroll mapping share one helper, window_relative_point. Scroll now uses checked addition, as click did.

Docs: click and scroll tool descriptions, the delivery field docs, README (Background keyboard delivery, pointer part), SKILL.md copies, CHANGELOG [Unreleased], and the regenerated Pi tool catalog.

Tests: five unit tests in src/server.rs cover the request shape the bridge sends (relative, window target, background), the refusal without a target, elements and AT-SPI points, mapping equal to a focused relative click, and points outside the crop. Before this change a relative background point was refused.

Gates run on Linux (dev box): cargo fmt --check, cargo check, clippy -D warnings, cargo test --locked --no-fail-fast, cargo doc -D warnings, mcp_safety_check.py, check_plugins.sh, agnix (0 errors), zod-check, Pi build:check, typecheck and tests, generate_pi_tool_catalog.py --check. Not checked on a live GNOME or KWin desktop.


Note

Medium Risk
Touches live desktop input routing (background pointer/pen) and coordinate mapping; behavior is gated by delivery/relative flags with new refusal paths and tests, but wrong mapping could mis-click unfocused windows.

Overview
Adds relative: true for background click and scroll (delivery: "background"): x/y can be window screenshot crop coordinates, which the server maps to capture pixels via window_coordinate_map (same path as focused relative clicks), then runs the usual background checks (agent seat, GNOME/KWin pen/touch).

Behavior: Relative background calls require a window target; missing target or out-of-crop points fail with nothing sent (no focus fallback). Element targets and coordinate_space: "atspi" still have no background route; drag stays capture-only.

Implementation: Shared helpers background_point, window_relative_point, and PenRequest::relative_to_capture; refactored background_pointer / background_pen plumbing and five unit tests in server.rs.

Docs/catalog: CHANGELOG [Unreleased], README, SKILL copies, MCP tool descriptions, regenerated Pi generated-tools.ts hashes.

Reviewed by Cursor Bugbot for commit 12dfe85. Configure here.

@cursor

cursor Bot commented Nov 24, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 1b5e8a08-9d93-406c-b017-03578e5e3f08)

@revuto-review revuto-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is an auto review done by revuto.


Revuto completed the review and found no evidence-backed concerns.

Background click and scroll now take relative=true: x and y from the
target window's screenshot crop are mapped through the window's bounds
and the capture scale, then checked like any background point.

Follow-up to #480.
@avifenesh
avifenesh force-pushed the feat/background-relative branch from 71d5b7b to 12dfe85 Compare November 24, 2026 14:02

@revuto-review revuto-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is an auto review done by revuto.


Revuto completed the review and found no evidence-backed concerns.

@avifenesh
avifenesh merged commit 12dfe85 into main Nov 24, 2026
26 checks passed
@avifenesh
avifenesh deleted the feat/background-relative branch November 24, 2026 14:06
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