[mutter/wip/tablet-protocol: 12/16] wayland: Implement wl_tablet_manager.tool_added



commit 85c5181605d59452de9553d06ee32ca377092cbd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Feb 5 11:49:45 2015 +0100

    wayland: Implement wl_tablet_manager.tool_added
    
    meta_wayland_tablet_manager_notify_tool() creates the wl_tablet_tool
    resource for a given client and notifies about it. It should be used
    prior to proximity_in events.

 src/wayland/meta-wayland-tablet-manager.c |   44 +++++++++++++++++++++++++++++
 src/wayland/meta-wayland-tablet-manager.h |    4 ++
 2 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland-tablet-manager.c b/src/wayland/meta-wayland-tablet-manager.c
index 87787b3..7a30d59 100644
--- a/src/wayland/meta-wayland-tablet-manager.c
+++ b/src/wayland/meta-wayland-tablet-manager.c
@@ -32,6 +32,7 @@
 
 #include "meta-wayland-private.h"
 #include "meta-wayland-tablet-manager.h"
+#include "meta-wayland-tablet-tool.h"
 #include "meta-wayland-tablet.h"
 
 static void
@@ -41,6 +42,35 @@ unbind_resource (struct wl_resource *resource)
 }
 
 static void
+notify_tool_added (MetaWaylandTabletManager *manager,
+                   struct wl_resource       *client_resource,
+                   MetaWaylandTablet        *tablet,
+                   MetaWaylandTabletTool    *tool)
+{
+  struct wl_resource *tool_resource, *tablet_resource;
+
+  tablet = g_hash_table_lookup (manager->tablets, tablet->device);
+
+  if (!tablet)
+    return;
+
+  tablet_resource = meta_wayland_tablet_lookup_resource (tablet,
+                                                         wl_resource_get_client (client_resource));
+  if (!tablet_resource)
+    return;
+
+  tool_resource = meta_wayland_tablet_tool_create_new_resource (tool,
+                                                                wl_resource_get_client (client_resource),
+                                                                client_resource, 0);
+  if (!tool_resource)
+    return;
+
+  wl_tablet_manager_send_tool_added (client_resource,
+                                     tool_resource, tablet_resource,
+                                     tool->type, tool->serial, tool->axes);
+}
+
+static void
 notify_tablet_added (MetaWaylandTabletManager *manager,
                      struct wl_resource       *client_resource,
                      ClutterInputDevice       *device)
@@ -251,6 +281,20 @@ meta_wayland_tablet_manager_handle_event (MetaWaylandTabletManager *manager,
 }
 
 void
+meta_wayland_tablet_manager_notify_tool (MetaWaylandTabletManager *manager,
+                                         MetaWaylandTablet        *tablet,
+                                         MetaWaylandTabletTool    *tool,
+                                         struct wl_client         *client)
+{
+  struct wl_resource *resource;
+
+  resource = wl_resource_find_for_client (&manager->resource_list, client);
+
+  if (resource)
+    notify_tool_added (manager, resource, tablet, tool);
+}
+
+void
 meta_wayland_tablet_manager_update_cursor_position (MetaWaylandTabletManager *manager,
                                                     const ClutterEvent       *event)
 {
diff --git a/src/wayland/meta-wayland-tablet-manager.h b/src/wayland/meta-wayland-tablet-manager.h
index 204a603..b658ce4 100644
--- a/src/wayland/meta-wayland-tablet-manager.h
+++ b/src/wayland/meta-wayland-tablet-manager.h
@@ -49,5 +49,9 @@ gboolean meta_wayland_tablet_manager_handle_event   (MetaWaylandTabletManager *m
 
 void     meta_wayland_tablet_manager_update_cursor_position (MetaWaylandTabletManager *manager,
                                                              const ClutterEvent       *event);
+void     meta_wayland_tablet_manager_notify_tool    (MetaWaylandTabletManager *manager,
+                                                     MetaWaylandTablet        *tablet,
+                                                     MetaWaylandTabletTool    *tool,
+                                                     struct wl_client         *client);
 
 #endif /* META_WAYLAND_TABLET_MANAGER_H */


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