core: Drop META_PAD_FEATURE_BUTTON value
This is now handled externally through separate API calls. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
This commit is contained in:
parent
2da9b67673
commit
3e6f7a9463
@ -192,60 +192,70 @@ meta_pad_action_mapper_new (MetaMonitorManager *monitor_manager)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GSettings *
|
static GSettings *
|
||||||
lookup_pad_action_settings (ClutterInputDevice *device,
|
get_pad_feature_gsettings (ClutterInputDevice *device,
|
||||||
MetaPadFeatureType feature,
|
const char *feature,
|
||||||
guint number,
|
int feature_number,
|
||||||
MetaPadDirection direction,
|
const char *suffix)
|
||||||
int mode)
|
|
||||||
{
|
{
|
||||||
const char *vendor, *product, *action_type, *detail_type = NULL;
|
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
GString *path;
|
g_autofree char *path = NULL;
|
||||||
char action_label;
|
const gchar *vendor, *product;
|
||||||
|
char tag;
|
||||||
|
|
||||||
|
tag = 'A' + feature_number;
|
||||||
vendor = clutter_input_device_get_vendor_id (device);
|
vendor = clutter_input_device_get_vendor_id (device);
|
||||||
product = clutter_input_device_get_product_id (device);
|
product = clutter_input_device_get_product_id (device);
|
||||||
|
|
||||||
action_label = 'A' + number;
|
path = g_strdup_printf ("/org/gnome/desktop/peripherals/tablets/%s:%s/%s%c%s/",
|
||||||
|
vendor, product, feature, tag,
|
||||||
|
suffix ? suffix : "");
|
||||||
|
settings = g_settings_new_with_path ("org.gnome.desktop.peripherals.tablet.pad-button",
|
||||||
|
path);
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GSettings *
|
||||||
|
lookup_pad_button_settings (ClutterInputDevice *device,
|
||||||
|
int button)
|
||||||
|
{
|
||||||
|
return get_pad_feature_gsettings (device, "button", button, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GSettings *
|
||||||
|
lookup_pad_feature_settings (ClutterInputDevice *device,
|
||||||
|
MetaPadFeatureType feature,
|
||||||
|
guint number,
|
||||||
|
MetaPadDirection direction,
|
||||||
|
int mode)
|
||||||
|
{
|
||||||
|
g_autofree char *suffix = NULL;
|
||||||
|
const char *feature_type, *detail_type;
|
||||||
|
|
||||||
switch (feature)
|
switch (feature)
|
||||||
{
|
{
|
||||||
case META_PAD_FEATURE_BUTTON:
|
|
||||||
action_type = "button";
|
|
||||||
break;
|
|
||||||
case META_PAD_FEATURE_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";
|
feature_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_FEATURE_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";
|
feature_type = "strip";
|
||||||
detail_type = (direction == META_PAD_DIRECTION_UP) ? "up" : "down";
|
detail_type = (direction == META_PAD_DIRECTION_UP) ? "up" : "down";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = g_string_new (NULL);
|
|
||||||
g_string_append_printf (path, "/org/gnome/desktop/peripherals/tablets/%s:%s/%s%c",
|
|
||||||
vendor, product, action_type, action_label);
|
|
||||||
|
|
||||||
if (detail_type)
|
|
||||||
g_string_append_printf (path, "-%s", detail_type);
|
|
||||||
|
|
||||||
if (mode >= 0)
|
if (mode >= 0)
|
||||||
g_string_append_printf (path, "-mode-%d", mode);
|
suffix = g_strdup_printf ("-%s-mode-%d", detail_type, mode);
|
||||||
|
else
|
||||||
|
suffix = g_strdup_printf ("-%s", detail_type);
|
||||||
|
|
||||||
g_string_append_c (path, '/');
|
return get_pad_feature_gsettings (device, feature_type, number, suffix);
|
||||||
|
|
||||||
settings = g_settings_new_with_path ("org.gnome.desktop.peripherals.tablet.pad-button",
|
|
||||||
path->str);
|
|
||||||
g_string_free (path, TRUE);
|
|
||||||
|
|
||||||
return settings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GDesktopPadButtonAction
|
static GDesktopPadButtonAction
|
||||||
@ -261,8 +271,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_FEATURE_BUTTON,
|
settings = lookup_pad_button_settings (pad, button);
|
||||||
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,8 +598,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_FEATURE_BUTTON,
|
settings = lookup_pad_button_settings (pad, button);
|
||||||
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);
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
@ -661,24 +669,24 @@ meta_pad_action_mapper_handle_action (MetaPadActionMapper *mapper,
|
|||||||
guint number,
|
guint number,
|
||||||
guint mode)
|
guint mode)
|
||||||
{
|
{
|
||||||
MetaPadDirection direction = META_PAD_DIRECTION_NONE;
|
MetaPadDirection direction;
|
||||||
g_autoptr (GSettings) settings1 = NULL, settings2 = NULL;
|
g_autoptr (GSettings) settings1 = NULL, settings2 = NULL;
|
||||||
g_autofree char *accel1 = NULL, *accel2 = NULL;
|
g_autofree char *accel1 = NULL, *accel2 = NULL;
|
||||||
gboolean handled;
|
gboolean handled;
|
||||||
|
|
||||||
if (feature == META_PAD_FEATURE_RING)
|
if (feature == META_PAD_FEATURE_RING)
|
||||||
{
|
{
|
||||||
settings1 = lookup_pad_action_settings (pad, feature, number,
|
settings1 = lookup_pad_feature_settings (pad, feature, number,
|
||||||
META_PAD_DIRECTION_CW, mode);
|
META_PAD_DIRECTION_CW, mode);
|
||||||
settings2 = lookup_pad_action_settings (pad, feature, number,
|
settings2 = lookup_pad_feature_settings (pad, feature, number,
|
||||||
META_PAD_DIRECTION_CCW, mode);
|
META_PAD_DIRECTION_CCW, mode);
|
||||||
}
|
}
|
||||||
else if (feature == META_PAD_FEATURE_STRIP)
|
else if (feature == META_PAD_FEATURE_STRIP)
|
||||||
{
|
{
|
||||||
settings1 = lookup_pad_action_settings (pad, feature, number,
|
settings1 = lookup_pad_feature_settings (pad, feature, number,
|
||||||
META_PAD_DIRECTION_UP, mode);
|
META_PAD_DIRECTION_UP, mode);
|
||||||
settings2 = lookup_pad_action_settings (pad, feature, number,
|
settings2 = lookup_pad_feature_settings (pad, feature, number,
|
||||||
META_PAD_DIRECTION_DOWN, mode);
|
META_PAD_DIRECTION_DOWN, mode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -691,7 +699,7 @@ meta_pad_action_mapper_handle_action (MetaPadActionMapper *mapper,
|
|||||||
|
|
||||||
if (meta_pad_action_mapper_get_action_direction (mapper, event, &direction))
|
if (meta_pad_action_mapper_get_action_direction (mapper, event, &direction))
|
||||||
{
|
{
|
||||||
const gchar *accel;
|
const gchar *accel = NULL;
|
||||||
|
|
||||||
if (direction == META_PAD_DIRECTION_UP ||
|
if (direction == META_PAD_DIRECTION_UP ||
|
||||||
direction == META_PAD_DIRECTION_CW)
|
direction == META_PAD_DIRECTION_CW)
|
||||||
@ -804,10 +812,10 @@ 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_FEATURE_RING, number,
|
settings1 = lookup_pad_feature_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_FEATURE_RING, number,
|
settings2 = lookup_pad_feature_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);
|
||||||
g_object_unref (settings1);
|
g_object_unref (settings1);
|
||||||
@ -826,10 +834,10 @@ 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_FEATURE_STRIP, number,
|
settings1 = lookup_pad_feature_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_FEATURE_STRIP, number,
|
settings2 = lookup_pad_feature_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);
|
||||||
g_object_unref (settings1);
|
g_object_unref (settings1);
|
||||||
@ -870,8 +878,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_FEATURE_BUTTON,
|
settings = lookup_pad_button_settings (pad, button);
|
||||||
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);
|
||||||
|
|
||||||
@ -931,9 +938,6 @@ meta_pad_action_mapper_get_feature_label (MetaPadActionMapper *mapper,
|
|||||||
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;
|
||||||
|
@ -58,7 +58,6 @@ typedef enum
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
META_PAD_FEATURE_BUTTON,
|
|
||||||
META_PAD_FEATURE_RING,
|
META_PAD_FEATURE_RING,
|
||||||
META_PAD_FEATURE_STRIP,
|
META_PAD_FEATURE_STRIP,
|
||||||
} MetaPadFeatureType;
|
} MetaPadFeatureType;
|
||||||
|
@ -575,9 +575,6 @@ meta_wayland_tablet_pad_get_feature_label (MetaWaylandTabletPad *pad,
|
|||||||
label = strip->feedback;
|
label = strip->feedback;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_strdup (label);
|
return g_strdup (label);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user