Refactor/20260529/screenshot drop mss#42
Merged
Conversation
…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>
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.
Description
Impact on Other Code/Features
Pre-submit Checklist
make runorjust runcommand?Additional Notes