xdg-shell: Fix menu offset

This commit is contained in:
Victoria Brekenfeld 2023-12-08 16:21:16 +00:00 committed by Victoria Brekenfeld
parent 8c4d77e43c
commit 02a6290067

View file

@ -19,9 +19,11 @@ use smithay::{
}, },
utils::{Logical, Point, Serial}, utils::{Logical, Point, Serial},
wayland::{ wayland::{
compositor::with_states,
seat::WaylandFocus, seat::WaylandFocus,
shell::xdg::{ shell::xdg::{
PopupSurface, PositionerState, ToplevelSurface, XdgShellHandler, XdgShellState, PopupSurface, PositionerState, SurfaceCachedState, ToplevelSurface, XdgShellHandler,
XdgShellState,
}, },
}, },
}; };
@ -365,9 +367,14 @@ impl XdgShellHandler for State {
surface: ToplevelSurface, surface: ToplevelSurface,
seat: WlSeat, seat: WlSeat,
serial: Serial, serial: Serial,
location: Point<i32, Logical>, mut location: Point<i32, Logical>,
) { ) {
let seat = Seat::from_resource(&seat).unwrap(); let seat = Seat::from_resource(&seat).unwrap();
location -= with_states(surface.wl_surface(), |states| {
states.cached_state.current::<SurfaceCachedState>().geometry
})
.unwrap_or_default()
.loc;
Shell::menu_request(self, surface.wl_surface(), &seat, serial, location) Shell::menu_request(self, surface.wl_surface(), &seat, serial, location)
} }
} }