[mutter] wayland: remove pressed button checks from meta_wayland_pointer_can_grab_surface()



commit a6cc35e5957d98d6c7f3b7ebc434cb2d90d3b38c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Apr 4 18:07:42 2016 +0200

    wayland: remove pressed button checks from meta_wayland_pointer_can_grab_surface()
    
    Leave these checks up to the callers, the only uses of this function
    (indirect, through meta_wayland_seat_get_grab_info) are
    [wl_shell|xdg]_surface.move/resize/show_window_menu.
    
    In move/resize it makes sense to check for a button being pressed, because
    we must expect a button release event. However for xdg_surface.show_window_menu
    we 1) don't strictly need further events and 2) we must account for press+release
    event pairs being processed at once in the compositor before the client sees
    the former.
    
    That is eg. the case of touchpad 2nd/3rd button tap emulation, multifinger
    taps will emit the event pair at once, so when the client manages to request
    xdg_surface.show_window_menu, it'll be too late in the compositor side, so the
    request is ignored.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764519

 src/wayland/meta-wayland-pointer.c |    3 +--
 src/wayland/meta-wayland-seat.c    |   12 +++++++-----
 src/wayland/meta-wayland-seat.h    |    9 +++++----
 src/wayland/meta-wayland-surface.c |   10 +++++-----
 4 files changed, 18 insertions(+), 16 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index aad9aaa..b4a36b4 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -1138,8 +1138,7 @@ meta_wayland_pointer_can_grab_surface (MetaWaylandPointer *pointer,
                                        MetaWaylandSurface *surface,
                                        uint32_t            serial)
 {
-  return (pointer->button_count > 0 &&
-          pointer->grab_serial == serial &&
+  return (pointer->grab_serial == serial &&
           pointer->focus_surface == surface);
 }
 
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index 9ac2cd1..367c1f1 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -374,10 +374,11 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat    *seat,
 
 gboolean
 meta_wayland_seat_get_grab_info (MetaWaylandSeat    *seat,
-                                MetaWaylandSurface *surface,
-                                uint32_t            serial,
-                                gfloat             *x,
-                                gfloat             *y)
+                                 MetaWaylandSurface *surface,
+                                 uint32_t            serial,
+                                 gboolean            require_pressed,
+                                 gfloat             *x,
+                                 gfloat             *y)
 {
   ClutterEventSequence *sequence = NULL;
   gboolean can_grab_surface = FALSE;
@@ -391,7 +392,8 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat    *seat,
     }
   else
     {
-      if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) != 0)
+      if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) != 0 &&
+          (!require_pressed || seat->pointer.button_count > 0))
         can_grab_surface = meta_wayland_pointer_can_grab_surface (&seat->pointer, surface, serial);
 
       if (can_grab_surface)
diff --git a/src/wayland/meta-wayland-seat.h b/src/wayland/meta-wayland-seat.h
index 42d2304..42ddb1e 100644
--- a/src/wayland/meta-wayland-seat.h
+++ b/src/wayland/meta-wayland-seat.h
@@ -60,10 +60,11 @@ void meta_wayland_seat_set_input_focus (MetaWaylandSeat    *seat,
 void meta_wayland_seat_repick (MetaWaylandSeat *seat);
 
 gboolean meta_wayland_seat_get_grab_info (MetaWaylandSeat    *seat,
-                                         MetaWaylandSurface *surface,
-                                         uint32_t            serial,
-                                         gfloat             *x,
-                                         gfloat             *y);
+                                          MetaWaylandSurface *surface,
+                                          uint32_t            serial,
+                                          gboolean            require_pressed,
+                                          gfloat             *x,
+                                          gfloat             *y);
 gboolean meta_wayland_seat_can_popup     (MetaWaylandSeat *seat,
                                           uint32_t         serial);
 
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index e9599c5..4699cfd 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -1362,7 +1362,7 @@ xdg_surface_show_window_menu (struct wl_client *client,
   MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
   MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
 
-  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, NULL, NULL))
+  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, FALSE, NULL, NULL))
     return;
 
   meta_window_show_menu (surface->window, META_WINDOW_MENU_WM,
@@ -1407,7 +1407,7 @@ xdg_surface_move (struct wl_client *client,
   MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
   gfloat x, y;
 
-  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, &x, &y))
+  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y))
     return;
 
   begin_grab_op_on_surface (surface, seat, META_GRAB_OP_MOVING, x, y);
@@ -1447,7 +1447,7 @@ xdg_surface_resize (struct wl_client *client,
   MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
   gfloat x, y;
 
-  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, &x, &y))
+  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y))
     return;
 
   begin_grab_op_on_surface (surface, seat, grab_op_for_xdg_surface_resize_edge (edges), x, y);
@@ -1790,7 +1790,7 @@ wl_shell_surface_move (struct wl_client *client,
   MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
   gfloat x, y;
 
-  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, &x, &y))
+  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y))
     return;
 
   begin_grab_op_on_surface (surface, seat, META_GRAB_OP_MOVING, x, y);
@@ -1830,7 +1830,7 @@ wl_shell_surface_resize (struct wl_client *client,
   MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
   gfloat x, y;
 
-  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, &x, &y))
+  if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y))
     return;
 
   begin_grab_op_on_surface (surface, seat, grab_op_for_wl_shell_surface_resize_edge (edges), x, y);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]