From 7d0d374fd8604ec88d1b4200e2a63537b50f0289 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 28 May 2026 13:16:00 -0700 Subject: [PATCH] image-copy: Adjust toplevel capture coordinate for window geometry --- src/shell/focus/target.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/shell/focus/target.rs b/src/shell/focus/target.rs index e0d10662..21d5e0d0 100644 --- a/src/shell/focus/target.rs +++ b/src/shell/focus/target.rs @@ -37,7 +37,10 @@ use smithay::{ Client, DisplayHandle, Resource, backend::ObjectId, protocol::wl_surface::WlSurface, }, utils::{IsAlive, Logical, Point, Serial, Transform}, - wayland::{seat::WaylandFocus, selection::data_device::WlOfferData, session_lock::LockSurface}, + wayland::{ + compositor::with_states, seat::WaylandFocus, selection::data_device::WlOfferData, + session_lock::LockSurface, shell::xdg::SurfaceCachedState, + }, xwayland::{ X11Surface, xwm::{XwmId, XwmOfferData}, @@ -241,10 +244,19 @@ impl PointerFocusTarget { return; } - let cursor_pos = if let Some(_wl_surface) = self.wl_surface() { + let cursor_pos = if let Some(wl_surface) = self.wl_surface() { + let geometry_loc = with_states(&wl_surface, |states| { + states + .cached_state + .get::() + .current() + .geometry + .map(|g| g.loc.to_f64()) + }) + .unwrap_or_default(); + Some( - event - .location + (event.location - geometry_loc) .to_buffer(1.0, Transform::Normal, &toplevel.geometry().size.to_f64()) .to_i32_round(), )