fix(cua-driver/linux): get_desktop_state screen size on pure Wayland#2047
Conversation
get_desktop_state's full-display capture already routes through the wlroots zwlr_screencopy cascade on Wayland, but the line right after it queried the screen size via x11_screen_size() unconditionally — which opens an X11 connection and fails with "$DISPLAY variable not set" on a pure-Wayland session (no Xwayland), aborting the whole tool even though the screenshot already succeeded. Surfaced on the Sway test VM during the overnight harness sweep. On Wayland the screencopy full-display buffer IS the whole output at native physical pixels, so reuse the already-decoded PNG dimensions for screen size; fall back to x11_screen_size() only off Wayland — X11/XWayland path unchanged. (Note: get_screen_size has the same latent unconditional x11_screen_size() call; left for a follow-up since it has no prior capture to borrow dims from.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesWayland desktop size handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Linux visual regression artifactsMatrix jobs now run independently. Download visual artifacts from this workflow run.
|
Problem
On a pure-Wayland session (Sway, no Xwayland),
get_desktop_statefails withCapture error: … $DISPLAY variable not set …— surfaced on the Sway test VM during the overnight harness sweep.Root cause
The full-display capture already routes correctly through the wlroots
zwlr_screencopycascade on Wayland. The bug is the line right after it:x11_screen_size()opens an X11 connection to read the root-window geometry. With noDISPLAY, x11rb returns "$DISPLAY variable not set" and the?aborts the whole tool — even though the screenshot already succeeded via screencopy.Fix
On Wayland the screencopy full-display buffer is the entire output at native physical pixels, so reuse the already-decoded PNG dimensions for the screen size; fall back to
x11_screen_size()only off Wayland. X11 / XWayland path unchanged (gated bycrate::wayland::is_wayland(), which requiresCUA_DRIVER_RS_ENABLE_WAYLAND=1+WAYLAND_DISPLAYset +DISPLAYunset).One-line behavioral change + a comment; no new deps, no schema change.
Verification
get_desktop_statewithCUA_DRIVER_RS_ENABLE_WAYLAND=1(DISPLAY unset) returns a PNG + non-zeroscreen_width/heightinstead of the$DISPLAYerror. (Verifying now.)DISPLAY=:0) still reports X11 root geometry unchanged.Follow-up (not in this PR)
get_screen_sizehas the same unconditionalx11_screen_size()call and will fail identically on pure Wayland — but it has no prior capture to borrow dims from, so it needs a real Wayland output-dimensions source. Tracked for a separate change.🤖 Generated with Claude Code
Summary by CodeRabbit