From 3c24934f48f7963075397db8562e9cf3a781d2b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Capucho?= Date: Mon, 19 Aug 2024 16:01:04 +0100 Subject: [PATCH] Track if a move or resize request is client initiated --- src/input/mod.rs | 4 +++- src/shell/element/stack.rs | 4 ++++ src/shell/element/window.rs | 2 ++ src/shell/grabs/menu/default.rs | 1 + src/shell/mod.rs | 11 ++++------- src/wayland/handlers/xdg_shell/mod.rs | 3 ++- src/xwayland.rs | 3 ++- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index e8a71052..5d47bf0e 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -888,6 +888,7 @@ impl State { &state.common.config, &state.common.event_loop_handle, &state.common.xdg_activation_state, + false ); drop(shell); dispatch_grab(res, seat_clone, serial, state); @@ -910,7 +911,8 @@ impl State { &surface, &seat_clone, serial, - edge + edge, + false ); drop(shell); dispatch_grab(res, seat_clone, serial, state); diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index 6e198b6c..e0c9158a 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -622,6 +622,7 @@ impl CosmicStack { &state.common.config, &state.common.event_loop_handle, &state.common.xdg_activation_state, + false, ); if let Some((grab, focus)) = res { if grab.is_touch_grab() { @@ -710,6 +711,7 @@ impl Program for CosmicStackInternal { &state.common.config, &state.common.event_loop_handle, &state.common.xdg_activation_state, + false, ); if let Some((grab, focus)) = res { if grab.is_touch_grab() { @@ -1290,6 +1292,7 @@ impl PointerTarget for CosmicStack { Focus::ResizeRight => ResizeEdge::RIGHT, Focus::Header => unreachable!(), }, + false, ); if let Some((grab, focus)) = res { if grab.is_touch_grab() { @@ -1356,6 +1359,7 @@ impl PointerTarget for CosmicStack { &state.common.config, &state.common.event_loop_handle, &state.common.xdg_activation_state, + false, ); if let Some((grab, focus)) = res { if grab.is_touch_grab() { diff --git a/src/shell/element/window.rs b/src/shell/element/window.rs index 75e9da51..9fac26b8 100644 --- a/src/shell/element/window.rs +++ b/src/shell/element/window.rs @@ -406,6 +406,7 @@ impl Program for CosmicWindowInternal { &state.common.config, &state.common.event_loop_handle, &state.common.xdg_activation_state, + false, ); if let Some((grab, focus)) = res { if grab.is_touch_grab() { @@ -718,6 +719,7 @@ impl PointerTarget for CosmicWindow { Focus::ResizeRight => ResizeEdge::RIGHT, Focus::Header => unreachable!(), }, + false, ); if let Some((grab, focus)) = res { diff --git a/src/shell/grabs/menu/default.rs b/src/shell/grabs/menu/default.rs index 0bebb955..1c826cbe 100644 --- a/src/shell/grabs/menu/default.rs +++ b/src/shell/grabs/menu/default.rs @@ -257,6 +257,7 @@ pub fn window_items( &state.common.config, &state.common.event_loop_handle, &state.common.xdg_activation_state, + false, ); std::mem::drop(shell); diff --git a/src/shell/mod.rs b/src/shell/mod.rs index f594891c..bd99d5b7 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -2430,15 +2430,11 @@ impl Shell { config: &Config, evlh: &LoopHandle<'static, State>, xdg_activation_state: &XdgActivationState, + client_initiated: bool, ) -> Option<(MoveGrab, Focus)> { let serial = serial.into(); - let mut start_data = check_grab_preconditions( - &seat, - surface, - serial, - release == ReleaseMode::NoMouseButtons && !move_out_of_stack, - )?; + let mut start_data = check_grab_preconditions(&seat, surface, serial, client_initiated)?; let mut old_mapped = self.element_for_surface(surface).cloned()?; if old_mapped.is_minimized() { return None; @@ -3072,9 +3068,10 @@ impl Shell { seat: &Seat, serial: impl Into>, edges: ResizeEdge, + client_initiated: bool, ) -> Option<(ResizeGrab, Focus)> { let serial = serial.into(); - let start_data = check_grab_preconditions(&seat, surface, serial, true)?; + let start_data = check_grab_preconditions(&seat, surface, serial, client_initiated)?; let mapped = self.element_for_surface(surface).cloned()?; if mapped.is_fullscreen(true) || mapped.is_maximized(true) { return None; diff --git a/src/wayland/handlers/xdg_shell/mod.rs b/src/wayland/handlers/xdg_shell/mod.rs index 4f782e38..9b833851 100644 --- a/src/wayland/handlers/xdg_shell/mod.rs +++ b/src/wayland/handlers/xdg_shell/mod.rs @@ -161,6 +161,7 @@ impl XdgShellHandler for State { &self.common.config, &self.common.event_loop_handle, &self.common.xdg_activation_state, + true, ) { std::mem::drop(shell); if grab.is_touch_grab() { @@ -183,7 +184,7 @@ impl XdgShellHandler for State { let seat = Seat::from_resource(&seat).unwrap(); let mut shell = self.common.shell.write().unwrap(); if let Some((grab, focus)) = - shell.resize_request(surface.wl_surface(), &seat, serial, edges.into()) + shell.resize_request(surface.wl_surface(), &seat, serial, edges.into(), true) { std::mem::drop(shell); if grab.is_touch_grab() { diff --git a/src/xwayland.rs b/src/xwayland.rs index 62ae3886..3621b1a9 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -481,7 +481,7 @@ impl XwmHandler for State { let mut shell = self.common.shell.write().unwrap(); let seat = shell.seats.last_active().clone(); if let Some((grab, focus)) = - shell.resize_request(&wl_surface, &seat, None, resize_edge.into()) + shell.resize_request(&wl_surface, &seat, None, resize_edge.into(), true) { std::mem::drop(shell); if grab.is_touch_grab() { @@ -513,6 +513,7 @@ impl XwmHandler for State { &self.common.config, &self.common.event_loop_handle, &self.common.xdg_activation_state, + true, ) { std::mem::drop(shell); if grab.is_touch_grab() {