diff options
author | Stephen Chandler Paul <cpaul@redhat.com> | 2015-08-02 14:18:10 -0400 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2015-08-04 14:14:48 +1000 |
commit | 223be9f62bc614c4bfa2836c5b0aaded70cadf9c (patch) | |
tree | 257eb63213fddba826ee7b95e7d5ba8367711c76 | |
parent | d3ee745a2461c09c86916f2ecf97426b6145ee09 (diff) |
Add a property for Disable While Typing
Signed-off-by: Stephen Chandler Paul <cpaul@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | include/libinput-properties.h | 6 | ||||
-rw-r--r-- | man/libinput.man | 8 | ||||
-rw-r--r-- | src/libinput.c | 97 |
4 files changed, 111 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index e7de887..1ee6665 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ XORG_DEFAULT_OPTIONS # 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.20.0]) +PKG_CHECK_MODULES(LIBINPUT, [libinput >= 0.21.0]) # Define a configure option for an alternate input module directory AC_ARG_WITH(xorg-module-dir, diff --git a/include/libinput-properties.h b/include/libinput-properties.h index 6135dc8..f54cee7 100644 --- a/include/libinput-properties.h +++ b/include/libinput-properties.h @@ -108,4 +108,10 @@ /* Middle button emulation: BOOL, 1 value, read-only */ #define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED_DEFAULT "libinput Middle Emulation Enabled Default" +/* Disable while typing: BOOL, 1 value */ +#define LIBINPUT_PROP_DISABLE_WHILE_TYPING "libinput Disable While Typing Enabled" + +/* Disable while typing: BOOL, 1 value, read-only */ +#define LIBINPUT_PROP_DISABLE_WHILE_TYPING_DEFAULT "libinput Disable While Typing Enabled Default" + #endif /* _LIBINPUT_PROPERTIES_H_ */ diff --git a/man/libinput.man b/man/libinput.man index 0ce5e6d..ac546e6 100644 --- a/man/libinput.man +++ b/man/libinput.man @@ -119,6 +119,10 @@ Enables or disables drag lock during tapping behavior. When enabled, a finger up during tap-and-drag will not immediately release the button. If the finger is set down again within the timeout, the draging process continues. +.TP 7 +.BI "Option \*qDisableWhileTyping\*q \*q" bool \*q +Indicates if the touchpad should be disabled while typing on the keyboard +(this does not apply to modifier keys such as Ctrl or Alt). .PP For all options, the options are only parsed if the device supports that configuration option. For all options, the default value is the one used by @@ -187,6 +191,10 @@ Indicates which click methods are enabled on this device. .BI "libinput Middle Emulation Enabled" 1 boolean value (8 bit, 0 or 1). Indicates if middle emulation is enabled or disabled. +.TP 7 +.BI "libinput Disable While Typing Enabled" +1 boolean value (8 bit, 0 or 1). Indicates if disable while typing is +enabled or disabled. .TP7 .PP The above properties have a diff --git a/src/libinput.c b/src/libinput.c index c03777a..49f73c9 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -102,6 +102,7 @@ struct xf86libinput { BOOL natural_scrolling; BOOL left_handed; BOOL middle_emulation; + BOOL disable_while_typing; CARD32 sendevents; CARD32 scroll_button; /* xorg button number */ float speed; @@ -338,6 +339,13 @@ LibinputApplyConfig(DeviceIntPtr dev) xf86IDrvMsg(pInfo, X_ERROR, "Failed to set MiddleEmulation to %d\n", driver_data->options.middle_emulation); + + if (libinput_device_config_dwt_is_available(device) && + libinput_device_config_dwt_set_enabled(device, + driver_data->options.disable_while_typing) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set DisableWhileTyping to %d\n", + driver_data->options.disable_while_typing); } static int @@ -1337,6 +1345,29 @@ xf86libinput_parse_middleemulation_option(InputInfoPtr pInfo, return enabled; } +static inline BOOL +xf86libinput_parse_disablewhiletyping_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL enabled; + + if (!libinput_device_config_dwt_is_available(device)) + return FALSE; + + enabled = xf86SetBoolOption(pInfo->options, + "DisableWhileTyping", + libinput_device_config_dwt_get_default_enabled(device)); + if (libinput_device_config_dwt_set_enabled(device, enabled) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set DisableWhileTyping to %d\n", + enabled); + enabled = libinput_device_config_dwt_get_enabled(device); + } + + return enabled; +} + static void xf86libinput_parse_buttonmap_option(InputInfoPtr pInfo, unsigned char *btnmap, @@ -1390,6 +1421,7 @@ xf86libinput_parse_options(InputInfoPtr pInfo, 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); + options->disable_while_typing = xf86libinput_parse_disablewhiletyping_option(pInfo, device); xf86libinput_parse_calibration_option(pInfo, device, driver_data->options.matrix); /* non-libinput options */ @@ -1586,6 +1618,8 @@ static Atom prop_click_method_enabled; static Atom prop_click_method_default; static Atom prop_middle_emulation; static Atom prop_middle_emulation_default; +static Atom prop_disable_while_typing; +static Atom prop_disable_while_typing_default; /* general properties */ static Atom prop_float; @@ -1995,6 +2029,37 @@ LibinputSetPropertyMiddleEmulation(DeviceIntPtr dev, return Success; } +static inline int +LibinputSetPropertyDisableWhileTyping(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_dwt_is_available(device)) + return BadMatch; + } else { + driver_data->options.disable_while_typing = *data; + } + + return Success; +} + static int LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, BOOL checkonly) @@ -2030,6 +2095,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, rc = LibinputSetPropertyClickMethod(dev, atom, val, checkonly); else if (atom == prop_middle_emulation) rc = LibinputSetPropertyMiddleEmulation(dev, atom, val, checkonly); + else if (atom == prop_disable_while_typing) + rc = LibinputSetPropertyDisableWhileTyping(dev, atom, val, checkonly); else if (atom == prop_device || atom == prop_product_id || atom == prop_tap_default || atom == prop_tap_drag_lock_default || @@ -2041,7 +2108,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, atom == prop_scroll_method_default || atom == prop_scroll_button_default || atom == prop_click_method_default || - atom == prop_middle_emulation_default) + atom == prop_middle_emulation_default || + atom == prop_disable_while_typing_default) return BadAccess; /* read-only */ else return Success; @@ -2471,6 +2539,32 @@ LibinputInitMiddleEmulationProperty(DeviceIntPtr dev, } static void +LibinputInitDisableWhileTypingProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL dwt = driver_data->options.disable_while_typing; + + if (!libinput_device_config_dwt_is_available(device)) + return; + + prop_disable_while_typing = LibinputMakeProperty(dev, + LIBINPUT_PROP_DISABLE_WHILE_TYPING, + XA_INTEGER, + 8, + 1, + &dwt); + if (!prop_disable_while_typing) + return; + + dwt = libinput_device_config_dwt_get_default_enabled(device); + prop_disable_while_typing_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_DISABLE_WHILE_TYPING_DEFAULT, + XA_INTEGER, 8, + 1, &dwt); +} + +static void LibinputInitProperty(DeviceIntPtr dev) { InputInfoPtr pInfo = dev->public.devicePrivate; @@ -2492,6 +2586,7 @@ LibinputInitProperty(DeviceIntPtr dev) LibinputInitScrollMethodsProperty(dev, driver_data, device); LibinputInitClickMethodsProperty(dev, driver_data, device); LibinputInitMiddleEmulationProperty(dev, driver_data, device); + LibinputInitDisableWhileTypingProperty(dev, driver_data, device); /* Device node property, read-only */ device_node = driver_data->path; |