From 57e090746e45b941cc313d464f99b7826fdf7ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 30 Oct 2012 14:07:27 -0400 Subject: [PATCH] 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 --- src/shell.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/shell.c b/src/shell.c index cef4011d..b28353ee 100644 --- a/src/shell.c +++ b/src/shell.c @@ -266,6 +266,9 @@ destroy_shell_grab_shsurf(struct wl_listener *listener, void *data) grab->shsurf = NULL; } +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, @@ -275,6 +278,8 @@ shell_grab_start(struct shell_grab *grab, { 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 @@ popup_grab_button(struct wl_pointer_grab *grab, } 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) @@ -1842,6 +1845,20 @@ static const struct wl_pointer_grab_interface popup_grab_interface = { popup_grab_button, }; +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) {