[mutter/gnome-3-24] wayland: Store and retrieve implicit grab information for tablet tools
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-3-24] wayland: Store and retrieve implicit grab information for tablet tools
- Date: Thu, 13 Jul 2017 17:15:02 +0000 (UTC)
commit 9f68507f0c3623d86ab552cf788ec05036f67f69
Author: Jason Gerecke <killertofu gmail com>
Date: Fri Jun 23 08:02:21 2017 -0700
wayland: Store and retrieve implicit grab information for tablet tools
Window moving and resizing depends on the `meta_wayland_seat_get_grab_info`
function succeeding. At the moment, tablet tools do not generate implicit
grabs like the pointer and touch. This commit adds the necessary elements
to track implicit grabs and retrieve their information.
https://bugzilla.gnome.org/show_bug.cgi?id=777333
src/wayland/meta-wayland-seat.c | 56 ++++++++++++++++++++++----------
src/wayland/meta-wayland-seat.h | 1 +
src/wayland/meta-wayland-tablet-tool.c | 42 ++++++++++++++++++++++-
src/wayland/meta-wayland-tablet-tool.h | 6 +++
4 files changed, 86 insertions(+), 19 deletions(-)
---
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index 3404652..a739860 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -411,36 +411,58 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat,
gfloat *x,
gfloat *y)
{
- ClutterEventSequence *sequence = NULL;
- gboolean can_grab_surface = FALSE;
+ MetaWaylandCompositor *compositor;
+ MetaWaylandTabletSeat *tablet_seat;
+ GList *tools, *l;
- if (meta_wayland_seat_has_touch (seat))
- sequence = meta_wayland_touch_find_grab_sequence (seat->touch,
- surface,
- serial);
+ compositor = meta_wayland_compositor_get_default ();
+ tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, seat);
+ tools = g_hash_table_get_values (tablet_seat->tools);
- if (sequence)
+ if (meta_wayland_seat_has_touch (seat))
{
- meta_wayland_touch_get_press_coords (seat->touch, sequence, x, y);
+ ClutterEventSequence *sequence;
+ sequence = meta_wayland_touch_find_grab_sequence (seat->touch,
+ surface,
+ serial);
+ if (sequence)
+ {
+ meta_wayland_touch_get_press_coords (seat->touch, sequence, x, y);
+ return TRUE;
+ }
}
- else
- {
- if (meta_wayland_seat_has_pointer (seat) &&
- (!require_pressed || seat->pointer->button_count > 0))
- can_grab_surface = meta_wayland_pointer_can_grab_surface (seat->pointer,
- surface,
- serial);
- if (can_grab_surface)
+ if (meta_wayland_seat_has_pointer (seat))
+ {
+ if ((!require_pressed || seat->pointer->button_count > 0) &&
+ meta_wayland_pointer_can_grab_surface (seat->pointer, surface, serial))
{
if (x)
*x = seat->pointer->grab_x;
if (y)
*y = seat->pointer->grab_y;
+
+ return TRUE;
}
}
- return sequence || can_grab_surface;
+ for (l = tools; l; l = l->next)
+ {
+ MetaWaylandTabletTool *tool = l->data;
+
+ if ((!require_pressed || tool->button_count > 0) &&
+ meta_wayland_tablet_tool_can_grab_surface (tool, surface, serial))
+ {
+ if (x)
+ *x = tool->grab_x;
+ if (y)
+ *y = tool->grab_y;
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
gboolean
diff --git a/src/wayland/meta-wayland-seat.h b/src/wayland/meta-wayland-seat.h
index 52db072..78abb15 100644
--- a/src/wayland/meta-wayland-seat.h
+++ b/src/wayland/meta-wayland-seat.h
@@ -31,6 +31,7 @@
#include "meta-wayland-keyboard.h"
#include "meta-wayland-touch.h"
#include "meta-wayland-data-device.h"
+#include "meta-wayland-tablet-tool.h"
struct _MetaWaylandSeat
{
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
index 6c19352..cd55f20 100644
--- a/src/wayland/meta-wayland-tablet-tool.c
+++ b/src/wayland/meta-wayland-tablet-tool.c
@@ -572,9 +572,15 @@ meta_wayland_tablet_tool_account_button (MetaWaylandTabletTool *tool,
const ClutterEvent *event)
{
if (event->type == CLUTTER_BUTTON_PRESS)
- tool->pressed_buttons |= 1 << (event->button.button - 1);
+ {
+ tool->pressed_buttons |= 1 << (event->button.button - 1);
+ tool->button_count++;
+ }
else if (event->type == CLUTTER_BUTTON_RELEASE)
- tool->pressed_buttons &= ~(1 << (event->button.button - 1));
+ {
+ tool->pressed_buttons &= ~(1 << (event->button.button - 1));
+ tool->button_count--;
+ }
}
static void
@@ -840,6 +846,9 @@ handle_button_event (MetaWaylandTabletTool *tool,
if (!tool->focus_surface)
return;
+ if (event->type == CLUTTER_BUTTON_PRESS && tool->button_count == 1)
+ clutter_event_get_coords (event, &tool->grab_x, &tool->grab_y);
+
if (event->type == CLUTTER_BUTTON_PRESS && event->button.button == 1)
broadcast_down (tool, event);
else if (event->type == CLUTTER_BUTTON_RELEASE && event->button.button == 1)
@@ -918,3 +927,32 @@ meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *tool,
if (tool->cursor_renderer)
meta_cursor_renderer_set_position (tool->cursor_renderer, new_x, new_y);
}
+
+static gboolean
+tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
+ MetaWaylandSurface *surface)
+{
+ GList *l;
+
+ if (tool->focus_surface == surface)
+ return TRUE;
+
+ for (l = surface->subsurfaces; l; l = l->next)
+ {
+ MetaWaylandSurface *subsurface = l->data;
+
+ if (tablet_tool_can_grab_surface (tool, subsurface))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
+ MetaWaylandSurface *surface,
+ uint32_t serial)
+{
+ return ((tool->down_serial == serial || tool->button_serial == serial) &&
+ tablet_tool_can_grab_surface (tool, surface));
+}
diff --git a/src/wayland/meta-wayland-tablet-tool.h b/src/wayland/meta-wayland-tablet-tool.h
index b7cfce0..351abbc 100644
--- a/src/wayland/meta-wayland-tablet-tool.h
+++ b/src/wayland/meta-wayland-tablet-tool.h
@@ -48,11 +48,14 @@ struct _MetaWaylandTabletTool
MetaWaylandSurface *current;
guint32 pressed_buttons;
+ guint32 button_count;
guint32 proximity_serial;
guint32 down_serial;
guint32 button_serial;
+ float grab_x, grab_y;
+
MetaWaylandTablet *current_tablet;
};
@@ -79,5 +82,8 @@ void meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *t
int new_x,
int new_y);
+gboolean meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
+ MetaWaylandSurface *surface,
+ uint32_t serial);
#endif /* META_WAYLAND_TABLET_TOOL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]