Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2952,8 +2952,20 @@ impl Tool for GetDesktopStateTool {
// so screen-absolute pixels land exactly.
let png = crate::capture::screenshot_display_bytes()?;
let (shot_w, shot_h) = crate::capture::png_dimensions_pub(&png)?;
// True screen size from the X11 root window.
let (screen_w, screen_h) = x11_screen_size()?;
// True screen size. On a pure-Wayland session (native backend
// opted in, no X11 DISPLAY) the capture above came from the
// wlroots `zwlr_screencopy` cascade, whose full-display buffer is
// the whole output at native (physical) pixels — so the PNG
// dimensions ARE the true screen size. Querying the X11 root
// window here would fail with "$DISPLAY variable not set" and
// abort the tool even though the screenshot already succeeded.
// Only fall back to the X11 root-window geometry off Wayland, so
// the X11 / XWayland path is unchanged. See #2017 / Sway testing.
let (screen_w, screen_h) = if crate::wayland::is_wayland() {
(shot_w, shot_h)
} else {
x11_screen_size()?
};
// Optional: write PNG to disk instead of returning base64.
let written = if let Some(path) = out_file.as_deref() {
std::fs::write(path, &png)?;
Expand Down
Loading