image-copy: Adjust cursor position for subsurface offset

The `themed_window` example of `smithay-client-toolkit` is a good test
for this.
This commit is contained in:
Ian Douglas Scott 2026-06-08 15:17:50 -07:00 committed by Ian Douglas Scott
parent 84d2a9d297
commit 651877e622

View file

@ -245,7 +245,14 @@ impl PointerFocusTarget {
} }
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| { let surface_offset = toplevel
.surface_offset(&wl_surface)
.unwrap_or(Point::from((0, 0)))
.to_f64();
let geometry_loc = toplevel
.wl_surface()
.and_then(|s| {
with_states(&s, |states| {
states states
.cached_state .cached_state
.get::<SurfaceCachedState>() .get::<SurfaceCachedState>()
@ -253,10 +260,10 @@ impl PointerFocusTarget {
.geometry .geometry
.map(|g| g.loc.to_f64()) .map(|g| g.loc.to_f64())
}) })
})
.unwrap_or_default(); .unwrap_or_default();
Some( Some(
(event.location - geometry_loc) (event.location - geometry_loc + surface_offset)
.to_buffer(1.0, Transform::Normal, &toplevel.geometry().size.to_f64()) .to_buffer(1.0, Transform::Normal, &toplevel.geometry().size.to_f64())
.to_i32_round(), .to_i32_round(),
) )