From 7a7d30815eab10d6a81d38bdbcc6088470984a67 Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Thu, 3 Sep 2015 11:48:57 +0100 Subject: Touchpad settings: Affect right-button to 2 finger tap and middle-button to 3 finger tap by default (consistent with 2 finger clicking and settings in other DEs) --- data/org.mate.peripherals-touchpad.gschema.xml.in.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/org.mate.peripherals-touchpad.gschema.xml.in.in b/data/org.mate.peripherals-touchpad.gschema.xml.in.in index a7f5d05..e79cf5d 100644 --- a/data/org.mate.peripherals-touchpad.gschema.xml.in.in +++ b/data/org.mate.peripherals-touchpad.gschema.xml.in.in @@ -31,12 +31,12 @@ <_description>Select the button mapping for one-finger tap. Supported values are: 1: left mouse button 2: middle mouse button 3: right mouse button - 2 + 3 <_summary>Two finger tap button <_description>Select the button mapping for two-finger tap. Supported values are: 1: left mouse button 2: middle mouse button 3: right mouse button - 3 + 2 <_summary>Three finger tap button <_description>Select the button mapping for three-finger tap. Supported values are: 1: left mouse button 2: middle mouse button 3: right mouse button -- cgit v1.2.1 From f113d3892ea59540b5145b0346111e815a5eeb3e Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Thu, 3 Sep 2015 13:42:48 +0100 Subject: Touchpad support: Added support for two and three finger clicks --- ...org.mate.peripherals-touchpad.gschema.xml.in.in | 10 ++++ plugins/mouse/msd-mouse-manager.c | 66 ++++++++++++++++++++-- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/data/org.mate.peripherals-touchpad.gschema.xml.in.in b/data/org.mate.peripherals-touchpad.gschema.xml.in.in index e79cf5d..a97e576 100644 --- a/data/org.mate.peripherals-touchpad.gschema.xml.in.in +++ b/data/org.mate.peripherals-touchpad.gschema.xml.in.in @@ -25,6 +25,16 @@ <_summary>Enable touchpad <_description>Set this to TRUE to enable all touchpads. + + 3 + <_summary>Enabled two-finger button-click emulation + <_description>0 thru 3, 0 is inactive, 1-3 is button for two-finger click to emulate + + + 2 + <_summary>Enable three-finger button-click emulation + <_description>0 thru 3, 0 is inactive, 1-3 is button for two-finger click to emulate + 1 <_summary>One finger tap button diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c index ca60db0..7c95978 100644 --- a/plugins/mouse/msd-mouse-manager.c +++ b/plugins/mouse/msd-mouse-manager.c @@ -62,6 +62,10 @@ #define MATE_TOUCHPAD_SCHEMA "org.mate.peripherals-touchpad" #define KEY_TOUCHPAD_DISABLE_W_TYPING "disable-while-typing" #ifdef HAVE_X11_EXTENSIONS_XINPUT_H + +#define KEY_TWO_FINGER_CLICK "two-finger-click" +#define KEY_THREE_FINGER_CLICK "three-finger-click" + #define KEY_TOUCHPAD_TAP_TO_CLICK "tap-to-click" #define KEY_TOUCHPAD_ONE_FINGER_TAP "tap-button-one-finger" #define KEY_TOUCHPAD_TWO_FINGER_TAP "tap-button-two-finger" @@ -96,6 +100,7 @@ static void msd_mouse_manager_finalize (GObject *object); static void set_mouse_settings (MsdMouseManager *manager); #ifdef HAVE_X11_EXTENSIONS_XINPUT_H static int set_tap_to_click (gboolean state, gboolean left_handed); +static void set_click_actions (gboolean enable_two_finger_click, gboolean enable_three_finger_click); #endif G_DEFINE_TYPE (MsdMouseManager, msd_mouse_manager, G_TYPE_OBJECT) @@ -646,12 +651,12 @@ set_tap_to_click (gboolean state, gboolean left_handed) gint two_finger_tap = g_settings_get_int (settings, KEY_TOUCHPAD_TWO_FINGER_TAP); gint three_finger_tap = g_settings_get_int (settings, KEY_TOUCHPAD_THREE_FINGER_TAP); if (one_finger_tap > 3 || one_finger_tap < 1) - one_finger_tap = 1; - if (two_finger_tap > 3 || two_finger_tap < 1) - two_finger_tap = 2; - if (three_finger_tap > 3 || three_finger_tap < 1) - three_finger_tap = 3; - g_object_unref (settings); + one_finger_tap = 1; + if (two_finger_tap > 3 || two_finger_tap < 1) + two_finger_tap = 2; + if (three_finger_tap > 3 || three_finger_tap < 1) + three_finger_tap = 3; + g_object_unref (settings); if (rc == Success && type == XA_INTEGER && format == 8 && nitems >= 7) { @@ -677,6 +682,51 @@ set_tap_to_click (gboolean state, gboolean left_handed) return 0; } + static void +set_click_actions (gint enable_two_finger_click, + gint enable_three_finger_click) +{ + int numdevices, i, format, rc; + unsigned long nitems, bytes_after; + XDeviceInfo *devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &numdevices); + XDevice * device; + unsigned char* data; + Atom prop, type; + + if (devicelist == NULL) + return 0; + + prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Synaptics Click Action", False); + if (!prop) + return; + + for (i = 0; i < numdevices; i++) { + if ((device = device_is_touchpad (devicelist[i]))) { + g_debug ("setting click action to click on %s", devicelist[i].name); + gdk_error_trap_push (); + rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, prop, 0, 2, + False, XA_INTEGER, &type, &format, &nitems, + &bytes_after, &data); + + if (rc == Success && type == XA_INTEGER && format == 8 && nitems >= 3) { + data[0] = 1; + data[1] = enable_two_finger_click; + data[2] = enable_three_finger_click; + XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, prop, XA_INTEGER, 8, PropModeReplace, data, nitems); + } + + if (rc == Success) + XFree (data); + XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); + if (gdk_error_trap_pop ()) { + g_warning ("Error in setting click actions on \"%s\"", devicelist[i].name); + continue; + } + } + } + XFreeDeviceList (devicelist); +} + static int set_horiz_scroll (gboolean state) { @@ -954,6 +1004,7 @@ set_mouse_settings (MsdMouseManager *manager) set_disable_w_typing (manager, g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_DISABLE_W_TYPING)); #ifdef HAVE_X11_EXTENSIONS_XINPUT_H set_tap_to_click (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_TAP_TO_CLICK), left_handed); + set_click_actions (g_settings_get_int (manager->priv->settings_touchpad, KEY_TWO_FINGER_CLICK), g_settings_get_int (manager->priv->settings_touchpad, KEY_THREE_FINGER_CLICK)); set_edge_scroll (g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_SCROLL_METHOD)); set_horiz_scroll (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_PAD_HORIZ_SCROLL)); set_touchpad_enabled (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_ENABLED)); @@ -979,6 +1030,9 @@ mouse_callback (GSettings *settings, } else if (g_strcmp0 (key, KEY_TOUCHPAD_TAP_TO_CLICK) == 0) { set_tap_to_click (g_settings_get_boolean (settings, key), g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED)); + } else if (g_str_equal (key, KEY_TWO_FINGER_CLICK) || g_str_equal (key, KEY_THREE_FINGER_CLICK)) { + set_click_actions(g_settings_get_int (settings, KEY_TWO_FINGER_CLICK), + g_settings_get_int (settings, KEY_THREE_FINGER_CLICK)); } else if (g_strcmp0 (key, KEY_TOUCHPAD_ONE_FINGER_TAP) == 0) { set_tap_to_click (g_settings_get_boolean (settings, KEY_TOUCHPAD_TAP_TO_CLICK), g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED)); -- cgit v1.2.1 From e1becf4e7b72d5ec3b915e7922b81f4e25c03f1b Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Thu, 3 Sep 2015 14:10:10 +0100 Subject: Refactored mouse plugin a bit (tap actions used to instantiate a gsettings object for every device) --- plugins/mouse/msd-mouse-manager.c | 65 +++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c index 7c95978..9b63cbe 100644 --- a/plugins/mouse/msd-mouse-manager.c +++ b/plugins/mouse/msd-mouse-manager.c @@ -99,8 +99,8 @@ static void msd_mouse_manager_init (MsdMouseManager *mouse_manag static void msd_mouse_manager_finalize (GObject *object); static void set_mouse_settings (MsdMouseManager *manager); #ifdef HAVE_X11_EXTENSIONS_XINPUT_H -static int set_tap_to_click (gboolean state, gboolean left_handed); -static void set_click_actions (gboolean enable_two_finger_click, gboolean enable_three_finger_click); +static void set_tap_to_click (MsdMouseManager * manager); +static void set_click_actions (MsdMouseManager * manager); #endif G_DEFINE_TYPE (MsdMouseManager, msd_mouse_manager, G_TYPE_OBJECT) @@ -308,7 +308,7 @@ touchpad_has_single_button (XDevice *device) static void -set_xinput_devices_left_handed (gboolean left_handed) +set_xinput_devices_left_handed (MsdMouseManager * manager, gboolean left_handed) { XDeviceInfo *device_info; gint n_devices; @@ -342,7 +342,7 @@ set_xinput_devices_left_handed (gboolean left_handed) gboolean single_button = touchpad_has_single_button (device); if (tap && !single_button) - set_tap_to_click (tap, left_handed); + set_tap_to_click (manager); XCloseDevice (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), device); g_object_unref (settings); @@ -440,7 +440,7 @@ set_left_handed (MsdMouseManager *manager, /* When XInput support is available, never set the * button ordering on the core pointer as that would * revert the changes we make on the devices themselves */ - set_xinput_devices_left_handed (left_handed); + set_xinput_devices_left_handed (manager, left_handed); return; } #endif @@ -621,8 +621,8 @@ set_disable_w_typing (MsdMouseManager *manager, gboolean state) } #ifdef HAVE_X11_EXTENSIONS_XINPUT_H -static int -set_tap_to_click (gboolean state, gboolean left_handed) +static void +set_tap_to_click (MsdMouseManager * manager) { int numdevices, i, format, rc; unsigned long nitems, bytes_after; @@ -632,12 +632,18 @@ set_tap_to_click (gboolean state, gboolean left_handed) Atom prop, type; if (devicelist == NULL) - return 0; + return; prop = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "Synaptics Tap Action", False); if (!prop) - return 0; + return; + + gboolean state = g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_TAP_TO_CLICK); + gboolean left_handed = g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED); + gint one_finger_tap = g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_ONE_FINGER_TAP); + gint two_finger_tap = g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_TWO_FINGER_TAP); + gint three_finger_tap = g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_THREE_FINGER_TAP); for (i = 0; i < numdevices; i++) { if ((device = device_is_touchpad (devicelist[i]))) { @@ -646,18 +652,13 @@ set_tap_to_click (gboolean state, gboolean left_handed) False, XA_INTEGER, &type, &format, &nitems, &bytes_after, &data); - GSettings *settings = g_settings_new (MATE_TOUCHPAD_SCHEMA); - gint one_finger_tap = g_settings_get_int (settings, KEY_TOUCHPAD_ONE_FINGER_TAP); - gint two_finger_tap = g_settings_get_int (settings, KEY_TOUCHPAD_TWO_FINGER_TAP); - gint three_finger_tap = g_settings_get_int (settings, KEY_TOUCHPAD_THREE_FINGER_TAP); if (one_finger_tap > 3 || one_finger_tap < 1) one_finger_tap = 1; if (two_finger_tap > 3 || two_finger_tap < 1) two_finger_tap = 2; if (three_finger_tap > 3 || three_finger_tap < 1) three_finger_tap = 3; - g_object_unref (settings); - + if (rc == Success && type == XA_INTEGER && format == 8 && nitems >= 7) { /* Set RLM mapping for 1/2/3 fingers*/ @@ -679,12 +680,10 @@ set_tap_to_click (gboolean state, gboolean left_handed) } XFreeDeviceList (devicelist); - return 0; } - static void -set_click_actions (gint enable_two_finger_click, - gint enable_three_finger_click) +static void +set_click_actions (MsdMouseManager * manager) { int numdevices, i, format, rc; unsigned long nitems, bytes_after; @@ -700,6 +699,9 @@ set_click_actions (gint enable_two_finger_click, if (!prop) return; + gint enable_two_finger_click = g_settings_get_int (manager->priv->settings_touchpad, KEY_TWO_FINGER_CLICK); + gint enable_three_finger_click = g_settings_get_int (manager->priv->settings_touchpad, KEY_THREE_FINGER_CLICK); + for (i = 0; i < numdevices; i++) { if ((device = device_is_touchpad (devicelist[i]))) { g_debug ("setting click action to click on %s", devicelist[i].name); @@ -999,12 +1001,12 @@ set_mouse_settings (MsdMouseManager *manager) set_left_handed (manager, left_handed); set_motion_acceleration (manager, g_settings_get_double (manager->priv->settings_mouse, KEY_MOUSE_MOTION_ACCELERATION)); set_motion_threshold (manager, g_settings_get_int (manager->priv->settings_mouse, KEY_MOUSE_MOTION_THRESHOLD)); - set_middle_button (manager, g_settings_get_boolean (manager->priv->settings_mouse, KEY_MIDDLE_BUTTON_EMULATION)); + set_middle_button (manager, g_settings_get_boolean (manager->priv->settings_mouse, KEY_MIDDLE_BUTTON_EMULATION)); set_disable_w_typing (manager, g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_DISABLE_W_TYPING)); #ifdef HAVE_X11_EXTENSIONS_XINPUT_H - set_tap_to_click (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_TAP_TO_CLICK), left_handed); - set_click_actions (g_settings_get_int (manager->priv->settings_touchpad, KEY_TWO_FINGER_CLICK), g_settings_get_int (manager->priv->settings_touchpad, KEY_THREE_FINGER_CLICK)); + set_tap_to_click (manager); + set_click_actions (manager); set_edge_scroll (g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_SCROLL_METHOD)); set_horiz_scroll (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_PAD_HORIZ_SCROLL)); set_touchpad_enabled (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_ENABLED)); @@ -1028,20 +1030,15 @@ mouse_callback (GSettings *settings, set_middle_button (manager, g_settings_get_boolean (settings, key)); #ifdef HAVE_X11_EXTENSIONS_XINPUT_H } else if (g_strcmp0 (key, KEY_TOUCHPAD_TAP_TO_CLICK) == 0) { - set_tap_to_click (g_settings_get_boolean (settings, key), - g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED)); + set_tap_to_click (manager); } else if (g_str_equal (key, KEY_TWO_FINGER_CLICK) || g_str_equal (key, KEY_THREE_FINGER_CLICK)) { - set_click_actions(g_settings_get_int (settings, KEY_TWO_FINGER_CLICK), - g_settings_get_int (settings, KEY_THREE_FINGER_CLICK)); + set_click_actions(manager); } else if (g_strcmp0 (key, KEY_TOUCHPAD_ONE_FINGER_TAP) == 0) { - set_tap_to_click (g_settings_get_boolean (settings, KEY_TOUCHPAD_TAP_TO_CLICK), - g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED)); + set_tap_to_click (manager); } else if (g_strcmp0 (key, KEY_TOUCHPAD_TWO_FINGER_TAP) == 0) { - set_tap_to_click (g_settings_get_boolean (settings, KEY_TOUCHPAD_TAP_TO_CLICK), - g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED)); + set_tap_to_click (manager); } else if (g_strcmp0 (key, KEY_TOUCHPAD_THREE_FINGER_TAP) == 0) { - set_tap_to_click (g_settings_get_boolean (settings, KEY_TOUCHPAD_TAP_TO_CLICK), - g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED)); + set_tap_to_click (manager); } else if (g_strcmp0 (key, KEY_TOUCHPAD_SCROLL_METHOD) == 0) { set_edge_scroll (g_settings_get_int (settings, key)); set_horiz_scroll (g_settings_get_boolean (settings, KEY_TOUCHPAD_PAD_HORIZ_SCROLL)); @@ -1102,8 +1099,8 @@ msd_mouse_manager_idle_cb (MsdMouseManager *manager) set_disable_w_typing (manager, g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_DISABLE_W_TYPING)); #ifdef HAVE_X11_EXTENSIONS_XINPUT_H - set_tap_to_click (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_TAP_TO_CLICK), - g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED)); + set_tap_to_click (manager); + set_click_actions (manager); set_edge_scroll (g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_SCROLL_METHOD)); set_horiz_scroll (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_PAD_HORIZ_SCROLL)); set_touchpad_enabled (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_ENABLED)); -- cgit v1.2.1 From dbc59a272ca033652402d5cf3ade7ca11cab0027 Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Thu, 3 Sep 2015 14:20:39 +0100 Subject: Touchpad support: Fixed default value for tapping when configuration is outside of bonds, fixed typo in settings description --- data/org.mate.peripherals-touchpad.gschema.xml.in.in | 4 ++-- plugins/mouse/msd-mouse-manager.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/org.mate.peripherals-touchpad.gschema.xml.in.in b/data/org.mate.peripherals-touchpad.gschema.xml.in.in index a97e576..64e630f 100644 --- a/data/org.mate.peripherals-touchpad.gschema.xml.in.in +++ b/data/org.mate.peripherals-touchpad.gschema.xml.in.in @@ -28,12 +28,12 @@ 3 <_summary>Enabled two-finger button-click emulation - <_description>0 thru 3, 0 is inactive, 1-3 is button for two-finger click to emulate + <_description>0 thru 3, 0 is inactive, 1-3 is button to emulate 2 <_summary>Enable three-finger button-click emulation - <_description>0 thru 3, 0 is inactive, 1-3 is button for two-finger click to emulate + <_description>0 thru 3, 0 is inactive, 1-3 is button to emulate 1 diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c index 9b63cbe..3fd7430 100644 --- a/plugins/mouse/msd-mouse-manager.c +++ b/plugins/mouse/msd-mouse-manager.c @@ -655,9 +655,9 @@ set_tap_to_click (MsdMouseManager * manager) if (one_finger_tap > 3 || one_finger_tap < 1) one_finger_tap = 1; if (two_finger_tap > 3 || two_finger_tap < 1) - two_finger_tap = 2; + two_finger_tap = 3; if (three_finger_tap > 3 || three_finger_tap < 1) - three_finger_tap = 3; + three_finger_tap = 2; if (rc == Success && type == XA_INTEGER && format == 8 && nitems >= 7) { -- cgit v1.2.1