refactor: extract positioning popups within global rect logic

- preparation to make unconstrain_popup() PopupKind agnostic
This commit is contained in:
KENZ 2026-04-24 05:41:11 +09:00 committed by Jacob Kauffmann
parent 977d4c2dca
commit 1a57c104f6

View file

@ -148,14 +148,7 @@ fn unconstrain_xdg_popup(
) { ) {
rect.loc -= window_loc; rect.loc -= window_loc;
rect.loc -= get_popup_toplevel_coords(&PopupKind::Xdg(surface.clone())).as_global(); rect.loc -= get_popup_toplevel_coords(&PopupKind::Xdg(surface.clone())).as_global();
let geometry = surface.with_pending_state(|state| { position_popup_within_rect(surface, rect);
state
.positioner
.get_unconstrained_geometry(rect.as_logical())
});
surface.with_pending_state(|state| {
state.geometry = geometry;
});
} }
fn unconstrain_layer_popup(surface: &PopupSurface, output: &Output, layer_surface: &LayerSurface) { fn unconstrain_layer_popup(surface: &PopupSurface, output: &Output, layer_surface: &LayerSurface) {
@ -166,8 +159,15 @@ fn unconstrain_layer_popup(surface: &PopupSurface, output: &Output, layer_surfac
let mut relative = Rectangle::from_size(output.geometry().size).as_logical(); let mut relative = Rectangle::from_size(output.geometry().size).as_logical();
relative.loc -= layer_geo.loc; relative.loc -= layer_geo.loc;
relative.loc -= get_popup_toplevel_coords(&PopupKind::Xdg(surface.clone())); relative.loc -= get_popup_toplevel_coords(&PopupKind::Xdg(surface.clone()));
let geometry = position_popup_within_rect(surface, relative.as_global());
surface.with_pending_state(|state| state.positioner.get_unconstrained_geometry(relative)); }
fn position_popup_within_rect(surface: &PopupSurface, rect: Rectangle<i32, Global>) {
let geometry = surface.with_pending_state(|state| {
state
.positioner
.get_unconstrained_geometry(rect.as_logical())
});
surface.with_pending_state(|state| { surface.with_pending_state(|state| {
state.geometry = geometry; state.geometry = geometry;
}); });