shell: End popups if we trigger a shell grab
Clicking outside popups closes them except in case of a shell grab
(move, resize or rotate), in which case we move the parent window away
from under the popup. Instead, just end the popup in those cases.
https://bugs.freedesktop.org/show_bug.cgi?id=55674
diff --git a/src/shell.c b/src/shell.c
index cef4011..b28353e 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -267,6 +267,9 @@
}
static void
+popup_grab_end(struct wl_pointer *pointer);
+
+static void
shell_grab_start(struct shell_grab *grab,
const struct wl_pointer_grab_interface *interface,
struct shell_surface *shsurf,
@@ -275,6 +278,8 @@
{
struct desktop_shell *shell = shsurf->shell;
+ popup_grab_end(pointer);
+
grab->grab.interface = interface;
grab->shsurf = shsurf;
grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf;
@@ -1827,9 +1832,7 @@
} else if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
(shsurf->popup.initial_up ||
time - shsurf->popup.seat->pointer->grab_time > 500)) {
- wl_shell_surface_send_popup_done(&shsurf->resource);
- wl_pointer_end_grab(grab->pointer);
- shsurf->popup.grab.pointer = NULL;
+ popup_grab_end(grab->pointer);
}
if (state == WL_POINTER_BUTTON_STATE_RELEASED)
@@ -1843,6 +1846,20 @@
};
static void
+popup_grab_end(struct wl_pointer *pointer)
+{
+ struct wl_pointer_grab *grab = pointer->grab;
+ struct shell_surface *shsurf =
+ container_of(grab, struct shell_surface, popup.grab);
+
+ if (pointer->grab->interface == &popup_grab_interface) {
+ wl_shell_surface_send_popup_done(&shsurf->resource);
+ wl_pointer_end_grab(grab->pointer);
+ shsurf->popup.grab.pointer = NULL;
+ }
+}
+
+static void
shell_map_popup(struct shell_surface *shsurf)
{
struct wl_seat *seat = shsurf->popup.seat;