Hello community, here is the log from the commit of package xf86-input-libinput for openSUSE:Factory checked in at 2015-05-24 19:32:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/xf86-input-libinput (Old) and /work/SRC/openSUSE:Factory/.xf86-input-libinput.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "xf86-input-libinput" Changes: -------- --- /work/SRC/openSUSE:Factory/xf86-input-libinput/xf86-input-libinput.changes 2015-04-25 11:26:26.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.xf86-input-libinput.new/xf86-input-libinput.changes 2015-05-24 19:32:26.000000000 +0200 @@ -1,0 +2,11 @@ +Sat May 23 00:39:18 UTC 2015 - zai...@opensuse.org + +- Update to version 0.10.0: + + Group scroll distances into a struct. + + Add option "ButtonMapping" (fdo#90206). + + man: add two linebreaks to make things easier to visually + parse. + + Move the option parsing into helper functions. + + Add a property for middle button emulation. + +------------------------------------------------------------------- Old: ---- xf86-input-libinput-0.9.0.tar.bz2 New: ---- xf86-input-libinput-0.10.0.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ xf86-input-libinput.spec ++++++ --- /var/tmp/diff_new_pack.M9RIjh/_old 2015-05-24 19:32:27.000000000 +0200 +++ /var/tmp/diff_new_pack.M9RIjh/_new 2015-05-24 19:32:27.000000000 +0200 @@ -17,7 +17,7 @@ Name: xf86-input-libinput -Version: 0.9.0 +Version: 0.10.0 Release: 0 Summary: Libinput driver for the Xorg X server License: MIT @@ -30,7 +30,7 @@ BuildRequires: libtool BuildRequires: pkg-config BuildRequires: pkgconfig(inputproto) -BuildRequires: pkgconfig(libinput) +BuildRequires: pkgconfig(libinput) >= 0.14.0 BuildRequires: pkgconfig(xorg-macros) >= 1.13 BuildRequires: pkgconfig(xorg-server) >= 1.7 BuildRequires: pkgconfig(xproto) ++++++ xf86-input-libinput-0.9.0.tar.bz2 -> xf86-input-libinput-0.10.0.tar.bz2 ++++++ ++++ 6901 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/xf86-input-libinput-0.9.0/ChangeLog new/xf86-input-libinput-0.10.0/ChangeLog --- old/xf86-input-libinput-0.9.0/ChangeLog 2015-04-23 04:23:34.000000000 +0200 +++ new/xf86-input-libinput-0.10.0/ChangeLog 2015-05-21 02:20:59.000000000 +0200 @@ -1,3 +1,66 @@ +commit 158e3264cefa9e6ac3e2218027b212237b039ce6 +Author: Peter Hutterer <peter.hutte...@who-t.net> +Date: Thu May 21 09:52:40 2015 +1000 + + xf86-input-libinput 0.10.0 + + Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> + +commit 006c80263027d5c5bc4e26d1b61a412f8a444a2d +Author: Peter Hutterer <peter.hutte...@who-t.net> +Date: Wed May 20 13:37:06 2015 +1000 + + Group scroll distances into a struct + + Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> + +commit d6ce065cea25785a8d03d27d723846e583c55e3b +Author: Peter Hutterer <peter.hutte...@who-t.net> +Date: Wed Apr 29 09:30:14 2015 +1000 + + Add option "ButtonMapping" (#90206) + + With a long entry in the man page to detail what this option does. + Specifically, it's the xorg.conf equivalent to XSetPointerMapping(3), it + doesn't do any physical button remappings, merely the logical ones. If the + physical button isn't mapped to the right logical button by default, that's + either a libiput bug or an xkcd 1172 issue. + + X.Org Bug 90206 <http://bugs.freedesktop.org/show_bug.cgi?id=90206> + + Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> + Reviewed-by: Hans de Goede <hdego...@redhat.com> + +commit b9a21505766a972016f18a48437411d88b25bd8b +Author: Peter Hutterer <peter.hutte...@who-t.net> +Date: Wed Apr 29 09:18:44 2015 +1000 + + man: add two linebreaks to make things easier to visually parse + + Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> + Reviewed-by: Hans de Goede <hdego...@redhat.com> + +commit 9356471f3f975aeb47d0cca43f31317af9ba384a +Author: Peter Hutterer <peter.hutte...@who-t.net> +Date: Wed Apr 29 08:18:13 2015 +1000 + + Move the option parsing into helper functions + + No functional changes, though I did move a free() up a bit in the process (see + sendevents parsing). + + Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> + Reviewed-by: Hans de Goede <hdego...@redhat.com> + +commit d5fa03c3433637c0fa8cbbfb38dadcf384f06ac3 +Author: Peter Hutterer <peter.hutte...@who-t.net> +Date: Thu Apr 23 17:48:44 2015 +1000 + + Add a property for middle button emulation + + Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> + Reviewed-by: Hans de Goede <hdego...@redhat.com> + commit 446401bea9d0335273963f476e897d8c4916420e Author: Peter Hutterer <peter.hutte...@who-t.net> Date: Thu Apr 23 12:20:12 2015 +1000 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/xf86-input-libinput-0.9.0/configure.ac new/xf86-input-libinput-0.10.0/configure.ac --- old/xf86-input-libinput-0.9.0/configure.ac 2015-04-23 04:17:29.000000000 +0200 +++ new/xf86-input-libinput-0.10.0/configure.ac 2015-05-21 01:52:31.000000000 +0200 @@ -23,7 +23,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) AC_INIT([xf86-input-libinput], - [0.9.0], + [0.10.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xf86-input-libinput]) AC_CONFIG_SRCDIR([Makefile.am]) @@ -45,7 +45,7 @@ # Obtain compiler/linker options from server and required extensions PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10] xproto [inputproto >= 2.2]) -PKG_CHECK_MODULES(LIBINPUT, [libinput >= 0.11.0]) +PKG_CHECK_MODULES(LIBINPUT, [libinput >= 0.14.0]) # Define a configure option for an alternate input module directory AC_ARG_WITH(xorg-module-dir, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/xf86-input-libinput-0.9.0/include/libinput-properties.h new/xf86-input-libinput-0.10.0/include/libinput-properties.h --- old/xf86-input-libinput-0.9.0/include/libinput-properties.h 2015-03-18 00:15:40.000000000 +0100 +++ new/xf86-input-libinput-0.10.0/include/libinput-properties.h 2015-04-23 08:45:34.000000000 +0200 @@ -95,4 +95,11 @@ /* Click method: BOOL, 2 values in order buttonareas, clickfinger only one enabled at a time at max, read-only */ #define LIBINPUT_PROP_CLICK_METHOD_ENABLED_DEFAULT "libinput Click Method Enabled Default" + +/* Middle button emulation: BOOL, 1 value */ +#define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED "libinput Middle Emulation Enabled" + +/* Middle button emulation: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED_DEFAULT "libinput Middle Emulation Enabled Default" + #endif /* _LIBINPUT_PROPERTIES_H_ */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/xf86-input-libinput-0.9.0/man/libinput.man new/xf86-input-libinput-0.10.0/man/libinput.man --- old/xf86-input-libinput-0.9.0/man/libinput.man 2015-03-18 00:15:40.000000000 +0100 +++ new/xf86-input-libinput-0.10.0/man/libinput.man 2015-04-30 03:34:13.000000000 +0200 @@ -12,6 +12,7 @@ \ \ ... .B EndSection .fi + .SH NOTE This is the man page for the X input driver. If you are looking for the library documentation, go to @@ -30,6 +31,7 @@ directive (refer to __xconfigfile__(__filemansuffix__)) instead of manual per-device configuration. Devices configured in the __xconfigfile__(__filemansuffix__) are not hot-plug capable. + .SH CONFIGURATION DETAILS Please refer to __xconfigfile__(__filemansuffix__) for general configuration details and for options that can be used with all input drivers. This @@ -48,6 +50,19 @@ .BI "Option \*qAccelSpeed\*q \*q" float \*q Sets the pointer acceleration speed within the range [-1, 1] .TP 7 +.BI "Option \*qButtonMapping\*q \*q" string \*q +Sets the logical button mapping for this device, see +XSetPointerMapping(__libmansuffix__). The string must be a +space-separated list of button mappings in the order of the +logical buttons on the device, starting with button 1. +The default mapping is "1 2 3 ... 32". A mapping of 0 +deactivates the button. Multiple buttons can have the same mapping. +Invalid mapping strings are discarded and the default mapping +is used for all buttons. Buttons not specified in the user's mapping use the +default mapping. See section +.B BUTTON MAPPING +for more details. +.TP 7 .BI "Option \*qCalibrationMatrix\*q \*q" string \*q A string of 9 space-separated floating point numbers. Sets the calibration matrix to the 3x3 matrix where the first row is (abc), @@ -64,6 +79,10 @@ .BI "Option \*qLeftHanded\*q \*q" bool \*q Enables left-handed button orientation, i.e. swapping left and right buttons. .TP 7 +.BI "Option \*qMiddleEmulation\*q \*q" bool \*q +Enables middle button emulation. When enabled, pressing the left and right +buttons simultaneously produces a middle mouse button click. +.TP 7 .BI "Option \*qNaturalScrolling\*q \*q" bool \*q Enables or disables natural scrolling behavior. .TP 7 @@ -151,11 +170,41 @@ .BI "libinput Click Methods Enabled" 2 boolean values (8 bit, 0 or 1), in order "buttonareas", "clickfinger". Indicates which click methods are enabled on this device. +.TP 7 +.BI "libinput Middle Emulation Enabled" +1 boolean value (8 bit, 0 or 1). Indicates if middle emulation is enabled or +disabled. +.TP7 .PP The above properties have a .BI "libinput <property name> Default" equivalent that indicates the default value for this setting on this device. +.SH BUTTON MAPPING +X clients receive events with logical button numbers, where 1, 2, 3 +are usually interpreted as left, middle, right and logical buttons 4, 5, 6, +7 are usually interpreted as scroll up, down, left, right. The fourth and +fifth physical buttons on a device will thus send logical buttons 8 and 9. +The +.B ButtonMapping +option adjusts the logical button mapping, it does not affect how a physical +button is mapped to a logical button. +.PP +Traditionally, a device was set to left-handed button mode by applying a +button mapping of +.B "\*q3 2 1 ...\*q" +On systems using the +.B libinput +__xservername__ input driver it is recommended to use the +.B LeftHanded +option instead. +.PP +The +.B libinput +__xservername__ input driver does not use the button mapping after setup. +Use XSetPointerMapping(__libmansuffix__) to modify the button mapping at +runtime. + .SH AUTHORS Peter Hutterer .SH "SEE ALSO" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/xf86-input-libinput-0.9.0/src/libinput.c new/xf86-input-libinput-0.10.0/src/libinput.c --- old/xf86-input-libinput-0.9.0/src/libinput.c 2015-04-13 01:01:18.000000000 +0200 +++ new/xf86-input-libinput-0.10.0/src/libinput.c 2015-05-21 01:51:43.000000000 +0200 @@ -71,10 +71,12 @@ char *path; struct libinput_device *device; - int scroll_vdist; - int scroll_hdist; - int scroll_vdist_remainder; - int scroll_hdist_remainder; + struct { + int vdist; + int hdist; + int vdist_remainder; + int hdist_remainder; + } scroll; struct { double x; @@ -85,16 +87,19 @@ ValuatorMask *valuators; - struct { + struct options { BOOL tapping; BOOL natural_scrolling; BOOL left_handed; + BOOL middle_emulation; CARD32 sendevents; CARD32 scroll_button; /* xorg button number */ float speed; float matrix[9]; enum libinput_config_scroll_method scroll_method; enum libinput_config_click_method click_method; + + unsigned char btnmap[MAX_BUTTONS + 1]; } options; }; @@ -309,6 +314,13 @@ "Failed to set click method to %s\n", method); } + + if (libinput_device_config_middle_emulation_is_available(device) && + libinput_device_config_middle_emulation_set_enabled(device, + driver_data->options.middle_emulation) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set MiddleEmulation to %d\n", + driver_data->options.middle_emulation); } static int @@ -432,7 +444,6 @@ int nbuttons = 7; int i; - unsigned char btnmap[MAX_BUTTONS + 1]; Atom btnlabels[MAX_BUTTONS]; Atom axislabels[TOUCHPAD_NUM_AXES]; @@ -443,11 +454,11 @@ } } - init_button_map(btnmap, ARRAY_SIZE(btnmap)); init_button_labels(btnlabels, ARRAY_SIZE(btnlabels)); init_axis_labels(axislabels, ARRAY_SIZE(axislabels)); - InitPointerDeviceStruct((DevicePtr)dev, btnmap, + InitPointerDeviceStruct((DevicePtr)dev, + driver_data->options.btnmap, nbuttons, btnlabels, xf86libinput_ptr_ctl, @@ -465,8 +476,8 @@ XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y), min, max, res * 1000, 0, res * 1000, Relative); - SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll_hdist, 0); - SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll_vdist, 0); + SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.hdist, 0); + SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.vdist, 0); return Success; } @@ -480,7 +491,6 @@ int nbuttons = 7; int i; - unsigned char btnmap[MAX_BUTTONS + 1]; Atom btnlabels[MAX_BUTTONS]; Atom axislabels[TOUCHPAD_NUM_AXES]; @@ -491,11 +501,11 @@ } } - init_button_map(btnmap, ARRAY_SIZE(btnmap)); init_button_labels(btnlabels, ARRAY_SIZE(btnlabels)); init_axis_labels(axislabels, ARRAY_SIZE(axislabels)); - InitPointerDeviceStruct((DevicePtr)dev, btnmap, + InitPointerDeviceStruct((DevicePtr)dev, + driver_data->options.btnmap, nbuttons, btnlabels, xf86libinput_ptr_ctl, @@ -513,8 +523,8 @@ XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y), min, max, res * 1000, 0, res * 1000, Absolute); - SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll_hdist, 0); - SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll_vdist, 0); + SetScrollValuator(dev, 2, SCROLL_TYPE_HORIZONTAL, driver_data->scroll.hdist, 0); + SetScrollValuator(dev, 3, SCROLL_TYPE_VERTICAL, driver_data->scroll.vdist, 0); return Success; } @@ -581,6 +591,7 @@ xf86libinput_init_touch(InputInfoPtr pInfo) { DeviceIntPtr dev = pInfo->dev; + struct xf86libinput *driver_data = pInfo->private; int min, max, res; unsigned char btnmap[MAX_BUTTONS + 1]; Atom btnlabels[MAX_BUTTONS]; @@ -591,7 +602,8 @@ init_button_labels(btnlabels, ARRAY_SIZE(btnlabels)); init_axis_labels(axislabels, ARRAY_SIZE(axislabels)); - InitPointerDeviceStruct((DevicePtr)dev, btnmap, + InitPointerDeviceStruct((DevicePtr)dev, + driver_data->options.btnmap, nbuttons, btnlabels, xf86libinput_ptr_ctl, @@ -758,7 +770,7 @@ if (libinput_event_pointer_has_axis(event, axis)) { if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) { value = libinput_event_pointer_get_axis_value_discrete(event, axis); - value *= driver_data->scroll_vdist; + value *= driver_data->scroll.vdist; } else { value = libinput_event_pointer_get_axis_value(event, axis); } @@ -768,7 +780,7 @@ if (libinput_event_pointer_has_axis(event, axis)) { if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) { value = libinput_event_pointer_get_axis_value_discrete(event, axis); - value *= driver_data->scroll_hdist; + value *= driver_data->scroll.hdist; } else { value = libinput_event_pointer_get_axis_value(event, axis); } @@ -965,208 +977,354 @@ LogVMessageVerb(type, verbosity, format, args); } -static void -xf86libinput_parse_options(InputInfoPtr pInfo, - struct xf86libinput *driver_data, - struct libinput_device *device) +static inline BOOL +xf86libinput_parse_tap_option(InputInfoPtr pInfo, + struct libinput_device *device) { - uint32_t scroll_methods; - uint32_t click_methods; + BOOL tap; - if (libinput_device_config_tap_get_finger_count(device) > 0) { - BOOL tap = xf86SetBoolOption(pInfo->options, - "Tapping", - libinput_device_config_tap_get_enabled(device)); - if (libinput_device_config_tap_set_enabled(device, tap) != - LIBINPUT_CONFIG_STATUS_SUCCESS) { - xf86IDrvMsg(pInfo, X_ERROR, - "Failed to set Tapping to %d\n", - tap); - tap = libinput_device_config_tap_get_enabled(device); - } - driver_data->options.tapping = tap; + if (libinput_device_config_tap_get_finger_count(device) == 0) + return FALSE; + + tap = xf86SetBoolOption(pInfo->options, + "Tapping", + libinput_device_config_tap_get_enabled(device)); + + if (libinput_device_config_tap_set_enabled(device, tap) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping to %d\n", + tap); + tap = libinput_device_config_tap_get_enabled(device); } - if (libinput_device_config_accel_is_available(device)) { - double speed = xf86SetRealOption(pInfo->options, - "AccelSpeed", - libinput_device_config_accel_get_speed(device)); - if (libinput_device_config_accel_set_speed(device, speed) != - LIBINPUT_CONFIG_STATUS_SUCCESS) { - xf86IDrvMsg(pInfo, X_ERROR, - "Invalid speed %.2f, using 0 instead\n", - speed); - driver_data->options.speed = libinput_device_config_accel_get_speed(device); - } - driver_data->options.speed = speed; + return tap; +} + +static inline double +xf86libinput_parse_accel_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + double speed; + + if (!libinput_device_config_accel_is_available(device)) + return 0.0; + + speed = xf86SetRealOption(pInfo->options, + "AccelSpeed", + libinput_device_config_accel_get_speed(device)); + if (libinput_device_config_accel_set_speed(device, speed) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Invalid speed %.2f, using 0 instead\n", + speed); + speed = libinput_device_config_accel_get_speed(device); } - if (libinput_device_config_scroll_has_natural_scroll(device)) { - BOOL natural_scroll = xf86SetBoolOption(pInfo->options, - "NaturalScrolling", - libinput_device_config_scroll_get_natural_scroll_enabled(device)); - if (libinput_device_config_scroll_set_natural_scroll_enabled(device, - natural_scroll) != - LIBINPUT_CONFIG_STATUS_SUCCESS) { - xf86IDrvMsg(pInfo, X_ERROR, - "Failed to set NaturalScrolling to %d\n", - natural_scroll); + return speed; +} - natural_scroll = libinput_device_config_scroll_get_natural_scroll_enabled(device); - } - driver_data->options.natural_scrolling = natural_scroll; +static inline BOOL +xf86libinput_parse_natscroll_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL natural_scroll; + + if (!libinput_device_config_scroll_has_natural_scroll(device)) + return FALSE; + + natural_scroll = xf86SetBoolOption(pInfo->options, + "NaturalScrolling", + libinput_device_config_scroll_get_natural_scroll_enabled(device)); + if (libinput_device_config_scroll_set_natural_scroll_enabled(device, + natural_scroll) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set NaturalScrolling to %d\n", + natural_scroll); + + natural_scroll = libinput_device_config_scroll_get_natural_scroll_enabled(device); } - if (libinput_device_config_send_events_get_modes(device) != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED) { - char *strmode; - enum libinput_config_send_events_mode mode = - libinput_device_config_send_events_get_mode(device); - - strmode = xf86SetStrOption(pInfo->options, - "SendEventsMode", - NULL); - if (strmode) { - if (strcmp(strmode, "enabled") == 0) - mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; - else if (strcmp(strmode, "disabled") == 0) - mode = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; - else if (strcmp(strmode, "disabled-on-external-mouse") == 0) - mode = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; - else - xf86IDrvMsg(pInfo, X_ERROR, - "Invalid SendeventsMode: %s\n", - strmode); - } + return natural_scroll; +} + +static inline enum libinput_config_send_events_mode +xf86libinput_parse_sendevents_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + char *strmode; + enum libinput_config_send_events_mode mode; - if (libinput_device_config_send_events_set_mode(device, mode) != - LIBINPUT_CONFIG_STATUS_SUCCESS) { + if (libinput_device_config_send_events_get_modes(device) == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED) + return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; + + mode = libinput_device_config_send_events_get_mode(device); + strmode = xf86SetStrOption(pInfo->options, + "SendEventsMode", + NULL); + if (strmode) { + if (strcmp(strmode, "enabled") == 0) + mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; + else if (strcmp(strmode, "disabled") == 0) + mode = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; + else if (strcmp(strmode, "disabled-on-external-mouse") == 0) + mode = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; + else xf86IDrvMsg(pInfo, X_ERROR, - "Failed to set SendEventsMode %u\n", mode); - mode = libinput_device_config_send_events_get_mode(device); - } - driver_data->options.sendevents = mode; + "Invalid SendeventsMode: %s\n", + strmode); free(strmode); } - if (libinput_device_config_calibration_has_matrix(device)) { - char *str; - float matrix[9] = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; - - libinput_device_config_calibration_get_matrix(device, - matrix); - memcpy(driver_data->options.matrix, matrix, sizeof(matrix)); - - if ((str = xf86CheckStrOption(pInfo->options, - "CalibrationMatrix", - NULL))) { - int num_calibration = sscanf(str, "%f %f %f %f %f %f %f %f %f ", - &matrix[0], &matrix[1], - &matrix[2], &matrix[3], - &matrix[4], &matrix[5], - &matrix[6], &matrix[7], - &matrix[8]); - if (num_calibration != 9) { - xf86IDrvMsg(pInfo, X_ERROR, - "Invalid matrix: %s, using default\n", str); - } else if (libinput_device_config_calibration_set_matrix(device, - matrix) == - LIBINPUT_CONFIG_STATUS_SUCCESS) { - memcpy(driver_data->options.matrix, matrix, sizeof(matrix)); - } else - xf86IDrvMsg(pInfo, X_ERROR, - "Failed to apply matrix: %s, using default\n", str); - - free(str); - } + if (libinput_device_config_send_events_set_mode(device, mode) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set SendEventsMode %u\n", mode); + mode = libinput_device_config_send_events_get_mode(device); } - if (libinput_device_config_left_handed_is_available(device)) { - BOOL left_handed = xf86SetBoolOption(pInfo->options, - "LeftHanded", - libinput_device_config_left_handed_get(device)); - if (libinput_device_config_left_handed_set(device, - left_handed) != - LIBINPUT_CONFIG_STATUS_SUCCESS) { + return mode; +} + +static inline void +xf86libinput_parse_calibration_option(InputInfoPtr pInfo, + struct libinput_device *device, + float matrix_out[9]) +{ + char *str; + float matrix[9] = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; + + memcpy(matrix_out, matrix, sizeof(matrix)); + + if (!libinput_device_config_calibration_has_matrix(device)) + return; + + libinput_device_config_calibration_get_matrix(device, matrix); + memcpy(matrix_out, matrix, sizeof(matrix)); + + if ((str = xf86CheckStrOption(pInfo->options, + "CalibrationMatrix", + NULL))) { + int num_calibration = sscanf(str, "%f %f %f %f %f %f %f %f %f ", + &matrix[0], &matrix[1], + &matrix[2], &matrix[3], + &matrix[4], &matrix[5], + &matrix[6], &matrix[7], + &matrix[8]); + if (num_calibration != 9) { xf86IDrvMsg(pInfo, X_ERROR, - "Failed to set LeftHanded to %d\n", - left_handed); - left_handed = libinput_device_config_left_handed_get(device); - } - driver_data->options.left_handed = left_handed; + "Invalid matrix: %s, using default\n", str); + } else if (libinput_device_config_calibration_set_matrix(device, + matrix) == + LIBINPUT_CONFIG_STATUS_SUCCESS) { + memcpy(matrix_out, matrix, sizeof(matrix)); + } else + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to apply matrix: %s, using default\n", str); + free(str); + } +} + +static inline BOOL +xf86libinput_parse_lefthanded_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL left_handed; + + if (!libinput_device_config_left_handed_is_available(device)) + return FALSE; + + left_handed = xf86SetBoolOption(pInfo->options, + "LeftHanded", + libinput_device_config_left_handed_get(device)); + if (libinput_device_config_left_handed_set(device, + left_handed) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set LeftHanded to %d\n", + left_handed); + left_handed = libinput_device_config_left_handed_get(device); } + return left_handed; +} + +static inline enum libinput_config_scroll_method +xf86libinput_parse_scroll_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + uint32_t scroll_methods; + enum libinput_config_scroll_method m; + char *method; + scroll_methods = libinput_device_config_scroll_get_methods(device); - if (scroll_methods != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) { - enum libinput_config_scroll_method m; - char *method = xf86SetStrOption(pInfo->options, - "ScrollMethod", - NULL); - - if (!method) - m = libinput_device_config_scroll_get_method(device); - else if (strncasecmp(method, "twofinger", 9) == 0) - m = LIBINPUT_CONFIG_SCROLL_2FG; - else if (strncasecmp(method, "edge", 4) == 0) - m = LIBINPUT_CONFIG_SCROLL_EDGE; - else if (strncasecmp(method, "button", 6) == 0) - m = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; - else if (strncasecmp(method, "none", 4) == 0) - m = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; - else { - xf86IDrvMsg(pInfo, X_ERROR, - "Unknown scroll method '%s'. Using default.\n", - method); - m = libinput_device_config_scroll_get_method(device); - } + if (scroll_methods == LIBINPUT_CONFIG_SCROLL_NO_SCROLL) + return LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + + method = xf86SetStrOption(pInfo->options, "ScrollMethod", NULL); + if (!method) + m = libinput_device_config_scroll_get_method(device); + else if (strncasecmp(method, "twofinger", 9) == 0) + m = LIBINPUT_CONFIG_SCROLL_2FG; + else if (strncasecmp(method, "edge", 4) == 0) + m = LIBINPUT_CONFIG_SCROLL_EDGE; + else if (strncasecmp(method, "button", 6) == 0) + m = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; + else if (strncasecmp(method, "none", 4) == 0) + m = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + else { + xf86IDrvMsg(pInfo, X_ERROR, + "Unknown scroll method '%s'. Using default.\n", + method); + m = libinput_device_config_scroll_get_method(device); + } + + free(method); + return m; +} + +static inline unsigned int +xf86libinput_parse_scrollbutton_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + unsigned int b; + CARD32 scroll_button; + + if ((libinput_device_config_scroll_get_methods(device) & + LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) == 0) + return 0; - driver_data->options.scroll_method = m; - free(method); + b = btn_linux2xorg(libinput_device_config_scroll_get_button(device)); + scroll_button = xf86SetIntOption(pInfo->options, + "ScrollButton", + b); + + b = btn_xorg2linux(scroll_button); + + if (libinput_device_config_scroll_set_button(device, + b) != LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set ScrollButton to %u\n", + scroll_button); + scroll_button = btn_linux2xorg(libinput_device_config_scroll_get_button(device)); } + return scroll_button; +} - if (libinput_device_config_scroll_get_methods(device) & - LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) { - unsigned int b = btn_linux2xorg(libinput_device_config_scroll_get_button(device)); - CARD32 scroll_button = xf86SetIntOption(pInfo->options, - "ScrollButton", - b); +static inline unsigned int +xf86libinput_parse_clickmethod_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + uint32_t click_methods = libinput_device_config_click_get_methods(device); + enum libinput_config_click_method m; + char *method; - b = btn_xorg2linux(scroll_button); + if (click_methods == LIBINPUT_CONFIG_CLICK_METHOD_NONE) + return LIBINPUT_CONFIG_CLICK_METHOD_NONE; - if (libinput_device_config_scroll_set_button(device, - b) != LIBINPUT_CONFIG_STATUS_SUCCESS) { - xf86IDrvMsg(pInfo, X_ERROR, - "Failed to set ScrollButton to %u\n", - scroll_button); - scroll_button = btn_linux2xorg(libinput_device_config_scroll_get_button(device)); - } - driver_data->options.scroll_button = scroll_button; + method = xf86SetStrOption(pInfo->options, "ClickMethod", NULL); + + if (!method) + m = libinput_device_config_click_get_method(device); + else if (strncasecmp(method, "buttonareas", 11) == 0) + m = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; + else if (strncasecmp(method, "clickfinger", 11) == 0) + m = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; + else if (strncasecmp(method, "none", 4) == 0) + m = LIBINPUT_CONFIG_CLICK_METHOD_NONE; + else { + xf86IDrvMsg(pInfo, X_ERROR, + "Unknown click method '%s'. Using default.\n", + method); + m = libinput_device_config_click_get_method(device); } + free(method); - click_methods = libinput_device_config_click_get_methods(device); - if (click_methods != LIBINPUT_CONFIG_CLICK_METHOD_NONE) { - enum libinput_config_click_method m; - char *method = xf86SetStrOption(pInfo->options, - "ClickMethod", - NULL); - - if (!method) - m = libinput_device_config_click_get_method(device); - else if (strncasecmp(method, "buttonareas", 11) == 0) - m = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; - else if (strncasecmp(method, "clickfinger", 11) == 0) - m = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; - else if (strncasecmp(method, "none", 4) == 0) - m = LIBINPUT_CONFIG_CLICK_METHOD_NONE; - else { + return m; +} + +static inline BOOL +xf86libinput_parse_middleemulation_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL enabled; + + if (!libinput_device_config_middle_emulation_is_available(device)) + return FALSE; + + enabled = xf86SetBoolOption(pInfo->options, + "MiddleEmulation", + libinput_device_config_middle_emulation_get_default_enabled(device)); + if (libinput_device_config_middle_emulation_set_enabled(device, enabled) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set MiddleEmulation to %d\n", + enabled); + enabled = libinput_device_config_middle_emulation_get_enabled(device); + } + + return enabled; +} + +static void +xf86libinput_parse_buttonmap_option(InputInfoPtr pInfo, + unsigned char *btnmap, + size_t size) +{ + const int MAXBUTTONS = 32; + char *mapping, *map, *s = NULL; + int idx = 1; + + init_button_map(btnmap, size); + + mapping = xf86SetStrOption(pInfo->options, "ButtonMapping", NULL); + if (!mapping) + return; + + map = mapping; + do + { + unsigned long int btn = strtoul(map, &s, 10); + + if (s == map || btn > MAXBUTTONS) + { xf86IDrvMsg(pInfo, X_ERROR, - "Unknown click method '%s'. Using default.\n", - method); - m = libinput_device_config_click_get_method(device); + "... Invalid button mapping. Using defaults\n"); + init_button_map(btnmap, size); + break; } - driver_data->options.click_method = m; - free(method); - } + btnmap[idx++] = btn; + map = s; + } while (s && *s != '\0' && idx < MAXBUTTONS); + + free(mapping); +} + +static void +xf86libinput_parse_options(InputInfoPtr pInfo, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + struct options *options = &driver_data->options; + + /* libinput options */ + options->tapping = xf86libinput_parse_tap_option(pInfo, device); + options->speed = xf86libinput_parse_accel_option(pInfo, device); + options->natural_scrolling = xf86libinput_parse_natscroll_option(pInfo, device); + options->sendevents = xf86libinput_parse_sendevents_option(pInfo, device); + options->left_handed = xf86libinput_parse_lefthanded_option(pInfo, device); + options->scroll_method = xf86libinput_parse_scroll_option(pInfo, device); + options->scroll_button = xf86libinput_parse_scrollbutton_option(pInfo, device); + options->click_method = xf86libinput_parse_clickmethod_option(pInfo, device); + options->middle_emulation = xf86libinput_parse_middleemulation_option(pInfo, device); + xf86libinput_parse_calibration_option(pInfo, device, driver_data->options.matrix); + + /* non-libinput options */ + xf86libinput_parse_buttonmap_option(pInfo, + options->btnmap, + sizeof(options->btnmap)); } static int @@ -1193,8 +1351,8 @@ if (!driver_data->valuators) goto fail; - driver_data->scroll_vdist = 15; - driver_data->scroll_hdist = 15; + driver_data->scroll.vdist = 15; + driver_data->scroll.hdist = 15; path = xf86SetStrOption(pInfo->options, "Device", NULL); if (!path) @@ -1347,6 +1505,8 @@ static Atom prop_click_methods_available; static Atom prop_click_method_enabled; static Atom prop_click_method_default; +static Atom prop_middle_emulation; +static Atom prop_middle_emulation_default; /* general properties */ static Atom prop_float; @@ -1694,6 +1854,37 @@ return Success; } +static inline int +LibinputSetPropertyMiddleEmulation(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->device; + BOOL* data; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + if (checkonly) { + if (*data != 0 && *data != 1) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (!libinput_device_config_middle_emulation_is_available(device)) + return BadMatch; + } else { + driver_data->options.middle_emulation = *data; + } + + return Success; +} + static int LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, BOOL checkonly) @@ -1725,6 +1916,8 @@ return BadAccess; /* read-only */ else if (atom == prop_click_method_enabled) rc = LibinputSetPropertyClickMethod(dev, atom, val, checkonly); + else if (atom == prop_middle_emulation) + rc = LibinputSetPropertyMiddleEmulation(dev, atom, val, checkonly); else if (atom == prop_device || atom == prop_product_id || atom == prop_tap_default || atom == prop_calibration_default || @@ -1734,7 +1927,8 @@ atom == prop_left_handed_default || atom == prop_scroll_method_default || atom == prop_scroll_button_default || - atom == prop_click_method_default) + atom == prop_click_method_default || + atom == prop_middle_emulation_default) return BadAccess; /* read-only */ else return Success; @@ -2117,6 +2311,32 @@ } static void +LibinputInitMiddleEmulationProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL middle = driver_data->options.middle_emulation; + + if (!libinput_device_config_middle_emulation_is_available(device)) + return; + + prop_middle_emulation = LibinputMakeProperty(dev, + LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED, + XA_INTEGER, + 8, + 1, + &middle); + if (!prop_middle_emulation) + return; + + middle = libinput_device_config_middle_emulation_get_default_enabled(device); + prop_middle_emulation_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED_DEFAULT, + XA_INTEGER, 8, + 1, &middle); +} + +static void LibinputInitProperty(DeviceIntPtr dev) { InputInfoPtr pInfo = dev->public.devicePrivate; @@ -2136,6 +2356,7 @@ LibinputInitLeftHandedProperty(dev, driver_data, device); LibinputInitScrollMethodsProperty(dev, driver_data, device); LibinputInitClickMethodsProperty(dev, driver_data, device); + LibinputInitMiddleEmulationProperty(dev, driver_data, device); /* Device node property, read-only */ device_node = driver_data->path;