From 85ac3a2d1accc812abbc3dae84ee7693414404e6 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 16 May 2023 15:35:15 +0200 Subject: [PATCH] wayland: Separate pad button labeling from other pad features This will be fully split in future commits. Part-of: --- src/core/display.c | 13 ++++++++-- src/wayland/meta-wayland-tablet-pad.c | 36 +++++++++++++++++---------- src/wayland/meta-wayland-tablet-pad.h | 9 ++++--- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/core/display.c b/src/core/display.c index e8c8a1d3c..1482ed0f9 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -2764,8 +2764,17 @@ meta_display_get_pad_action_label (MetaDisplay *display, if (tablet_pad) { - label = meta_wayland_tablet_pad_get_label (tablet_pad, feature, - action_number); + 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); + } } if (label) diff --git a/src/wayland/meta-wayland-tablet-pad.c b/src/wayland/meta-wayland-tablet-pad.c index cafd76cba..11957acd7 100644 --- a/src/wayland/meta-wayland-tablet-pad.c +++ b/src/wayland/meta-wayland-tablet-pad.c @@ -533,23 +533,30 @@ meta_wayland_tablet_pad_label_mode_switch_button (MetaWaylandTabletPad *pad, return NULL; } -gchar * -meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad, - MetaPadFeatureType feature, - guint action) +char * +meta_wayland_tablet_pad_get_button_label (MetaWaylandTabletPad *pad, + int button) { - const gchar *label = NULL; - gchar *mode_label; + const char *label = NULL; + char *mode_label; + + mode_label = meta_wayland_tablet_pad_label_mode_switch_button (pad, button); + if (mode_label) + return mode_label; + + label = g_hash_table_lookup (pad->feedback, GUINT_TO_POINTER (button)); + return g_strdup (label); +} + +char * +meta_wayland_tablet_pad_get_feature_label (MetaWaylandTabletPad *pad, + MetaPadFeatureType feature, + int action) +{ + const char *label = NULL; switch (feature) { - case META_PAD_FEATURE_BUTTON: - mode_label = meta_wayland_tablet_pad_label_mode_switch_button (pad, action); - if (mode_label) - return mode_label; - - label = g_hash_table_lookup (pad->feedback, GUINT_TO_POINTER (action)); - break; case META_PAD_FEATURE_RING: { MetaWaylandTabletPadRing *ring; @@ -568,6 +575,9 @@ meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad, label = strip->feedback; break; } + default: + g_assert_not_reached (); + break; } return g_strdup (label); diff --git a/src/wayland/meta-wayland-tablet-pad.h b/src/wayland/meta-wayland-tablet-pad.h index aaa39dc34..4b1f9e261 100644 --- a/src/wayland/meta-wayland-tablet-pad.h +++ b/src/wayland/meta-wayland-tablet-pad.h @@ -74,8 +74,11 @@ gboolean meta_wayland_tablet_pad_handle_event (MetaWaylandTabletPad * void meta_wayland_tablet_pad_set_focus (MetaWaylandTabletPad *pad, MetaWaylandSurface *surface); -gchar * meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad, - MetaPadFeatureType feature, - guint action); +char * meta_wayland_tablet_pad_get_button_label (MetaWaylandTabletPad *pad, + int button); + +char * meta_wayland_tablet_pad_get_feature_label (MetaWaylandTabletPad *pad, + MetaPadFeatureType feature, + int action); #endif /* META_WAYLAND_TABLET_PAD_H */