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,18 +245,25 @@ 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
states .surface_offset(&wl_surface)
.cached_state .unwrap_or(Point::from((0, 0)))
.get::<SurfaceCachedState>() .to_f64();
.current() let geometry_loc = toplevel
.geometry .wl_surface()
.map(|g| g.loc.to_f64()) .and_then(|s| {
}) with_states(&s, |states| {
.unwrap_or_default(); states
.cached_state
.get::<SurfaceCachedState>()
.current()
.geometry
.map(|g| g.loc.to_f64())
})
})
.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(),
) )