From 32613f3cd6b3059bd78fe00264f8ee437f00ad8c Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 2 Feb 2020 18:09:21 +0300 Subject: [PATCH] anvil.shell: check that grab is correct in Move Check that the grab had a focus and it was the same client as this surface. --- anvil/src/shell.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/anvil/src/shell.rs b/anvil/src/shell.rs index e69b400..b9fa6a3 100644 --- a/anvil/src/shell.rs +++ b/anvil/src/shell.rs @@ -167,6 +167,19 @@ pub fn init_shell( let start_data = pointer.grab_start_data().unwrap(); + // If the focus was for a different surface, ignore the request. + if start_data.focus.is_none() + || !start_data + .focus + .as_ref() + .unwrap() + .0 + .as_ref() + .same_client_as(surface.get_surface().unwrap().as_ref()) + { + return; + } + let toplevel = SurfaceKind::Xdg(surface); let initial_window_location = xdg_window_map.borrow().location(&toplevel).unwrap(); @@ -222,6 +235,19 @@ pub fn init_shell( let start_data = pointer.grab_start_data().unwrap(); + // If the focus was for a different surface, ignore the request. + if start_data.focus.is_none() + || !start_data + .focus + .as_ref() + .unwrap() + .0 + .as_ref() + .same_client_as(surface.get_surface().unwrap().as_ref()) + { + return; + } + let toplevel = SurfaceKind::Wl(surface); let initial_window_location = shell_window_map.borrow().location(&toplevel).unwrap();