Skip to content

Refactor/20260529/screenshot drop mss#42

Merged
Geson-anko merged 7 commits into
mainfrom
refactor/20260529/screenshot-drop-mss
May 28, 2026
Merged

Refactor/20260529/screenshot drop mss#42
Geson-anko merged 7 commits into
mainfrom
refactor/20260529/screenshot-drop-mss

Conversation

@Geson-anko

Copy link
Copy Markdown
Member

Description

Impact on Other Code/Features

  • None
  • Yes

Pre-submit Checklist

  • Is the title clear and descriptive, and does the description concisely explain the PR?
  • Have you confirmed your PR handles one specific change rather than bundling different changes together?
  • Have you listed all changes introduced in this PR?
  • Have you tested the PR locally using the make run or just run command?

Additional Notes

Geson-anko and others added 7 commits May 29, 2026 07:59
…ead of mss

take_screenshot() now grabs window content through vrcpilot.capture.Capture
(WGC / X11 Composite) rather than mss screen-region grab. Capture is
occlusion-tolerant and focus-free, so the focus() call and settle_seconds
argument are removed; the new signature is take_screenshot(*, pid=None).

width/height are now sourced from the captured image so
image.shape == (height, width, 3) holds unconditionally; x/y remain from
get_vrchat_window_rect (informational). pid is passed straight through to
get_vrchat_window_rect then Capture, deferring not-running/multi-instance
semantics to the rect helper and dodging the VRChatMultipleInstancesError
subclass trap.

monitor_index can no longer be derived from window-content capture: it is
kept as a public field/kwarg/YAML key (value always 0) and a
Screenshot.__post_init__ emits a DeprecationWarning announcing removal in
0.6.0 when constructed non-zero. _resolve_monitor_index is deleted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
LinuxMouse sized the absolute-move coordinate space from mss.MSS().monitors[0].
That is now read from the X11 root screen via open_x11_display() +
screen().width_in_pixels/height_in_pixels (python-xlib is already a Linux dep).
Construction raises RuntimeError (was Xlib.error.XError surfaced from mss) when
no display is reachable; the display is closed in a finally per
open_x11_display's caller-owns-close contract.

Test docstrings/skip reasons updated to describe the python-xlib probe and the
RuntimeError; skip predicates and CLI argparse/no-VRChat tests unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vrcpilot no longer imports mss anywhere, so remove it from
[project.dependencies]. The e2e whole-desktop artifact grab
(save_monitor_screenshot) moves from mss to pyscreenshot, which auto-selects
a Wayland-capable backend (grim) where mss could not run; pyscreenshot is a
dev-only dependency since it is used solely by e2e helper scripts. mss remains
in the lock only as pyscreenshot's transitive backend, never imported by
vrcpilot. uv.lock regenerated.

pyscreenshot.grab() is annotated `-> 'Image'` (the PIL module, not the class),
so the result is cast to PIL.Image.Image to keep e2e under pyright.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the hand-rolled open_x11_display() + try/finally close in
LinuxMouse.__init__ with the x11_display() context manager that vrcpilot.linux
ships for exactly this block-scoped use (its open_x11_display docstring
recommends it to avoid leaking on early returns). Behavior is identical:
RuntimeError when no display is reachable, root-screen dimensions otherwise,
connection closed on block exit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
LinuxMouse.__init__ now uses the x11_display() context manager, so the
no-display construction test patches vrcpilot.controls.mouse.linux.x11_display
(yielding None via a contextlib.contextmanager) instead of the removed
open_x11_display reference. Docstring/comment references updated to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…creenshot

Update the Python API and CLI docs (EN + JA): take_screenshot drops
settle_seconds and is now focus-free window-content capture via Capture;
Returns/Raises rewritten (no focus-refused / mss error). Screenshot.monitor_index
is documented as deprecated, always 0, removed in 0.6.0 (the YAML key is still
emitted by screenshot/ocr/detect). Also refresh now-stale mss wording in
comments (test_windows.py grab-region notes, e2e/screenshot.py, cli
test_screenshot.py, linux.py get_window_rect docstring) to describe WGC / X11
Composite window capture.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
spec-planner records the mss-removal spec decisions (monitor_index
deprecation mechanism, subclass-trap avoidance, image-derived dimensions);
code-quality-reviewer records the screenshot.py pinned-contract no-touch
rationale.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Geson-anko Geson-anko merged commit 79c05f8 into main May 28, 2026
9 checks passed
@Geson-anko Geson-anko deleted the refactor/20260529/screenshot-drop-mss branch May 28, 2026 23:43
@Geson-anko Geson-anko restored the refactor/20260529/screenshot-drop-mss branch May 29, 2026 00:04
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