core: Separate MetaPadActionMapper pad button labeling

This will be handled separately in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
This commit is contained in:
Carlos Garnacho 2023-05-16 15:40:35 +02:00 committed by Marge Bot
parent 85ac3a2d1a
commit b6a6e9f187
3 changed files with 33 additions and 18 deletions

View File

@ -2739,12 +2739,21 @@ meta_display_get_pad_action_label (MetaDisplay *display,
MetaPadFeatureType feature, MetaPadFeatureType feature,
guint action_number) guint action_number)
{ {
gchar *label; char *label;
/* First, lookup the action, as imposed by settings */ /* First, lookup the action, as imposed by settings */
label = meta_pad_action_mapper_get_action_label (display->pad_action_mapper, if (feature == META_PAD_FEATURE_BUTTON)
pad, feature, {
action_number); 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) if (label)
return label; return label;

View File

@ -838,10 +838,10 @@ meta_pad_action_mapper_get_strip_label (MetaPadActionMapper *mapper,
return label; return label;
} }
static char * char *
meta_pad_action_mapper_get_button_label (MetaPadActionMapper *mapper, meta_pad_action_mapper_get_button_label (MetaPadActionMapper *mapper,
ClutterInputDevice *pad, ClutterInputDevice *pad,
guint button) int button)
{ {
GDesktopPadButtonAction action; GDesktopPadButtonAction action;
int group; int group;
@ -916,23 +916,24 @@ get_current_pad_mode (MetaPadActionMapper *mapper,
} }
char * char *
meta_pad_action_mapper_get_action_label (MetaPadActionMapper *mapper, meta_pad_action_mapper_get_feature_label (MetaPadActionMapper *mapper,
ClutterInputDevice *pad, ClutterInputDevice *pad,
MetaPadFeatureType feature, MetaPadFeatureType feature,
guint number) int number)
{ {
guint mode; unsigned int mode;
switch (feature) switch (feature)
{ {
case META_PAD_FEATURE_BUTTON:
return meta_pad_action_mapper_get_button_label (mapper, pad, number);
case META_PAD_FEATURE_RING: case META_PAD_FEATURE_RING:
mode = get_current_pad_mode (mapper, pad, feature, number); mode = get_current_pad_mode (mapper, pad, feature, number);
return meta_pad_action_mapper_get_ring_label (mapper, pad, number, mode); return meta_pad_action_mapper_get_ring_label (mapper, pad, number, mode);
case META_PAD_FEATURE_STRIP: case META_PAD_FEATURE_STRIP:
mode = get_current_pad_mode (mapper, pad, feature, number); mode = get_current_pad_mode (mapper, pad, feature, number);
return meta_pad_action_mapper_get_strip_label (mapper, pad, number, mode); return meta_pad_action_mapper_get_strip_label (mapper, pad, number, mode);
default:
g_assert_not_reached ();
break;
} }
return NULL; return NULL;

View File

@ -38,9 +38,14 @@ gboolean meta_pad_action_mapper_is_button_grabbed (MetaPadActionMapper *mapper,
guint button); guint button);
gboolean meta_pad_action_mapper_handle_event (MetaPadActionMapper *mapper, gboolean meta_pad_action_mapper_handle_event (MetaPadActionMapper *mapper,
const ClutterEvent *event); const ClutterEvent *event);
gchar * meta_pad_action_mapper_get_action_label (MetaPadActionMapper *mapper,
ClutterInputDevice *pad, char * meta_pad_action_mapper_get_button_label (MetaPadActionMapper *mapper,
MetaPadFeatureType feature, ClutterInputDevice *pad,
guint number); int button);
char * meta_pad_action_mapper_get_feature_label (MetaPadActionMapper *mapper,
ClutterInputDevice *pad,
MetaPadFeatureType feature,
int number);
#endif /* META_PAD_ACTION_MAPPER_H */ #endif /* META_PAD_ACTION_MAPPER_H */