[mutter/wip/carlosg/device-capabilities] backends: Set mapping function for left-handed setting
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/device-capabilities] backends: Set mapping function for left-handed setting
- Date: Wed, 9 Mar 2022 11:31:26 +0000 (UTC)
commit 8e27195bebd90c6aba2e669f4c3e7da8eb1e78aa
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Mar 9 12:19:20 2022 +0100
backends: Set mapping function for left-handed setting
We have separate left-handed settings for mice and touchpads,
which are slightly harder to be kept separate querying devices
by capabilities. These should just relate if the "follow mouse"
handedness is set on touchpads.
In order to keep applying the setting in a fine grained manner,
add a mapping function for the left-handed setting on mice, this
will replace the right configuration value depending on the pointer
device it is dealing with.
This ensures mouse preferences don't overwrite touchpad behavior
unless that preference is enabled.
src/backends/meta-input-settings.c | 45 +++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 10 deletions(-)
---
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index d045315fa7..a2a6e6230f 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -281,6 +281,39 @@ update_touchpad_left_handed (MetaInputSettings *input_settings,
}
}
+static gboolean
+apply_device_handedness (MetaInputSettings *input_settings,
+ ClutterInputDevice *device,
+ gboolean value)
+{
+ if ((clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) != 0)
+ {
+ GDesktopTouchpadHandedness handedness;
+ MetaInputSettingsPrivate *priv;
+
+ /* Look up correct handedness on touchpads */
+ priv = meta_input_settings_get_instance_private (input_settings);
+ handedness = g_settings_get_enum (priv->touchpad_settings, "left-handed");
+
+ switch (handedness)
+ {
+ case G_DESKTOP_TOUCHPAD_HANDEDNESS_RIGHT:
+ value = FALSE;
+ break;
+ case G_DESKTOP_TOUCHPAD_HANDEDNESS_LEFT:
+ value = TRUE;
+ break;
+ case G_DESKTOP_TOUCHPAD_HANDEDNESS_MOUSE:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+
+ return value;
+}
+
static void
update_mouse_left_handed (MetaInputSettings *input_settings,
ClutterInputDevice *device)
@@ -312,19 +345,11 @@ update_mouse_left_handed (MetaInputSettings *input_settings,
}
else
{
- GDesktopTouchpadHandedness touchpad_handedness;
-
settings_set_bool_setting (input_settings,
- CLUTTER_INPUT_CAPABILITY_POINTER, NULL,
+ CLUTTER_INPUT_CAPABILITY_POINTER,
+ apply_device_handedness,
input_settings_class->set_left_handed,
enabled);
-
- touchpad_handedness = g_settings_get_enum (priv->touchpad_settings,
- "left-handed");
-
- /* Also update touchpads if they're following mouse settings */
- if (touchpad_handedness == G_DESKTOP_TOUCHPAD_HANDEDNESS_MOUSE)
- update_touchpad_left_handed (input_settings, NULL);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]