From 0f033807d7d0c5243a6f59d5204af16cb373f09b Mon Sep 17 00:00:00 2001 From: dcz Date: Wed, 23 Apr 2025 12:37:02 +0000 Subject: [PATCH] shell/grabs: Adjust reactive popups when window is moved Reactive XDG popups should be reconstrained if the window is moved: > When set reactive, the surface is reconstrained if the conditions used for constraining changed, e.g. the parent window moved. --- src/shell/grabs/moving.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index 5b3c7979b..49bfa681c 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -11,7 +11,7 @@ use crate::{ }, focus::target::{KeyboardFocusTarget, PointerFocusTarget}, layout::floating::TiledCorners, - CosmicMapped, CosmicSurface, Direction, ManagedLayer, + CosmicMapped, CosmicSurface, Direction, ManagedLayer, WindowSurface, }, utils::prelude::*, wayland::protocols::toplevel_info::{toplevel_enter_output, toplevel_enter_workspace}, @@ -490,7 +490,32 @@ impl PointerGrab for MoveGrab { event: &MotionEvent, ) { self.update_location(state, event.location); - + { + let mut borrow = self + .seat + .user_data() + .get::() + .map(|s| s.lock().unwrap()); + if let Some(grab_state) = borrow.as_mut().and_then(|s| s.as_mut()) { + // this is the global location + let location = + grab_state.window_offset.as_global().to_f64() + grab_state.location.as_global(); + for (window, offset) in self.window.windows() { + match window.0.underlying_surface() { + WindowSurface::Wayland(toplevel) => { + update_reactive_popups( + toplevel, + // round() is used for consistency with fractional scaling + (location + offset.as_global().to_f64()).to_i32_round(), + self.window_outputs.iter(), + ); + } + // X11 surfaces have access to the global coordinate space unlike wayland clients, so they do the re-adjustment themselves. + _ => {} + } + } + } + } // While the grab is active, no client has pointer focus handle.motion(state, None, event); if !self.window.alive() {