core: Mark both directions in rings/strips as (un)handled altogether
If going on a direction has a keycombo associated and the other does not, it does not make sense to let the wayland bits handle pad ring/strip events that only go in one direction. Ensure that's the case, and also while figuring out the ring/strip direction based on the initial events. Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1886 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2001>
This commit is contained in:
parent
952caf6b71
commit
1ad98879b7
@ -640,27 +640,51 @@ meta_pad_action_mapper_handle_action (MetaPadActionMapper *mapper,
|
||||
guint number,
|
||||
guint mode)
|
||||
{
|
||||
MetaPadDirection direction = = META_PAD_DIRECTION_NONE;
|
||||
GSettings *settings;
|
||||
gboolean handled = FALSE;
|
||||
char *accel;
|
||||
MetaPadDirection direction = META_PAD_DIRECTION_NONE;
|
||||
g_autoptr (GSettings) settings1 = NULL, settings2 = NULL;
|
||||
g_autofree char *accel1, *accel2;
|
||||
gboolean handled;
|
||||
|
||||
if (!meta_pad_action_mapper_get_action_direction (mapper,
|
||||
event, &direction))
|
||||
return FALSE;
|
||||
|
||||
settings = lookup_pad_action_settings (pad, action, number, direction, mode);
|
||||
accel = g_settings_get_string (settings, "keybinding");
|
||||
|
||||
if (accel && *accel)
|
||||
if (action == META_PAD_ACTION_RING)
|
||||
{
|
||||
meta_pad_action_mapper_emulate_keybinding (mapper, accel, TRUE);
|
||||
meta_pad_action_mapper_emulate_keybinding (mapper, accel, FALSE);
|
||||
handled = TRUE;
|
||||
settings1 = lookup_pad_action_settings (pad, action, number,
|
||||
META_PAD_DIRECTION_CW, mode);
|
||||
settings2 = lookup_pad_action_settings (pad, action, number,
|
||||
META_PAD_DIRECTION_CCW, mode);
|
||||
}
|
||||
else if (action == META_PAD_ACTION_STRIP)
|
||||
{
|
||||
settings1 = lookup_pad_action_settings (pad, action, number,
|
||||
META_PAD_DIRECTION_UP, mode);
|
||||
settings2 = lookup_pad_action_settings (pad, action, number,
|
||||
META_PAD_DIRECTION_DOWN, mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_object_unref (settings);
|
||||
g_free (accel);
|
||||
accel1 = g_settings_get_string (settings1, "keybinding");
|
||||
accel2 = g_settings_get_string (settings2, "keybinding");
|
||||
handled = ((accel1 && *accel1) || (accel2 && *accel2));
|
||||
|
||||
if (meta_pad_action_mapper_get_action_direction (mapper, event, &direction))
|
||||
{
|
||||
const gchar *accel;
|
||||
|
||||
if (direction == META_PAD_DIRECTION_UP ||
|
||||
direction == META_PAD_DIRECTION_CW)
|
||||
accel = accel1;
|
||||
else if (direction == META_PAD_DIRECTION_DOWN ||
|
||||
direction == META_PAD_DIRECTION_CCW)
|
||||
accel = accel2;
|
||||
|
||||
if (accel && *accel)
|
||||
{
|
||||
meta_pad_action_mapper_emulate_keybinding (mapper, accel, TRUE);
|
||||
meta_pad_action_mapper_emulate_keybinding (mapper, accel, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
@ -694,29 +718,59 @@ meta_pad_action_mapper_handle_event (MetaPadActionMapper *mapper,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
format_directional_action (GString *str,
|
||||
MetaPadDirection direction,
|
||||
const gchar *action)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case META_PAD_DIRECTION_CW:
|
||||
g_string_append_printf (str, "⭮ %s", action);
|
||||
break;
|
||||
case META_PAD_DIRECTION_CCW:
|
||||
g_string_append_printf (str, "⭯ %s", action);
|
||||
break;
|
||||
case META_PAD_DIRECTION_UP:
|
||||
g_string_append_printf (str, "↥ %s", action);
|
||||
break;
|
||||
case META_PAD_DIRECTION_DOWN:
|
||||
g_string_append_printf (str, "↧ %s", action);
|
||||
break;
|
||||
case META_PAD_DIRECTION_NONE:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
compose_directional_action_label (GSettings *direction1,
|
||||
GSettings *direction2)
|
||||
compose_directional_action_label (MetaPadDirection direction1,
|
||||
GSettings *value1,
|
||||
MetaPadDirection direction2,
|
||||
GSettings *value2)
|
||||
{
|
||||
char *accel1, *accel2, *str = NULL;
|
||||
/* TRANSLATORS: This is a (non) action on an input device gadget */
|
||||
const char *none_label = N_("None");
|
||||
g_autofree char *accel1, *accel2;
|
||||
GString *str;
|
||||
|
||||
accel1 = g_settings_get_string (direction1, "keybinding");
|
||||
accel2 = g_settings_get_string (direction2, "keybinding");
|
||||
accel1 = g_settings_get_string (value1, "keybinding");
|
||||
accel2 = g_settings_get_string (value2, "keybinding");
|
||||
|
||||
if ((accel1 && *accel1) || (accel2 && *accel2))
|
||||
if ((!accel1 || !*accel1) && ((!accel2 || !*accel2)))
|
||||
return NULL;
|
||||
|
||||
str = g_string_new (NULL);
|
||||
|
||||
if (accel1 && *accel1)
|
||||
format_directional_action (str, direction1, accel1);
|
||||
|
||||
if (accel2 && *accel2)
|
||||
{
|
||||
str = g_strdup_printf ("%s / %s",
|
||||
(accel1 && *accel1) ? accel1 : _(none_label),
|
||||
(accel2 && *accel2) ? accel2 : _(none_label));
|
||||
if (str->len != 0)
|
||||
g_string_append (str, " / ");
|
||||
|
||||
format_directional_action (str, direction2, accel2);
|
||||
}
|
||||
|
||||
g_free (accel1);
|
||||
g_free (accel2);
|
||||
|
||||
return str;
|
||||
return g_string_free (str, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
@ -733,7 +787,8 @@ meta_pad_action_mapper_get_ring_label (MetaPadActionMapper *mapper,
|
||||
META_PAD_DIRECTION_CW, mode);
|
||||
settings2 = lookup_pad_action_settings (pad, META_PAD_ACTION_RING, number,
|
||||
META_PAD_DIRECTION_CCW, mode);
|
||||
label = compose_directional_action_label (settings1, settings2);
|
||||
label = compose_directional_action_label (META_PAD_DIRECTION_CW, settings1,
|
||||
META_PAD_DIRECTION_CCW, settings2);
|
||||
g_object_unref (settings1);
|
||||
g_object_unref (settings2);
|
||||
|
||||
@ -754,7 +809,8 @@ meta_pad_action_mapper_get_strip_label (MetaPadActionMapper *mapper,
|
||||
META_PAD_DIRECTION_UP, mode);
|
||||
settings2 = lookup_pad_action_settings (pad, META_PAD_ACTION_STRIP, number,
|
||||
META_PAD_DIRECTION_DOWN, mode);
|
||||
label = compose_directional_action_label (settings1, settings2);
|
||||
label = compose_directional_action_label (META_PAD_DIRECTION_UP, settings1,
|
||||
META_PAD_DIRECTION_DOWN, settings2);
|
||||
g_object_unref (settings1);
|
||||
g_object_unref (settings2);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user