From b6a6e9f187ffe7bea777552096bd1e75572ed904 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 16 May 2023 15:40:35 +0200 Subject: [PATCH] core: Separate MetaPadActionMapper pad button labeling This will be handled separately in future commits. Part-of: --- src/core/display.c | 17 +++++++++++++---- src/core/meta-pad-action-mapper.c | 21 +++++++++++---------- src/core/meta-pad-action-mapper.h | 13 +++++++++---- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/core/display.c b/src/core/display.c index 1482ed0f9..363fd0962 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -2739,12 +2739,21 @@ meta_display_get_pad_action_label (MetaDisplay *display, MetaPadFeatureType feature, guint action_number) { - gchar *label; + char *label; /* First, lookup the action, as imposed by settings */ - label = meta_pad_action_mapper_get_action_label (display->pad_action_mapper, - pad, feature, - action_number); + 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); + } + if (label) return label; diff --git a/src/core/meta-pad-action-mapper.c b/src/core/meta-pad-action-mapper.c index 1a0232cc9..c1d997bf5 100644 --- a/src/core/meta-pad-action-mapper.c +++ b/src/core/meta-pad-action-mapper.c @@ -838,10 +838,10 @@ meta_pad_action_mapper_get_strip_label (MetaPadActionMapper *mapper, return label; } -static char * +char * meta_pad_action_mapper_get_button_label (MetaPadActionMapper *mapper, - ClutterInputDevice *pad, - guint button) + ClutterInputDevice *pad, + int button) { GDesktopPadButtonAction action; int group; @@ -916,23 +916,24 @@ get_current_pad_mode (MetaPadActionMapper *mapper, } char * -meta_pad_action_mapper_get_action_label (MetaPadActionMapper *mapper, - ClutterInputDevice *pad, - MetaPadFeatureType feature, - guint number) +meta_pad_action_mapper_get_feature_label (MetaPadActionMapper *mapper, + ClutterInputDevice *pad, + MetaPadFeatureType feature, + int number) { - guint mode; + unsigned int mode; switch (feature) { - case META_PAD_FEATURE_BUTTON: - return meta_pad_action_mapper_get_button_label (mapper, pad, number); case META_PAD_FEATURE_RING: mode = get_current_pad_mode (mapper, pad, feature, number); return meta_pad_action_mapper_get_ring_label (mapper, pad, number, mode); case META_PAD_FEATURE_STRIP: mode = get_current_pad_mode (mapper, pad, feature, number); return meta_pad_action_mapper_get_strip_label (mapper, pad, number, mode); + default: + g_assert_not_reached (); + break; } return NULL; diff --git a/src/core/meta-pad-action-mapper.h b/src/core/meta-pad-action-mapper.h index 642d4e82a..4a1873752 100644 --- a/src/core/meta-pad-action-mapper.h +++ b/src/core/meta-pad-action-mapper.h @@ -38,9 +38,14 @@ gboolean meta_pad_action_mapper_is_button_grabbed (MetaPadActionMapper *mapper, guint button); gboolean meta_pad_action_mapper_handle_event (MetaPadActionMapper *mapper, const ClutterEvent *event); -gchar * meta_pad_action_mapper_get_action_label (MetaPadActionMapper *mapper, - ClutterInputDevice *pad, - MetaPadFeatureType feature, - guint number); + +char * meta_pad_action_mapper_get_button_label (MetaPadActionMapper *mapper, + ClutterInputDevice *pad, + int button); + +char * meta_pad_action_mapper_get_feature_label (MetaPadActionMapper *mapper, + ClutterInputDevice *pad, + MetaPadFeatureType feature, + int number); #endif /* META_PAD_ACTION_MAPPER_H */