[mutter/wip/tablet-protocol-v2: 11/14] wayland: Implement tool notification



commit 9125a8f89d5b56f02d5c30b064bb1499469b2e77
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 28 17:02:16 2015 +0100

    wayland: Implement tool notification
    
    Those must be notified to clients before proximity_in, only if the client
    didn't have a resource for this tool previously.

 src/wayland/meta-wayland-tablet-tool.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
index 28a7dad..2c15340 100644
--- a/src/wayland/meta-wayland-tablet-tool.c
+++ b/src/wayland/meta-wayland-tablet-tool.c
@@ -117,6 +117,25 @@ meta_wayland_tablet_tool_set_cursor_surface (MetaWaylandTabletTool *tool,
 }
 
 static void
+meta_wayland_tablet_tool_ensure_resource (MetaWaylandTabletTool *tool,
+                                          struct wl_client      *client)
+{
+  struct wl_resource *seat_resource;
+
+  seat_resource = meta_wayland_tablet_seat_lookup_resource (tool->seat, client);
+
+  if (seat_resource &&
+      !meta_wayland_tablet_tool_lookup_resource (tool, client))
+    {
+      meta_wayland_tablet_tool_create_new_resource (tool, client,
+                                                    seat_resource,
+                                                    0);
+
+      meta_wayland_tablet_seat_notify_tool (tool->seat, tool, client);
+    }
+}
+
+static void
 meta_wayland_tablet_tool_set_focus (MetaWaylandTabletTool *tool,
                                     MetaWaylandSurface    *surface)
 {
@@ -147,7 +166,7 @@ meta_wayland_tablet_tool_set_focus (MetaWaylandTabletTool *tool,
       tool->focus_surface = NULL;
     }
 
-  if (surface != NULL)
+  if (surface != NULL && tool->current_tablet)
     {
       struct wl_resource *resource, *tablet_resource;
       struct wl_client *client;
@@ -161,6 +180,8 @@ meta_wayland_tablet_tool_set_focus (MetaWaylandTabletTool *tool,
       move_resources_for_client (&tool->focus_resource_list,
                                  &tool->resource_list, client);
 
+      meta_wayland_tablet_tool_ensure_resource (tool, client);
+
       tablet_resource = meta_wayland_tablet_lookup_resource (tool->current_tablet,
                                                              client);
       l = &tool->focus_resource_list;


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