core: Rename MetaPadActionType to MetaPadFeatureType

We want to separate pad buttons from strips and rings for
purposes of labeling. Start by renaming the enum "features"
to use a less englobing word.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
This commit is contained in:
Carlos Garnacho 2023-05-16 11:24:21 +02:00 committed by Marge Bot
parent 112cca75e2
commit 233e612ef8
6 changed files with 54 additions and 54 deletions

View File

@ -2736,14 +2736,14 @@ meta_display_request_pad_osd (MetaDisplay *display,
gchar * gchar *
meta_display_get_pad_action_label (MetaDisplay *display, meta_display_get_pad_action_label (MetaDisplay *display,
ClutterInputDevice *pad, ClutterInputDevice *pad,
MetaPadActionType action_type, MetaPadFeatureType feature,
guint action_number) guint action_number)
{ {
gchar *label; gchar *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, label = meta_pad_action_mapper_get_action_label (display->pad_action_mapper,
pad, action_type, pad, feature,
action_number); action_number);
if (label) if (label)
return label; return label;
@ -2764,7 +2764,7 @@ meta_display_get_pad_action_label (MetaDisplay *display,
if (tablet_pad) if (tablet_pad)
{ {
label = meta_wayland_tablet_pad_get_label (tablet_pad, action_type, label = meta_wayland_tablet_pad_get_label (tablet_pad, feature,
action_number); action_number);
} }

View File

@ -65,7 +65,7 @@ struct _MetaPadActionMapper
/* Pad ring/strip emission */ /* Pad ring/strip emission */
struct { struct {
ClutterInputDevice *pad; ClutterInputDevice *pad;
MetaPadActionType action; MetaPadFeatureType feature;
guint number; guint number;
double value; double value;
} last_pad_action_info; } last_pad_action_info;
@ -193,7 +193,7 @@ meta_pad_action_mapper_new (MetaMonitorManager *monitor_manager)
static GSettings * static GSettings *
lookup_pad_action_settings (ClutterInputDevice *device, lookup_pad_action_settings (ClutterInputDevice *device,
MetaPadActionType action, MetaPadFeatureType feature,
guint number, guint number,
MetaPadDirection direction, MetaPadDirection direction,
int mode) int mode)
@ -208,18 +208,18 @@ lookup_pad_action_settings (ClutterInputDevice *device,
action_label = 'A' + number; action_label = 'A' + number;
switch (action) switch (feature)
{ {
case META_PAD_ACTION_BUTTON: case META_PAD_FEATURE_BUTTON:
action_type = "button"; action_type = "button";
break; break;
case META_PAD_ACTION_RING: case META_PAD_FEATURE_RING:
g_assert (direction == META_PAD_DIRECTION_CW || g_assert (direction == META_PAD_DIRECTION_CW ||
direction == META_PAD_DIRECTION_CCW); direction == META_PAD_DIRECTION_CCW);
action_type = "ring"; action_type = "ring";
detail_type = (direction == META_PAD_DIRECTION_CW) ? "cw" : "ccw"; detail_type = (direction == META_PAD_DIRECTION_CW) ? "cw" : "ccw";
break; break;
case META_PAD_ACTION_STRIP: case META_PAD_FEATURE_STRIP:
g_assert (direction == META_PAD_DIRECTION_UP || g_assert (direction == META_PAD_DIRECTION_UP ||
direction == META_PAD_DIRECTION_DOWN); direction == META_PAD_DIRECTION_DOWN);
action_type = "strip"; action_type = "strip";
@ -261,7 +261,7 @@ meta_pad_action_mapper_get_button_action (MetaPadActionMapper *mapper,
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (pad), g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (pad),
G_DESKTOP_PAD_BUTTON_ACTION_NONE); G_DESKTOP_PAD_BUTTON_ACTION_NONE);
settings = lookup_pad_action_settings (pad, META_PAD_ACTION_BUTTON, settings = lookup_pad_action_settings (pad, META_PAD_FEATURE_BUTTON,
button, META_PAD_DIRECTION_NONE, -1); button, META_PAD_DIRECTION_NONE, -1);
action = g_settings_get_enum (settings, "action"); action = g_settings_get_enum (settings, "action");
g_object_unref (settings); g_object_unref (settings);
@ -589,7 +589,7 @@ meta_pad_action_mapper_handle_button (MetaPadActionMapper *mapper,
meta_display_request_pad_osd (display_from_mapper (mapper), pad, FALSE); meta_display_request_pad_osd (display_from_mapper (mapper), pad, FALSE);
return TRUE; return TRUE;
case G_DESKTOP_PAD_BUTTON_ACTION_KEYBINDING: case G_DESKTOP_PAD_BUTTON_ACTION_KEYBINDING:
settings = lookup_pad_action_settings (pad, META_PAD_ACTION_BUTTON, settings = lookup_pad_action_settings (pad, META_PAD_FEATURE_BUTTON,
button, META_PAD_DIRECTION_NONE, -1); button, META_PAD_DIRECTION_NONE, -1);
accel = g_settings_get_string (settings, "keybinding"); accel = g_settings_get_string (settings, "keybinding");
meta_pad_action_mapper_emulate_keybinding (mapper, accel, is_press); meta_pad_action_mapper_emulate_keybinding (mapper, accel, is_press);
@ -608,7 +608,7 @@ meta_pad_action_mapper_get_action_direction (MetaPadActionMapper *mapper,
MetaPadDirection *direction) MetaPadDirection *direction)
{ {
ClutterInputDevice *pad = clutter_event_get_device (event); ClutterInputDevice *pad = clutter_event_get_device (event);
MetaPadActionType pad_action; MetaPadFeatureType pad_feature;
gboolean has_direction = FALSE; gboolean has_direction = FALSE;
MetaPadDirection inc_dir, dec_dir; MetaPadDirection inc_dir, dec_dir;
guint number; guint number;
@ -619,14 +619,14 @@ meta_pad_action_mapper_get_action_direction (MetaPadActionMapper *mapper,
switch (event->type) switch (event->type)
{ {
case CLUTTER_PAD_RING: case CLUTTER_PAD_RING:
pad_action = META_PAD_ACTION_RING; pad_feature = META_PAD_FEATURE_RING;
number = event->pad_ring.ring_number; number = event->pad_ring.ring_number;
value = event->pad_ring.angle; value = event->pad_ring.angle;
inc_dir = META_PAD_DIRECTION_CW; inc_dir = META_PAD_DIRECTION_CW;
dec_dir = META_PAD_DIRECTION_CCW; dec_dir = META_PAD_DIRECTION_CCW;
break; break;
case CLUTTER_PAD_STRIP: case CLUTTER_PAD_STRIP:
pad_action = META_PAD_ACTION_STRIP; pad_feature = META_PAD_FEATURE_STRIP;
number = event->pad_strip.strip_number; number = event->pad_strip.strip_number;
value = event->pad_strip.value; value = event->pad_strip.value;
inc_dir = META_PAD_DIRECTION_DOWN; inc_dir = META_PAD_DIRECTION_DOWN;
@ -637,7 +637,7 @@ meta_pad_action_mapper_get_action_direction (MetaPadActionMapper *mapper,
} }
if (mapper->last_pad_action_info.pad == pad && if (mapper->last_pad_action_info.pad == pad &&
mapper->last_pad_action_info.action == pad_action && mapper->last_pad_action_info.feature == pad_feature &&
mapper->last_pad_action_info.number == number && mapper->last_pad_action_info.number == number &&
value >= 0 && mapper->last_pad_action_info.value >= 0) value >= 0 && mapper->last_pad_action_info.value >= 0)
{ {
@ -647,7 +647,7 @@ meta_pad_action_mapper_get_action_direction (MetaPadActionMapper *mapper,
} }
mapper->last_pad_action_info.pad = pad; mapper->last_pad_action_info.pad = pad;
mapper->last_pad_action_info.action = pad_action; mapper->last_pad_action_info.feature = pad_feature;
mapper->last_pad_action_info.number = number; mapper->last_pad_action_info.number = number;
mapper->last_pad_action_info.value = value; mapper->last_pad_action_info.value = value;
return has_direction; return has_direction;
@ -657,7 +657,7 @@ static gboolean
meta_pad_action_mapper_handle_action (MetaPadActionMapper *mapper, meta_pad_action_mapper_handle_action (MetaPadActionMapper *mapper,
ClutterInputDevice *pad, ClutterInputDevice *pad,
const ClutterEvent *event, const ClutterEvent *event,
MetaPadActionType action, MetaPadFeatureType feature,
guint number, guint number,
guint mode) guint mode)
{ {
@ -666,18 +666,18 @@ meta_pad_action_mapper_handle_action (MetaPadActionMapper *mapper,
g_autofree char *accel1 = NULL, *accel2 = NULL; g_autofree char *accel1 = NULL, *accel2 = NULL;
gboolean handled; gboolean handled;
if (action == META_PAD_ACTION_RING) if (feature == META_PAD_FEATURE_RING)
{ {
settings1 = lookup_pad_action_settings (pad, action, number, settings1 = lookup_pad_action_settings (pad, feature, number,
META_PAD_DIRECTION_CW, mode); META_PAD_DIRECTION_CW, mode);
settings2 = lookup_pad_action_settings (pad, action, number, settings2 = lookup_pad_action_settings (pad, feature, number,
META_PAD_DIRECTION_CCW, mode); META_PAD_DIRECTION_CCW, mode);
} }
else if (action == META_PAD_ACTION_STRIP) else if (feature == META_PAD_FEATURE_STRIP)
{ {
settings1 = lookup_pad_action_settings (pad, action, number, settings1 = lookup_pad_action_settings (pad, feature, number,
META_PAD_DIRECTION_UP, mode); META_PAD_DIRECTION_UP, mode);
settings2 = lookup_pad_action_settings (pad, action, number, settings2 = lookup_pad_action_settings (pad, feature, number,
META_PAD_DIRECTION_DOWN, mode); META_PAD_DIRECTION_DOWN, mode);
} }
else else
@ -726,12 +726,12 @@ meta_pad_action_mapper_handle_event (MetaPadActionMapper *mapper,
&event->pad_button); &event->pad_button);
case CLUTTER_PAD_RING: case CLUTTER_PAD_RING:
return meta_pad_action_mapper_handle_action (mapper, pad, event, return meta_pad_action_mapper_handle_action (mapper, pad, event,
META_PAD_ACTION_RING, META_PAD_FEATURE_RING,
event->pad_ring.ring_number, event->pad_ring.ring_number,
event->pad_ring.mode); event->pad_ring.mode);
case CLUTTER_PAD_STRIP: case CLUTTER_PAD_STRIP:
return meta_pad_action_mapper_handle_action (mapper, pad, event, return meta_pad_action_mapper_handle_action (mapper, pad, event,
META_PAD_ACTION_STRIP, META_PAD_FEATURE_STRIP,
event->pad_strip.strip_number, event->pad_strip.strip_number,
event->pad_strip.mode); event->pad_strip.mode);
default: default:
@ -804,9 +804,9 @@ meta_pad_action_mapper_get_ring_label (MetaPadActionMapper *mapper,
char *label; char *label;
/* We only allow keybinding actions with those */ /* We only allow keybinding actions with those */
settings1 = lookup_pad_action_settings (pad, META_PAD_ACTION_RING, number, settings1 = lookup_pad_action_settings (pad, META_PAD_FEATURE_RING, number,
META_PAD_DIRECTION_CW, mode); META_PAD_DIRECTION_CW, mode);
settings2 = lookup_pad_action_settings (pad, META_PAD_ACTION_RING, number, settings2 = lookup_pad_action_settings (pad, META_PAD_FEATURE_RING, number,
META_PAD_DIRECTION_CCW, mode); META_PAD_DIRECTION_CCW, mode);
label = compose_directional_action_label (META_PAD_DIRECTION_CW, settings1, label = compose_directional_action_label (META_PAD_DIRECTION_CW, settings1,
META_PAD_DIRECTION_CCW, settings2); META_PAD_DIRECTION_CCW, settings2);
@ -826,9 +826,9 @@ meta_pad_action_mapper_get_strip_label (MetaPadActionMapper *mapper,
char *label; char *label;
/* We only allow keybinding actions with those */ /* We only allow keybinding actions with those */
settings1 = lookup_pad_action_settings (pad, META_PAD_ACTION_STRIP, number, settings1 = lookup_pad_action_settings (pad, META_PAD_FEATURE_STRIP, number,
META_PAD_DIRECTION_UP, mode); META_PAD_DIRECTION_UP, mode);
settings2 = lookup_pad_action_settings (pad, META_PAD_ACTION_STRIP, number, settings2 = lookup_pad_action_settings (pad, META_PAD_FEATURE_STRIP, number,
META_PAD_DIRECTION_DOWN, mode); META_PAD_DIRECTION_DOWN, mode);
label = compose_directional_action_label (META_PAD_DIRECTION_UP, settings1, label = compose_directional_action_label (META_PAD_DIRECTION_UP, settings1,
META_PAD_DIRECTION_DOWN, settings2); META_PAD_DIRECTION_DOWN, settings2);
@ -870,7 +870,7 @@ meta_pad_action_mapper_get_button_label (MetaPadActionMapper *mapper,
GSettings *settings; GSettings *settings;
char *accel; char *accel;
settings = lookup_pad_action_settings (pad, META_PAD_ACTION_BUTTON, settings = lookup_pad_action_settings (pad, META_PAD_FEATURE_BUTTON,
button, META_PAD_DIRECTION_NONE, -1); button, META_PAD_DIRECTION_NONE, -1);
accel = g_settings_get_string (settings, "keybinding"); accel = g_settings_get_string (settings, "keybinding");
g_object_unref (settings); g_object_unref (settings);
@ -893,7 +893,7 @@ meta_pad_action_mapper_get_button_label (MetaPadActionMapper *mapper,
static guint static guint
get_current_pad_mode (MetaPadActionMapper *mapper, get_current_pad_mode (MetaPadActionMapper *mapper,
ClutterInputDevice *pad, ClutterInputDevice *pad,
MetaPadActionType action_type, MetaPadFeatureType feature,
guint number) guint number)
{ {
PadMappingInfo *info; PadMappingInfo *info;
@ -905,8 +905,8 @@ get_current_pad_mode (MetaPadActionMapper *mapper,
if (!info->group_modes || n_groups == 0) if (!info->group_modes || n_groups == 0)
return 0; return 0;
if (action_type == META_PAD_ACTION_RING || if (feature == META_PAD_FEATURE_RING ||
action_type == META_PAD_ACTION_STRIP) feature == META_PAD_FEATURE_STRIP)
{ {
/* Assume features are evenly distributed in groups */ /* Assume features are evenly distributed in groups */
group = number % n_groups; group = number % n_groups;
@ -918,20 +918,20 @@ get_current_pad_mode (MetaPadActionMapper *mapper,
char * char *
meta_pad_action_mapper_get_action_label (MetaPadActionMapper *mapper, meta_pad_action_mapper_get_action_label (MetaPadActionMapper *mapper,
ClutterInputDevice *pad, ClutterInputDevice *pad,
MetaPadActionType action_type, MetaPadFeatureType feature,
guint number) guint number)
{ {
guint mode; guint mode;
switch (action_type) switch (feature)
{ {
case META_PAD_ACTION_BUTTON: case META_PAD_FEATURE_BUTTON:
return meta_pad_action_mapper_get_button_label (mapper, pad, number); return meta_pad_action_mapper_get_button_label (mapper, pad, number);
case META_PAD_ACTION_RING: case META_PAD_FEATURE_RING:
mode = get_current_pad_mode (mapper, pad, action_type, 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_ACTION_STRIP: case META_PAD_FEATURE_STRIP:
mode = get_current_pad_mode (mapper, pad, action_type, 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);
} }

View File

@ -40,7 +40,7 @@ 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, gchar * meta_pad_action_mapper_get_action_label (MetaPadActionMapper *mapper,
ClutterInputDevice *pad, ClutterInputDevice *pad,
MetaPadActionType action, MetaPadFeatureType feature,
guint number); guint number);
#endif /* META_PAD_ACTION_MAPPER_H */ #endif /* META_PAD_ACTION_MAPPER_H */

View File

@ -58,10 +58,10 @@ typedef enum
typedef enum typedef enum
{ {
META_PAD_ACTION_BUTTON, /* Action is a button */ META_PAD_FEATURE_BUTTON,
META_PAD_ACTION_RING, /* Action is a ring */ META_PAD_FEATURE_RING,
META_PAD_ACTION_STRIP, /* Action is a strip */ META_PAD_FEATURE_STRIP,
} MetaPadActionType; } MetaPadFeatureType;
typedef struct _MetaDisplayClass MetaDisplayClass; typedef struct _MetaDisplayClass MetaDisplayClass;
@ -195,7 +195,7 @@ void meta_display_request_pad_osd (MetaDisplay *display,
META_EXPORT META_EXPORT
gchar * meta_display_get_pad_action_label (MetaDisplay *display, gchar * meta_display_get_pad_action_label (MetaDisplay *display,
ClutterInputDevice *pad, ClutterInputDevice *pad,
MetaPadActionType action_type, MetaPadFeatureType feature_type,
guint action_number); guint action_number);
META_EXPORT META_EXPORT

View File

@ -535,22 +535,22 @@ meta_wayland_tablet_pad_label_mode_switch_button (MetaWaylandTabletPad *pad,
gchar * gchar *
meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad, meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad,
MetaPadActionType type, MetaPadFeatureType feature,
guint action) guint action)
{ {
const gchar *label = NULL; const gchar *label = NULL;
gchar *mode_label; gchar *mode_label;
switch (type) switch (feature)
{ {
case META_PAD_ACTION_BUTTON: case META_PAD_FEATURE_BUTTON:
mode_label = meta_wayland_tablet_pad_label_mode_switch_button (pad, action); mode_label = meta_wayland_tablet_pad_label_mode_switch_button (pad, action);
if (mode_label) if (mode_label)
return mode_label; return mode_label;
label = g_hash_table_lookup (pad->feedback, GUINT_TO_POINTER (action)); label = g_hash_table_lookup (pad->feedback, GUINT_TO_POINTER (action));
break; break;
case META_PAD_ACTION_RING: case META_PAD_FEATURE_RING:
{ {
MetaWaylandTabletPadRing *ring; MetaWaylandTabletPadRing *ring;
@ -559,7 +559,7 @@ meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad,
label = ring->feedback; label = ring->feedback;
break; break;
} }
case META_PAD_ACTION_STRIP: case META_PAD_FEATURE_STRIP:
{ {
MetaWaylandTabletPadStrip *strip; MetaWaylandTabletPadStrip *strip;

View File

@ -75,7 +75,7 @@ void meta_wayland_tablet_pad_set_focus (MetaWaylandTabletPad *
MetaWaylandSurface *surface); MetaWaylandSurface *surface);
gchar * meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad, gchar * meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad,
MetaPadActionType type, MetaPadFeatureType feature,
guint action); guint action);
#endif /* META_WAYLAND_TABLET_PAD_H */ #endif /* META_WAYLAND_TABLET_PAD_H */