Commit 223be9f6 authored by Stephen Chandler Paul's avatar Stephen Chandler Paul Committed by Peter Hutterer

Add a property for Disable While Typing

Signed-off-by: 's avatarStephen Chandler Paul <cpaul@redhat.com>
Reviewed-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent d3ee745a
...@@ -45,7 +45,7 @@ XORG_DEFAULT_OPTIONS ...@@ -45,7 +45,7 @@ XORG_DEFAULT_OPTIONS
# Obtain compiler/linker options from server and required extensions # Obtain compiler/linker options from server and required extensions
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10] xproto [inputproto >= 2.2]) 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 # Define a configure option for an alternate input module directory
AC_ARG_WITH(xorg-module-dir, AC_ARG_WITH(xorg-module-dir,
......
...@@ -108,4 +108,10 @@ ...@@ -108,4 +108,10 @@
/* Middle button emulation: BOOL, 1 value, read-only */ /* Middle button emulation: BOOL, 1 value, read-only */
#define LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED_DEFAULT "libinput Middle Emulation Enabled Default" #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_ */ #endif /* _LIBINPUT_PROPERTIES_H_ */
...@@ -119,6 +119,10 @@ Enables or disables drag lock during tapping behavior. When enabled, a ...@@ -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 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 the finger is set down again within the timeout, the draging process
continues. 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 .PP
For all options, the options are only parsed if the device supports that 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 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. ...@@ -187,6 +191,10 @@ Indicates which click methods are enabled on this device.
.BI "libinput Middle Emulation Enabled" .BI "libinput Middle Emulation Enabled"
1 boolean value (8 bit, 0 or 1). Indicates if middle emulation is enabled or 1 boolean value (8 bit, 0 or 1). Indicates if middle emulation is enabled or
disabled. 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 .TP7
.PP .PP
The above properties have a The above properties have a
......
...@@ -102,6 +102,7 @@ struct xf86libinput { ...@@ -102,6 +102,7 @@ struct xf86libinput {
BOOL natural_scrolling; BOOL natural_scrolling;
BOOL left_handed; BOOL left_handed;
BOOL middle_emulation; BOOL middle_emulation;
BOOL disable_while_typing;
CARD32 sendevents; CARD32 sendevents;
CARD32 scroll_button; /* xorg button number */ CARD32 scroll_button; /* xorg button number */
float speed; float speed;
...@@ -338,6 +339,13 @@ LibinputApplyConfig(DeviceIntPtr dev) ...@@ -338,6 +339,13 @@ LibinputApplyConfig(DeviceIntPtr dev)
xf86IDrvMsg(pInfo, X_ERROR, xf86IDrvMsg(pInfo, X_ERROR,
"Failed to set MiddleEmulation to %d\n", "Failed to set MiddleEmulation to %d\n",
driver_data->options.middle_emulation); 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 static int
...@@ -1337,6 +1345,29 @@ xf86libinput_parse_middleemulation_option(InputInfoPtr pInfo, ...@@ -1337,6 +1345,29 @@ xf86libinput_parse_middleemulation_option(InputInfoPtr pInfo,
return enabled; 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 static void
xf86libinput_parse_buttonmap_option(InputInfoPtr pInfo, xf86libinput_parse_buttonmap_option(InputInfoPtr pInfo,
unsigned char *btnmap, unsigned char *btnmap,
...@@ -1390,6 +1421,7 @@ xf86libinput_parse_options(InputInfoPtr pInfo, ...@@ -1390,6 +1421,7 @@ xf86libinput_parse_options(InputInfoPtr pInfo,
options->scroll_button = xf86libinput_parse_scrollbutton_option(pInfo, device); options->scroll_button = xf86libinput_parse_scrollbutton_option(pInfo, device);
options->click_method = xf86libinput_parse_clickmethod_option(pInfo, device); options->click_method = xf86libinput_parse_clickmethod_option(pInfo, device);
options->middle_emulation = xf86libinput_parse_middleemulation_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); xf86libinput_parse_calibration_option(pInfo, device, driver_data->options.matrix);
/* non-libinput options */ /* non-libinput options */
...@@ -1586,6 +1618,8 @@ static Atom prop_click_method_enabled; ...@@ -1586,6 +1618,8 @@ static Atom prop_click_method_enabled;
static Atom prop_click_method_default; static Atom prop_click_method_default;
static Atom prop_middle_emulation; static Atom prop_middle_emulation;
static Atom prop_middle_emulation_default; static Atom prop_middle_emulation_default;
static Atom prop_disable_while_typing;
static Atom prop_disable_while_typing_default;
/* general properties */ /* general properties */
static Atom prop_float; static Atom prop_float;
...@@ -1995,6 +2029,37 @@ LibinputSetPropertyMiddleEmulation(DeviceIntPtr dev, ...@@ -1995,6 +2029,37 @@ LibinputSetPropertyMiddleEmulation(DeviceIntPtr dev,
return Success; 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 static int
LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly) BOOL checkonly)
...@@ -2030,6 +2095,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, ...@@ -2030,6 +2095,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
rc = LibinputSetPropertyClickMethod(dev, atom, val, checkonly); rc = LibinputSetPropertyClickMethod(dev, atom, val, checkonly);
else if (atom == prop_middle_emulation) else if (atom == prop_middle_emulation)
rc = LibinputSetPropertyMiddleEmulation(dev, atom, val, checkonly); 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 || else if (atom == prop_device || atom == prop_product_id ||
atom == prop_tap_default || atom == prop_tap_default ||
atom == prop_tap_drag_lock_default || atom == prop_tap_drag_lock_default ||
...@@ -2041,7 +2108,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, ...@@ -2041,7 +2108,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
atom == prop_scroll_method_default || atom == prop_scroll_method_default ||
atom == prop_scroll_button_default || atom == prop_scroll_button_default ||
atom == prop_click_method_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 */ return BadAccess; /* read-only */
else else
return Success; return Success;
...@@ -2470,6 +2538,32 @@ LibinputInitMiddleEmulationProperty(DeviceIntPtr dev, ...@@ -2470,6 +2538,32 @@ LibinputInitMiddleEmulationProperty(DeviceIntPtr dev,
1, &middle); 1, &middle);
} }
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 static void
LibinputInitProperty(DeviceIntPtr dev) LibinputInitProperty(DeviceIntPtr dev)
{ {
...@@ -2492,6 +2586,7 @@ LibinputInitProperty(DeviceIntPtr dev) ...@@ -2492,6 +2586,7 @@ LibinputInitProperty(DeviceIntPtr dev)
LibinputInitScrollMethodsProperty(dev, driver_data, device); LibinputInitScrollMethodsProperty(dev, driver_data, device);
LibinputInitClickMethodsProperty(dev, driver_data, device); LibinputInitClickMethodsProperty(dev, driver_data, device);
LibinputInitMiddleEmulationProperty(dev, driver_data, device); LibinputInitMiddleEmulationProperty(dev, driver_data, device);
LibinputInitDisableWhileTypingProperty(dev, driver_data, device);
/* Device node property, read-only */ /* Device node property, read-only */
device_node = driver_data->path; device_node = driver_data->path;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment