diff --git a/src/core/display.c b/src/core/display.c index c047297f8..009944c74 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 #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 /* @@ -3070,3 +3073,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_backend_get_input_settings (meta_get_backend ()); + 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 ea86d99e9..e6d8ba9f1 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