From 2da9b676730a21a137f3f6095b7ced00c08f12be Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 16 May 2023 15:48:34 +0200 Subject: [PATCH] core: Separate pad button labels in high-level MetaDisplay API These "features" are somewhat less featured, it's becoming too ugly to handle all of them with a single API call. The clear outlier are buttons, so move them to a separate function. Part-of: --- src/core/display.c | 78 ++++++++++++++++++++++++++++++---------------- src/meta/display.h | 11 +++++-- 2 files changed, 59 insertions(+), 30 deletions(-) diff --git a/src/core/display.c b/src/core/display.c index 363fd0962..a14e25252 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -2733,27 +2733,16 @@ meta_display_request_pad_osd (MetaDisplay *display, } } -gchar * -meta_display_get_pad_action_label (MetaDisplay *display, +char * +meta_display_get_pad_button_label (MetaDisplay *display, ClutterInputDevice *pad, - MetaPadFeatureType feature, - guint action_number) + int button) { char *label; /* First, lookup the action, as imposed by settings */ - if (feature == META_PAD_FEATURE_BUTTON) - { - label = meta_pad_action_mapper_get_button_label (display->pad_action_mapper, - pad, action_number); - } - else - { - label = meta_pad_action_mapper_get_feature_label (display->pad_action_mapper, - pad, feature, - action_number); - } - + label = meta_pad_action_mapper_get_button_label (display->pad_action_mapper, + pad, button); if (label) return label; @@ -2773,17 +2762,52 @@ meta_display_get_pad_action_label (MetaDisplay *display, if (tablet_pad) { - if (feature == META_PAD_FEATURE_BUTTON) - { - label = meta_wayland_tablet_pad_get_button_label (tablet_pad, - action_number); - } - else - { - label = meta_wayland_tablet_pad_get_feature_label (tablet_pad, - feature, - action_number); - } + label = meta_wayland_tablet_pad_get_button_label (tablet_pad, + button); + } + + if (label) + return label; + } +#endif + + return NULL; +} + +char * +meta_display_get_pad_feature_label (MetaDisplay *display, + ClutterInputDevice *pad, + MetaPadFeatureType feature, + int feature_number) +{ + char *label; + + /* First, lookup the action, as imposed by settings */ + label = meta_pad_action_mapper_get_feature_label (display->pad_action_mapper, + pad, feature, + feature_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 = wayland_compositor_from_display (display); + 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_feature_label (tablet_pad, + feature, + feature_number); } if (label) diff --git a/src/meta/display.h b/src/meta/display.h index 10e3e1400..91db8683c 100644 --- a/src/meta/display.h +++ b/src/meta/display.h @@ -193,10 +193,15 @@ void meta_display_request_pad_osd (MetaDisplay *display, gboolean edition_mode); META_EXPORT -gchar * meta_display_get_pad_action_label (MetaDisplay *display, +char * meta_display_get_pad_button_label (MetaDisplay *display, + ClutterInputDevice *pad, + int button_number); + +META_EXPORT +char * meta_display_get_pad_feature_label (MetaDisplay *display, ClutterInputDevice *pad, - MetaPadFeatureType feature_type, - guint action_number); + MetaPadFeatureType feature, + int feature_number); META_EXPORT void meta_display_get_size (MetaDisplay *display,