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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
This commit is contained in:
Carlos Garnacho 2023-05-16 15:48:34 +02:00 committed by Marge Bot
parent b6a6e9f187
commit 2da9b67673
2 changed files with 59 additions and 30 deletions

View File

@ -2733,27 +2733,16 @@ meta_display_request_pad_osd (MetaDisplay *display,
} }
} }
gchar * char *
meta_display_get_pad_action_label (MetaDisplay *display, meta_display_get_pad_button_label (MetaDisplay *display,
ClutterInputDevice *pad, ClutterInputDevice *pad,
MetaPadFeatureType feature, int button)
guint action_number)
{ {
char *label; char *label;
/* First, lookup the action, as imposed by settings */ /* 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, label = meta_pad_action_mapper_get_button_label (display->pad_action_mapper,
pad, action_number); pad, button);
}
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;
@ -2772,18 +2761,53 @@ meta_display_get_pad_action_label (MetaDisplay *display,
tablet_pad = meta_wayland_tablet_seat_lookup_pad (tablet_seat, pad); tablet_pad = meta_wayland_tablet_seat_lookup_pad (tablet_seat, pad);
if (tablet_pad) if (tablet_pad)
{
if (feature == META_PAD_FEATURE_BUTTON)
{ {
label = meta_wayland_tablet_pad_get_button_label (tablet_pad, label = meta_wayland_tablet_pad_get_button_label (tablet_pad,
action_number); button);
} }
else
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, label = meta_wayland_tablet_pad_get_feature_label (tablet_pad,
feature, feature,
action_number); feature_number);
}
} }
if (label) if (label)

View File

@ -193,10 +193,15 @@ void meta_display_request_pad_osd (MetaDisplay *display,
gboolean edition_mode); gboolean edition_mode);
META_EXPORT META_EXPORT
gchar * meta_display_get_pad_action_label (MetaDisplay *display, char * meta_display_get_pad_button_label (MetaDisplay *display,
ClutterInputDevice *pad, ClutterInputDevice *pad,
MetaPadFeatureType feature_type, int button_number);
guint action_number);
META_EXPORT
char * meta_display_get_pad_feature_label (MetaDisplay *display,
ClutterInputDevice *pad,
MetaPadFeatureType feature,
int feature_number);
META_EXPORT META_EXPORT
void meta_display_get_size (MetaDisplay *display, void meta_display_get_size (MetaDisplay *display,