From 81eb7d9537666d98a769cf89a1d85ea624b3032c Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 10 Mar 2014 15:00:59 -0400 Subject: [PATCH] Add META_GRAB_OP_WAYLAND_CLIENT Which is used for Wayland popup grabs. The issue here is that we don't want the code that raises or focuses windows based on mouse ops to run while a client has a grab. We still keep the "old" grab infrastructure in place for now, but ideally we'd replace it eventually with a better grab-op infrastructure. --- src/core/display.c | 24 +++++++++++++++++++++--- src/meta/common.h | 5 ++++- src/wayland/meta-wayland-pointer.c | 22 +++++++++++++++++++++- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/core/display.c b/src/core/display.c index acd26c68c..de675578d 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1418,6 +1418,20 @@ meta_grab_op_is_moving (MetaGrabOp op) } } +static gboolean +grab_op_should_block_mouse_events (MetaGrabOp op) +{ + switch (op) + { + case META_GRAB_OP_WAYLAND_CLIENT: + case META_GRAB_OP_COMPOSITOR: + return TRUE; + + default: + return FALSE; + } +} + /** * meta_display_xserver_time_is_before: * @display: a #MetaDisplay @@ -2054,7 +2068,7 @@ meta_display_handle_event (MetaDisplay *display, switch (event->type) { case CLUTTER_BUTTON_PRESS: - if (display->grab_op == META_GRAB_OP_COMPOSITOR) + if (grab_op_should_block_mouse_events (display->grab_op)) break; display->overlay_key_only_pressed = FALSE; @@ -2226,7 +2240,7 @@ meta_display_handle_event (MetaDisplay *display, } break; case CLUTTER_BUTTON_RELEASE: - if (display->grab_op == META_GRAB_OP_COMPOSITOR) + if (grab_op_should_block_mouse_events (display->grab_op)) break; display->overlay_key_only_pressed = FALSE; @@ -2240,7 +2254,7 @@ meta_display_handle_event (MetaDisplay *display, } break; case CLUTTER_MOTION: - if (display->grab_op == META_GRAB_OP_COMPOSITOR) + if (grab_op_should_block_mouse_events (display->grab_op)) break; if (display->grab_window == window && @@ -2274,6 +2288,10 @@ meta_display_handle_event (MetaDisplay *display, if (display->grab_op == META_GRAB_OP_COMPOSITOR) bypass_wayland = TRUE; + /* If a Wayland client has a grab, don't pass that through to Clutter */ + if (display->grab_op == META_GRAB_OP_WAYLAND_CLIENT) + bypass_clutter = TRUE; + if (compositor && !bypass_wayland) { if (meta_wayland_compositor_handle_event (compositor, event)) diff --git a/src/meta/common.h b/src/meta/common.h index da9712f80..f81d763d7 100644 --- a/src/meta/common.h +++ b/src/meta/common.h @@ -228,7 +228,10 @@ typedef enum META_GRAB_OP_CLICKING_UNSTICK, /* Special grab op when the compositor asked for a grab */ - META_GRAB_OP_COMPOSITOR + META_GRAB_OP_COMPOSITOR, + + /* For when a client takes a popup grab */ + META_GRAB_OP_WAYLAND_CLIENT, } MetaGrabOp; /** diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index 7d15ce4a7..07bd3620f 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -478,6 +478,12 @@ meta_wayland_pointer_end_popup_grab (MetaWaylandPointer *pointer) g_slice_free (MetaWaylandPopup, popup); } + { + MetaDisplay *display = meta_get_display (); + meta_display_end_grab_op (display, + meta_display_get_current_time_roundtrip (display)); + } + meta_wayland_pointer_end_grab (pointer); g_slice_free (MetaWaylandPopupGrab, popup_grab); } @@ -517,6 +523,8 @@ meta_wayland_pointer_start_popup_grab (MetaWaylandPointer *pointer, if (pointer->grab == &pointer->default_grab) { + MetaWindow *window = surface->window; + grab = g_slice_new0 (MetaWaylandPopupGrab); grab->generic.interface = &popup_grab_interface; grab->generic.pointer = pointer; @@ -524,6 +532,19 @@ meta_wayland_pointer_start_popup_grab (MetaWaylandPointer *pointer, wl_list_init (&grab->all_popups); meta_wayland_pointer_start_grab (pointer, (MetaWaylandPointerGrab*)grab); + + meta_display_begin_grab_op (window->display, + window->screen, + window, + META_GRAB_OP_WAYLAND_CLIENT, + FALSE, /* pointer_already_grabbed */ + FALSE, /* frame_action */ + 1, /* button. XXX? */ + 0, /* modmask */ + meta_display_get_current_time_roundtrip (window->display), + wl_fixed_to_int (pointer->grab_x), + wl_fixed_to_int (pointer->grab_y)); + } else grab = (MetaWaylandPopupGrab*)pointer->grab; @@ -538,7 +559,6 @@ meta_wayland_pointer_start_popup_grab (MetaWaylandPointer *pointer, wl_resource_add_destroy_listener (surface->wl_shell_surface.resource, &popup->surface_destroy_listener); wl_list_insert (&grab->all_popups, &popup->link); - return TRUE; }