summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStephen Chandler Paul <cpaul@redhat.com>2015-08-02 14:18:10 -0400
committerPeter Hutterer <peter.hutterer@who-t.net>2015-08-04 14:14:48 +1000
commit223be9f62bc614c4bfa2836c5b0aaded70cadf9c (patch)
tree257eb63213fddba826ee7b95e7d5ba8367711c76 /src
parentd3ee745a2461c09c86916f2ecf97426b6145ee09 (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>
Diffstat (limited to 'src')
-rw-r--r--src/libinput.c97
1 files changed, 96 insertions, 1 deletions
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;