[mutter/wip/tablet-protocol-v2: 12/14] wayland: Add methods to update the position of different tools' cursors



commit 1ba5ded13020389458dc1e853891cc1093c632eb
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 28 13:49:19 2015 +0100

    wayland: Add methods to update the position of different tools' cursors

 src/wayland/meta-wayland-tablet-manager.c |   28 ++++++++++++++++++++++++++++
 src/wayland/meta-wayland-tablet-manager.h |    3 +++
 src/wayland/meta-wayland-tablet-tool.c    |    9 +++++++++
 src/wayland/meta-wayland-tablet-tool.h    |    5 +++++
 4 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland-tablet-manager.c b/src/wayland/meta-wayland-tablet-manager.c
index 2e5e3c2..ff40c59 100644
--- a/src/wayland/meta-wayland-tablet-manager.c
+++ b/src/wayland/meta-wayland-tablet-manager.c
@@ -33,6 +33,7 @@
 #include "meta-wayland-private.h"
 #include "meta-wayland-tablet-manager.h"
 #include "meta-wayland-tablet-seat.h"
+#include "meta-wayland-tablet-tool.h"
 
 static void
 unbind_resource (struct wl_resource *resource)
@@ -227,3 +228,30 @@ meta_wayland_tablet_manager_handle_event (MetaWaylandTabletManager *manager,
       return CLUTTER_EVENT_PROPAGATE;
     }
 }
+
+void
+meta_wayland_tablet_manager_update_cursor_position (MetaWaylandTabletManager *manager,
+                                                    const ClutterEvent       *event)
+{
+  MetaWaylandTabletSeat *tablet_seat = NULL;
+  MetaWaylandTabletTool *tool = NULL;
+  ClutterInputDeviceTool *device_tool;
+  ClutterInputDevice *device;
+
+  device = clutter_event_get_source_device (event);
+  device_tool = clutter_event_get_device_tool (event);
+
+  if (device)
+    tablet_seat = meta_wayland_tablet_manager_lookup_seat (manager, device);
+
+  if (tablet_seat && device_tool)
+    tool = meta_wayland_tablet_seat_lookup_tool (tablet_seat, device_tool);
+
+  if (tool)
+    {
+      gfloat new_x, new_y;
+
+      clutter_event_get_coords (event, &new_x, &new_y);
+      meta_wayland_tablet_tool_set_cursor_position (tool, new_x, new_y);
+    }
+}
diff --git a/src/wayland/meta-wayland-tablet-manager.h b/src/wayland/meta-wayland-tablet-manager.h
index f63c3b7..9972201 100644
--- a/src/wayland/meta-wayland-tablet-manager.h
+++ b/src/wayland/meta-wayland-tablet-manager.h
@@ -47,4 +47,7 @@ void     meta_wayland_tablet_manager_update         (MetaWaylandTabletManager *m
 gboolean meta_wayland_tablet_manager_handle_event   (MetaWaylandTabletManager *manager,
                                                      const ClutterEvent       *event);
 
+void     meta_wayland_tablet_manager_update_cursor_position (MetaWaylandTabletManager *manager,
+                                                             const ClutterEvent       *event);
+
 #endif /* META_WAYLAND_TABLET_MANAGER_H */
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
index 2c15340..5c468e2 100644
--- a/src/wayland/meta-wayland-tablet-tool.c
+++ b/src/wayland/meta-wayland-tablet-tool.c
@@ -787,3 +787,12 @@ meta_wayland_tablet_tool_handle_event (MetaWaylandTabletTool *tool,
 
   return CLUTTER_EVENT_STOP;
 }
+
+void
+meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *tool,
+                                              int                    new_x,
+                                              int                    new_y)
+{
+  if (tool->cursor_renderer)
+    meta_cursor_renderer_set_position (tool->cursor_renderer, new_x, new_y);
+}
diff --git a/src/wayland/meta-wayland-tablet-tool.h b/src/wayland/meta-wayland-tablet-tool.h
index 2d7031a..c2f81ec 100644
--- a/src/wayland/meta-wayland-tablet-tool.h
+++ b/src/wayland/meta-wayland-tablet-tool.h
@@ -74,4 +74,9 @@ void     meta_wayland_tablet_tool_update              (MetaWaylandTabletTool  *t
 gboolean meta_wayland_tablet_tool_handle_event        (MetaWaylandTabletTool  *tool,
                                                        const ClutterEvent     *event);
 
+void     meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool  *tool,
+                                                       int                     new_x,
+                                                       int                     new_y);
+
+
 #endif /* META_WAYLAND_TABLET_TOOL_H */


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