[mutter] Implements disable-while-typing in mutter.
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Implements disable-while-typing in mutter.
- Date: Wed, 24 May 2017 03:57:19 +0000 (UTC)
commit 76198e0b3b93c05de39536698758ac0485deea49
Author: Evan Welsh <gf 3432 gmail com>
Date: Tue May 23 13:38:00 2017 +0000
Implements disable-while-typing in mutter.
Disable-while-typing disables the touchpad while the user is typing.
This patch introduces the necessary backend code to implement the
org.gnome.desktop.peripherals.touchpad.disable-while-typing setting of
gsettings-desktop-schemas which was implemented in commit
4c5b1c1df399d6afaaccb237e299ccd1d5d29ddd and released as part of 3.24.
This is known as dwt in libinput.
This patch has been tested on X11 and Wayland.
https://bugzilla.gnome.org/show_bug.cgi?id=764852
src/backends/meta-input-settings-private.h | 4 ++-
src/backends/meta-input-settings.c | 41 ++++++++++++++++++++++
src/backends/native/meta-input-settings-native.c | 20 ++++++++++
src/backends/x11/meta-input-settings-x11.c | 12 ++++++
4 files changed, 76 insertions(+), 1 deletions(-)
---
diff --git a/src/backends/meta-input-settings-private.h b/src/backends/meta-input-settings-private.h
index 53a7b80..1a9ab5f 100644
--- a/src/backends/meta-input-settings-private.h
+++ b/src/backends/meta-input-settings-private.h
@@ -54,6 +54,9 @@ struct _MetaInputSettingsClass
void (* set_tap_enabled) (MetaInputSettings *settings,
ClutterInputDevice *device,
gboolean enabled);
+ void (* set_disable_while_typing) (MetaInputSettings *settings,
+ ClutterInputDevice *device,
+ gboolean enabled);
void (* set_invert_scroll) (MetaInputSettings *settings,
ClutterInputDevice *device,
gboolean inverted);
@@ -106,7 +109,6 @@ struct _MetaInputSettingsClass
ClutterInputDeviceTool *tool,
GDesktopStylusButtonAction primary,
GDesktopStylusButtonAction secondary);
-
gboolean (* has_two_finger_scroll) (MetaInputSettings *settings,
ClutterInputDevice *device);
};
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 0566e0d..7881dbf 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -443,6 +443,44 @@ update_device_natural_scroll (MetaInputSettings *input_settings,
}
static void
+update_touchpad_disable_while_typing (MetaInputSettings *input_settings,
+ ClutterInputDevice *device)
+{
+ GSettings *settings;
+ MetaInputSettingsClass *input_settings_class;
+ MetaInputSettingsPrivate *priv;
+ gboolean enabled;
+ const gchar *key = "disable-while-typing";
+
+ if (device &&
+ clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ return;
+
+ priv = meta_input_settings_get_instance_private (input_settings);
+ input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings);
+ enabled = g_settings_get_boolean (priv->touchpad_settings, key);
+
+ if (device)
+ {
+ settings = get_settings_for_device_type (input_settings,
+ clutter_input_device_get_device_type (device));
+
+ if (!settings)
+ return;
+
+ settings_device_set_bool_setting (input_settings, device,
+ input_settings_class->set_disable_while_typing,
+ enabled);
+ }
+ else
+ {
+ settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
+ input_settings_class->set_disable_while_typing,
+ enabled);
+ }
+}
+
+static void
update_touchpad_tap_enabled (MetaInputSettings *input_settings,
ClutterInputDevice *device)
{
@@ -983,6 +1021,8 @@ meta_input_settings_changed_cb (GSettings *settings,
update_device_natural_scroll (input_settings, NULL);
else if (strcmp (key, "tap-to-click") == 0)
update_touchpad_tap_enabled (input_settings, NULL);
+ else if (strcmp(key, "disable-while-typing") == 0)
+ update_touchpad_disable_while_typing (input_settings, NULL);
else if (strcmp (key, "send-events") == 0)
update_touchpad_send_events (input_settings, NULL);
else if (strcmp (key, "edge-scrolling-enabled") == 0)
@@ -1228,6 +1268,7 @@ apply_device_settings (MetaInputSettings *input_settings,
update_touchpad_left_handed (input_settings, device);
update_touchpad_tap_enabled (input_settings, device);
+ update_touchpad_disable_while_typing (input_settings, device);
update_touchpad_send_events (input_settings, device);
update_touchpad_two_finger_scroll (input_settings, device);
update_touchpad_edge_scroll (input_settings, device);
diff --git a/src/backends/native/meta-input-settings-native.c
b/src/backends/native/meta-input-settings-native.c
index 69e7608..952625e 100644
--- a/src/backends/native/meta-input-settings-native.c
+++ b/src/backends/native/meta-input-settings-native.c
@@ -122,6 +122,25 @@ meta_input_settings_native_set_tap_enabled (MetaInputSettings *settings,
}
static void
+meta_input_settings_native_set_disable_while_typing (MetaInputSettings *settings,
+ ClutterInputDevice *device,
+ gboolean enabled)
+{
+ struct libinput_device *libinput_device;
+
+ libinput_device = clutter_evdev_input_device_get_libinput_device (device);
+
+ if (!libinput_device)
+ return;
+
+ if (libinput_device_config_dwt_is_available (libinput_device))
+ libinput_device_config_dwt_set_enabled (libinput_device,
+ enabled ?
+ LIBINPUT_CONFIG_DWT_ENABLED :
+ LIBINPUT_CONFIG_DWT_DISABLED);
+}
+
+static void
meta_input_settings_native_set_invert_scroll (MetaInputSettings *settings,
ClutterInputDevice *device,
gboolean inverted)
@@ -507,6 +526,7 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
input_settings_class->set_scroll_button = meta_input_settings_native_set_scroll_button;
input_settings_class->set_click_method = meta_input_settings_native_set_click_method;
input_settings_class->set_keyboard_repeat = meta_input_settings_native_set_keyboard_repeat;
+ input_settings_class->set_disable_while_typing = meta_input_settings_native_set_disable_while_typing;
input_settings_class->set_tablet_mapping = meta_input_settings_native_set_tablet_mapping;
input_settings_class->set_tablet_keep_aspect = meta_input_settings_native_set_tablet_keep_aspect;
diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c
index 012cb62..174fd32 100644
--- a/src/backends/x11/meta-input-settings-x11.c
+++ b/src/backends/x11/meta-input-settings-x11.c
@@ -206,6 +206,17 @@ meta_input_settings_x11_set_left_handed (MetaInputSettings *settings,
}
static void
+meta_input_settings_x11_set_disable_while_typing (MetaInputSettings *settings,
+ ClutterInputDevice *device,
+ gboolean enabled)
+{
+ guchar value = (enabled) ? 1 : 0;
+
+ change_property (device, "libinput Disable While Typing Enabled",
+ XA_INTEGER, 8, &value, 1);
+}
+
+static void
meta_input_settings_x11_set_tap_enabled (MetaInputSettings *settings,
ClutterInputDevice *device,
gboolean enabled)
@@ -744,6 +755,7 @@ meta_input_settings_x11_class_init (MetaInputSettingsX11Class *klass)
input_settings_class->set_speed = meta_input_settings_x11_set_speed;
input_settings_class->set_left_handed = meta_input_settings_x11_set_left_handed;
input_settings_class->set_tap_enabled = meta_input_settings_x11_set_tap_enabled;
+ input_settings_class->set_disable_while_typing = meta_input_settings_x11_set_disable_while_typing;
input_settings_class->set_invert_scroll = meta_input_settings_x11_set_invert_scroll;
input_settings_class->set_edge_scroll = meta_input_settings_x11_set_edge_scroll;
input_settings_class->set_two_finger_scroll = meta_input_settings_x11_set_two_finger_scroll;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]