[mutter/wip/tablet-protocol-v2: 66/70] core: Add public MetaDisplay functions to get action labels for pad buttons



commit da37d7914817a9b1f182b88ade334932addd9780
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jun 22 19:10:13 2016 +0200

    core: Add public MetaDisplay functions to get action labels for pad buttons
    
    This API will be used from the gnome-shell pad OSD implementation, in order
    to show the actions that currently apply to every button/ring/strip in the
    tablet.

 src/core/display.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/meta/display.h |    5 +++++
 2 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index 4c7a00e..a9ddfef 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -53,6 +53,7 @@
 #include "backends/native/meta-backend-native.h"
 #include "backends/x11/meta-backend-x11.h"
 #include "backends/meta-stage.h"
+#include "backends/meta-input-settings-private.h"
 #include <clutter/x11/clutter-x11.h>
 
 #ifdef HAVE_RANDR
@@ -75,6 +76,8 @@
 
 #ifdef HAVE_WAYLAND
 #include "wayland/meta-xwayland-private.h"
+#include "wayland/meta-wayland-tablet-seat.h"
+#include "wayland/meta-wayland-tablet-pad.h"
 #endif
 
 /*
@@ -3079,3 +3082,50 @@ meta_display_set_alarm_filter (MetaDisplay    *display,
   display->alarm_filter = filter;
   display->alarm_filter_data = data;
 }
+
+gchar *
+meta_display_get_pad_action_label (MetaDisplay        *display,
+                                   ClutterInputDevice *pad,
+                                   MetaPadActionType   action_type,
+                                   guint               action_number)
+{
+  gchar *label;
+
+  /* First, lookup the action, as imposed by settings */
+  if (action_type == META_PAD_ACTION_BUTTON)
+    {
+      MetaInputSettings *settings;
+
+      settings = meta_input_settings_get ();
+      label = meta_input_settings_get_pad_button_action_label (settings, pad, action_number);
+      if (label)
+        return label;
+    }
+
+#ifdef HAVE_WAYLAND
+  /* Second, if this wayland, lookup the actions set by the clients */
+  if (meta_is_wayland_compositor ())
+    {
+      MetaWaylandCompositor *compositor;
+      MetaWaylandTabletSeat *tablet_seat;
+      MetaWaylandTabletPad *tablet_pad = NULL;
+
+      compositor = meta_wayland_compositor_get_default ();
+      tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager,
+                                                             compositor->seat);
+      if (tablet_seat)
+        tablet_pad = meta_wayland_tablet_seat_lookup_pad (tablet_seat, pad);
+
+      if (tablet_pad)
+        {
+          label = meta_wayland_tablet_pad_get_label (tablet_pad, action_type,
+                                                     action_number);
+        }
+
+      if (label)
+        return label;
+    }
+#endif
+
+  return NULL;
+}
diff --git a/src/meta/display.h b/src/meta/display.h
index ea86d99..e6d8ba9 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -188,4 +188,9 @@ void meta_display_unfreeze_keyboard (MetaDisplay *display,
 gboolean meta_display_is_pointer_emulating_sequence (MetaDisplay          *display,
                                                      ClutterEventSequence *sequence);
 
+gchar * meta_display_get_pad_action_label (MetaDisplay        *display,
+                                           ClutterInputDevice *pad,
+                                           MetaPadActionType   action_type,
+                                           guint               action_number);
+
 #endif


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