[PATCH libinput 1/2] Add a configuration interface for enabling/disabling disable-while-typing

Hans de Goede hdegoede at redhat.com
Wed Jul 22 06:01:52 PDT 2015


Hi,

On 13-07-15 04:46, Peter Hutterer wrote:
> DWT can interfere with some applications where keyboard and touchpad use at
> the same time is common, e.g. games but also anything that requires a
> combination of frequent pointer motion and use of keyboard shortcuts.
>
> Expose a toggle to disable DWT where needed.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=90624
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

Series looks good to me:

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans

> ---
>   src/libinput-private.h        | 12 ++++++
>   src/libinput.c                | 42 ++++++++++++++++++++
>   src/libinput.h                | 90 +++++++++++++++++++++++++++++++++++++++++++
>   src/libinput.sym              |  4 ++
>   tools/event-debug.c           |  8 ++++
>   tools/libinput-list-devices.c | 14 +++++++
>   tools/shared.c                | 16 ++++++++
>   tools/shared.h                |  1 +
>   8 files changed, 187 insertions(+)
>
> diff --git a/src/libinput-private.h b/src/libinput-private.h
> index d9dcffc..7362c63 100644
> --- a/src/libinput-private.h
> +++ b/src/libinput-private.h
> @@ -196,6 +196,17 @@ struct libinput_device_config_middle_emulation {
>   			 struct libinput_device *device);
>   };
>
> +struct libinput_device_config_dwt {
> +	int (*is_available)(struct libinput_device *device);
> +	enum libinput_config_status (*set_enabled)(
> +			 struct libinput_device *device,
> +			 enum libinput_config_dwt_state enable);
> +	enum libinput_config_dwt_state (*get_enabled)(
> +			 struct libinput_device *device);
> +	enum libinput_config_dwt_state (*get_default_enabled)(
> +			 struct libinput_device *device);
> +};
> +
>   struct libinput_device_config {
>   	struct libinput_device_config_tap *tap;
>   	struct libinput_device_config_calibration *calibration;
> @@ -206,6 +217,7 @@ struct libinput_device_config {
>   	struct libinput_device_config_scroll_method *scroll_method;
>   	struct libinput_device_config_click_method *click_method;
>   	struct libinput_device_config_middle_emulation *middle_emulation;
> +	struct libinput_device_config_dwt *dwt;
>   };
>
>   struct libinput_device_group {
> diff --git a/src/libinput.c b/src/libinput.c
> index 563ad0d..cab6224 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -2401,3 +2401,45 @@ libinput_device_config_scroll_get_default_button(struct libinput_device *device)
>
>   	return device->config.scroll_method->get_default_button(device);
>   }
> +
> +LIBINPUT_EXPORT int
> +libinput_device_config_dwt_is_available(struct libinput_device *device)
> +{
> +	if (!device->config.dwt)
> +		return 0;
> +
> +	return device->config.dwt->is_available(device);
> +}
> +
> +LIBINPUT_EXPORT enum libinput_config_status
> +libinput_device_config_dwt_set_enabled(struct libinput_device *device,
> +				       enum libinput_config_dwt_state enable)
> +{
> +	if (enable != LIBINPUT_CONFIG_DWT_ENABLED &&
> +	    enable != LIBINPUT_CONFIG_DWT_DISABLED)
> +		return LIBINPUT_CONFIG_STATUS_INVALID;
> +
> +	if (!libinput_device_config_dwt_is_available(device))
> +		return enable ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED :
> +				LIBINPUT_CONFIG_STATUS_SUCCESS;
> +
> +	return device->config.dwt->set_enabled(device, enable);
> +}
> +
> +LIBINPUT_EXPORT enum libinput_config_dwt_state
> +libinput_device_config_dwt_get_enabled(struct libinput_device *device)
> +{
> +	if (!libinput_device_config_dwt_is_available(device))
> +		return LIBINPUT_CONFIG_DWT_DISABLED;
> +
> +	return device->config.dwt->get_enabled(device);
> +}
> +
> +LIBINPUT_EXPORT enum libinput_config_dwt_state
> +libinput_device_config_dwt_get_default_enabled(struct libinput_device *device)
> +{
> +	if (!libinput_device_config_dwt_is_available(device))
> +		return LIBINPUT_CONFIG_DWT_DISABLED;
> +
> +	return device->config.dwt->get_default_enabled(device);
> +}
> diff --git a/src/libinput.h b/src/libinput.h
> index 3595fd1..f9a7d68 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -3078,6 +3078,96 @@ libinput_device_config_scroll_get_button(struct libinput_device *device);
>   uint32_t
>   libinput_device_config_scroll_get_default_button(struct libinput_device *device);
>
> +/**
> + * @ingroup config
> + *
> + * Possible states for the disable-while-typing feature. See @ref
> + * disable-while-typing for details.
> + */
> +enum libinput_config_dwt_state {
> +	LIBINPUT_CONFIG_DWT_DISABLED,
> +	LIBINPUT_CONFIG_DWT_ENABLED,
> +};
> +
> +/**
> + * @ingroup config
> + *
> + * Check if this device supports configurable disable-while-typing feature.
> + * This feature is usally available on built-in touchpads and disables the
> + * touchpad while typing. See @ref disable-while-typing for details.
> + *
> + * @param device The device to configure
> + * @return 0 if this device does not support disable-while-typing, or 1
> + * otherwise.
> + *
> + * @see libinput_device_config_dwt_set_enabled
> + * @see libinput_device_config_dwt_get_enabled
> + * @see libinput_device_config_dwt_get_default_enabled
> + */
> +int
> +libinput_device_config_dwt_is_available(struct libinput_device *device);
> +
> +/**
> + * @ingroup config
> + *
> + * Enable or disable the disable-while-typing feature. When enabled, the
> + * device will be disabled while typing and for a short period after. See
> + * @ref disable-while-typing for details.
> + *
> + * @note Enabling or disabling disable-while-typing may not take effect
> + * immediately.
> + *
> + * @param device The device to configure
> + * @param enable @ref LIBINPUT_CONFIG_DWT_DISABLED to disable
> + * disable-while-typing, @ref LIBINPUT_CONFIG_DWT_ENABLED to enable
> + *
> + * @return A config status code. Disabling disable-while-typing on a
> + * device that does not support the feature always succeeds.
> + *
> + * @see libinput_device_config_dwt_is_available
> + * @see libinput_device_config_dwt_get_enabled
> + * @see libinput_device_config_dwt_get_default_enabled
> + */
> +enum libinput_config_status
> +libinput_device_config_dwt_set_enabled(struct libinput_device *device,
> +				       enum libinput_config_dwt_state enable);
> +
> +/**
> + * @ingroup config
> + *
> + * Check if the disable-while typing feature is currently enabled on this
> + * device. If the device does not support disable-while-typing, this
> + * function returns @ref LIBINPUT_CONFIG_DWT_DISABLED.
> + *
> + * @param device The device to configure
> + * @return @ref LIBINPUT_CONFIG_DWT_DISABLED if disabled, @ref
> + * LIBINPUT_CONFIG_DWT_ENABLED if enabled.
> + *
> + * @see libinput_device_config_dwt_is_available
> + * @see libinput_device_config_dwt_set_enabled
> + * @see libinput_device_config_dwt_get_default_enabled
> + */
> +enum libinput_config_dwt_state
> +libinput_device_config_dwt_get_enabled(struct libinput_device *device);
> +
> +/**
> + * @ingroup config
> + *
> + * Check if the disable-while typing feature is enabled on this device by
> + * default. If the device does not support disable-while-typing, this
> + * function returns @ref LIBINPUT_CONFIG_DWT_DISABLED.
> + *
> + * @param device The device to configure
> + * @return @ref LIBINPUT_CONFIG_DWT_DISABLED if disabled, @ref
> + * LIBINPUT_CONFIG_DWT_ENABLED if enabled.
> + *
> + * @see libinput_device_config_dwt_is_available
> + * @see libinput_device_config_dwt_set_enabled
> + * @see libinput_device_config_dwt_get_enabled
> + */
> +enum libinput_config_dwt_state
> +libinput_device_config_dwt_get_default_enabled(struct libinput_device *device);
> +
>   #ifdef __cplusplus
>   }
>   #endif
> diff --git a/src/libinput.sym b/src/libinput.sym
> index 6bdd3ba..fe29d84 100644
> --- a/src/libinput.sym
> +++ b/src/libinput.sym
> @@ -149,6 +149,10 @@ global:
>   } LIBINPUT_0.15.0;
>
>   LIBINPUT_0.20.0 {
> +	libinput_device_config_dwt_is_available;
> +	libinput_device_config_dwt_set_enabled;
> +	libinput_device_config_dwt_get_enabled;
> +	libinput_device_config_dwt_get_default_enabled;
>   	libinput_event_gesture_get_angle_delta;
>   	libinput_event_gesture_get_base_event;
>   	libinput_event_gesture_get_cancelled;
> diff --git a/tools/event-debug.c b/tools/event-debug.c
> index 710a425..7ead6bf 100644
> --- a/tools/event-debug.c
> +++ b/tools/event-debug.c
> @@ -194,6 +194,14 @@ print_device_notify(struct libinput_event *ev)
>   			printf("-clickfinger");
>   	}
>
> +	if (libinput_device_config_dwt_is_available(dev)) {
> +		if (libinput_device_config_dwt_get_enabled(dev) ==
> +		    LIBINPUT_CONFIG_DWT_ENABLED)
> +			printf(" dwt-on");
> +		else
> +			printf(" dwt-off)");
> +	}
> +
>   	printf("\n");
>
>   }
> diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c
> index 6d162e2..53eabc3 100644
> --- a/tools/libinput-list-devices.c
> +++ b/tools/libinput-list-devices.c
> @@ -181,6 +181,18 @@ click_defaults(struct libinput_device *device)
>   	return str;
>   }
>
> +static const char *
> +dwt_default(struct libinput_device *device)
> +{
> +	if (!libinput_device_config_dwt_is_available(device))
> +		return "n/a";
> +
> +	if (libinput_device_config_dwt_get_default_enabled(device))
> +		return "enabled";
> +	else
> +		return "disabled";
> +}
> +
>   static void
>   print_device_notify(struct libinput_event *ev)
>   {
> @@ -244,6 +256,8 @@ print_device_notify(struct libinput_event *ev)
>   	printf("Click methods:    %s\n", str);
>   	free(str);
>
> +	printf("Disable-w-typing: %s\n", dwt_default(dev));
> +
>   	printf("\n");
>   }
>
> diff --git a/tools/shared.c b/tools/shared.c
> index 64544c5..cea4c50 100644
> --- a/tools/shared.c
> +++ b/tools/shared.c
> @@ -53,6 +53,8 @@ enum options {
>   	OPT_LEFT_HANDED_DISABLE,
>   	OPT_MIDDLEBUTTON_ENABLE,
>   	OPT_MIDDLEBUTTON_DISABLE,
> +	OPT_DWT_ENABLE,
> +	OPT_DWT_DISABLE,
>   	OPT_CLICK_METHOD,
>   	OPT_SCROLL_METHOD,
>   	OPT_SCROLL_BUTTON,
> @@ -87,6 +89,8 @@ tools_usage()
>   	       "--disable-left-handed.... enable/disable left-handed button configuration\n"
>   	       "--enable-middlebutton\n"
>   	       "--disable-middlebutton.... enable/disable middle button emulation\n"
> +	       "--enable-dwt\n"
> +	       "--disable-dwt..... enable/disable disable-while-typing\n"
>   	       "--set-click-method=[none|clickfinger|buttonareas] .... set the desired click method\n"
>   	       "--set-scroll-method=[none|twofinger|edge|button] ... set the desired scroll method\n"
>   	       "--set-scroll-button=BTN_MIDDLE ... set the button to the given button code\n"
> @@ -115,6 +119,7 @@ tools_init_context(struct tools_context *context)
>   	options->natural_scroll = -1;
>   	options->left_handed = -1;
>   	options->middlebutton = -1;
> +	options->dwt = -1;
>   	options->click_method = -1;
>   	options->scroll_method = -1;
>   	options->scroll_button = -1;
> @@ -147,6 +152,8 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
>   			{ "disable-left-handed", 0, 0, OPT_LEFT_HANDED_DISABLE },
>   			{ "enable-middlebutton", 0, 0, OPT_MIDDLEBUTTON_ENABLE },
>   			{ "disable-middlebutton", 0, 0, OPT_MIDDLEBUTTON_DISABLE },
> +			{ "enable-dwt", 0, 0, OPT_DWT_ENABLE },
> +			{ "disable-dwt", 0, 0, OPT_DWT_DISABLE },
>   			{ "set-click-method", 1, 0, OPT_CLICK_METHOD },
>   			{ "set-scroll-method", 1, 0, OPT_SCROLL_METHOD },
>   			{ "set-scroll-button", 1, 0, OPT_SCROLL_BUTTON },
> @@ -212,6 +219,12 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
>   			case OPT_MIDDLEBUTTON_DISABLE:
>   				options->middlebutton = 0;
>   				break;
> +			case OPT_DWT_ENABLE:
> +				options->dwt = LIBINPUT_CONFIG_DWT_ENABLED;
> +				break;
> +			case OPT_DWT_DISABLE:
> +				options->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
> +				break;
>   			case OPT_CLICK_METHOD:
>   				if (!optarg) {
>   					tools_usage();
> @@ -419,6 +432,9 @@ tools_device_apply_config(struct libinput_device *device,
>   		libinput_device_config_middle_emulation_set_enabled(device,
>   								    options->middlebutton);
>
> +	if (options->dwt != -1)
> +		libinput_device_config_dwt_set_enabled(device, options->dwt);
> +
>   	if (options->click_method != -1)
>   		libinput_device_config_click_set_method(device, options->click_method);
>
> diff --git a/tools/shared.h b/tools/shared.h
> index a848e2d..a9cf6d9 100644
> --- a/tools/shared.h
> +++ b/tools/shared.h
> @@ -47,6 +47,7 @@ struct tools_options {
>   	enum libinput_config_scroll_method scroll_method;
>   	int scroll_button;
>   	double speed;
> +	int dwt;
>   };
>
>   struct tools_context {
>


More information about the wayland-devel mailing list