[gtk+/wip/wayland-tablet-v2: 17/19] wayland: Offer wayland-specific method to set pad actions feedback



commit 18488ef8f5fd43e9c205509149aea037d6ebaf3a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Aug 4 19:47:13 2016 +0200

    wayland: Offer wayland-specific method to set pad actions feedback
    
    The wayland tablet protocol allows notifying the compositor with
    descriptions of the actions performed by each tablet element. This
    API call allows to hook up in to this wayland-specific feature.

 gdk/wayland/gdkdevice-wayland.c |   52 +++++++++++++++++++++++++++++++++++++++
 gdk/wayland/gdkwaylanddevice.h  |    6 ++++
 2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index fcd5177..8430d2f 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -5184,3 +5184,55 @@ gdk_wayland_device_get_node_path (GdkDevice *device)
 
   return NULL;
 }
+
+void
+gdk_wayland_device_pad_set_feedback (GdkDevice           *device,
+                                     GdkDevicePadFeature  element,
+                                     guint                idx,
+                                     const gchar         *label)
+{
+  GdkWaylandTabletPadData *pad;
+  GdkWaylandTabletPadGroupData *group;
+  GdkSeat *seat;
+
+  seat = gdk_device_get_seat (device);
+  pad = gdk_wayland_device_manager_find_pad (GDK_WAYLAND_SEAT (seat),
+                                             device);
+  if (!pad)
+    return;
+
+  if (element == GDK_DEVICE_PAD_FEATURE_BUTTON)
+    {
+      group = tablet_pad_lookup_button_group (pad, idx);
+      if (!group)
+        return;
+
+      zwp_tablet_pad_v2_set_feedback (pad->wp_tablet_pad, idx, label,
+                                      group->mode_switch_serial);
+    }
+  else if (element == GDK_DEVICE_PAD_FEATURE_RING)
+    {
+      struct zwp_tablet_pad_ring_v2 *wp_pad_ring;
+
+      wp_pad_ring = g_list_nth_data (pad->rings, idx);
+      if (!wp_pad_ring)
+        return;
+
+      group = zwp_tablet_pad_ring_v2_get_user_data (wp_pad_ring);
+      zwp_tablet_pad_ring_v2_set_feedback (wp_pad_ring, label,
+                                           group->mode_switch_serial);
+
+    }
+  else if (element == GDK_DEVICE_PAD_FEATURE_STRIP)
+    {
+      struct zwp_tablet_pad_strip_v2 *wp_pad_strip;
+
+      wp_pad_strip = g_list_nth_data (pad->strips, idx);
+      if (!wp_pad_strip)
+        return;
+
+      group = zwp_tablet_pad_strip_v2_get_user_data (wp_pad_strip);
+      zwp_tablet_pad_strip_v2_set_feedback (wp_pad_strip, label,
+                                            group->mode_switch_serial);
+    }
+}
diff --git a/gdk/wayland/gdkwaylanddevice.h b/gdk/wayland/gdkwaylanddevice.h
index b02ceeb..e7a3b9a 100644
--- a/gdk/wayland/gdkwaylanddevice.h
+++ b/gdk/wayland/gdkwaylanddevice.h
@@ -58,6 +58,12 @@ struct wl_seat      *gdk_wayland_seat_get_wl_seat           (GdkSeat   *seat);
 GDK_AVAILABLE_IN_3_22
 const gchar         *gdk_wayland_device_get_node_path       (GdkDevice *device);
 
+GDK_AVAILABLE_IN_3_22
+void                 gdk_wayland_device_pad_set_feedback (GdkDevice           *device,
+                                                          GdkDevicePadFeature  element,
+                                                          guint                idx,
+                                                          const gchar         *label);
+
 G_END_DECLS
 
 #endif /* __GDK_WAYLAND_DEVICE_H__ */


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