From 1a57c104f64c01eeae47774a0f48a366b1105cb8 Mon Sep 17 00:00:00 2001 From: KENZ Date: Fri, 24 Apr 2026 05:41:11 +0900 Subject: [PATCH] refactor: extract positioning popups within global rect logic - preparation to make unconstrain_popup() PopupKind agnostic --- src/wayland/handlers/xdg_shell/popup.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wayland/handlers/xdg_shell/popup.rs b/src/wayland/handlers/xdg_shell/popup.rs index 59e8b6e5..ad093d9e 100644 --- a/src/wayland/handlers/xdg_shell/popup.rs +++ b/src/wayland/handlers/xdg_shell/popup.rs @@ -148,14 +148,7 @@ fn unconstrain_xdg_popup( ) { rect.loc -= window_loc; rect.loc -= get_popup_toplevel_coords(&PopupKind::Xdg(surface.clone())).as_global(); - let geometry = surface.with_pending_state(|state| { - state - .positioner - .get_unconstrained_geometry(rect.as_logical()) - }); - surface.with_pending_state(|state| { - state.geometry = geometry; - }); + position_popup_within_rect(surface, rect); } 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(); relative.loc -= layer_geo.loc; relative.loc -= get_popup_toplevel_coords(&PopupKind::Xdg(surface.clone())); - let geometry = - surface.with_pending_state(|state| state.positioner.get_unconstrained_geometry(relative)); + position_popup_within_rect(surface, relative.as_global()); +} + +fn position_popup_within_rect(surface: &PopupSurface, rect: Rectangle) { + let geometry = surface.with_pending_state(|state| { + state + .positioner + .get_unconstrained_geometry(rect.as_logical()) + }); surface.with_pending_state(|state| { state.geometry = geometry; });