[PATCH libinput 08/10] Add a config API for disable-while-typing

Hans de Goede hdegoede at redhat.com
Wed Jun 4 02:44:09 PDT 2014


Hi,

On 06/03/2014 07:35 AM, Peter Hutterer wrote:
> ---
>  src/libinput-private.h |  9 ++++++++
>  src/libinput.c         | 33 +++++++++++++++++++++++++++++
>  src/libinput.h         | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 98 insertions(+)
> 
> diff --git a/src/libinput-private.h b/src/libinput-private.h
> index 85113bd..9a3e629 100644
> --- a/src/libinput-private.h
> +++ b/src/libinput-private.h
> @@ -104,11 +104,20 @@ struct libinput_device_config_accel {
>  	void (*reset)(struct libinput_device *device);
>  };
>  
> +struct libinput_device_config_disable_while_typing {
> +	int (*available)(struct libinput_device *device);
> +	enum libinput_config_status (*enable)(struct libinput_device *device,
> +					      int enable);
> +	int (*is_enabled)(struct libinput_device *device);
> +	void (*reset)(struct libinput_device *device);
> +};
> +

set / get / get_default  ?

Regards,

Hans


>  struct libinput_device_config {
>  	struct libinput_device_config_tap *tap;
>  	struct libinput_device_config_scroll *scroll;
>  	struct libinput_device_config_rotation *rotation;
>  	struct libinput_device_config_accel *accel;
> +	struct libinput_device_config_disable_while_typing *dwt;
>  };
>  
>  struct libinput_device {
> diff --git a/src/libinput.c b/src/libinput.c
> index 5a068f1..33a8e90 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -1336,3 +1336,36 @@ libinput_device_config_accel_reset(struct libinput_device *device)
>  	if (device->config.accel)
>  		device->config.accel->reset(device);
>  }
> +
> +LIBINPUT_EXPORT int
> +libinput_device_config_disable_while_typing_is_available(struct libinput_device *device)
> +{
> +	return device->config.dwt ?
> +		device->config.dwt->available(device) : 0;
> +}
> +
> +LIBINPUT_EXPORT enum libinput_config_status
> +libinput_device_config_disable_while_typing_enable(struct libinput_device *device,
> +						   int enable)
> +{
> +	if (!libinput_device_config_disable_while_typing_is_available(device))
> +		return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
> +
> +	return device->config.dwt->enable(device, enable);
> +}
> +
> +LIBINPUT_EXPORT int
> +libinput_device_config_disable_while_typing_is_enabled(struct libinput_device *device)
> +{
> +	if (!libinput_device_config_disable_while_typing_is_available(device))
> +		return 0;
> +
> +	return device->config.dwt->is_enabled(device);
> +}
> +
> +LIBINPUT_EXPORT void
> +libinput_device_config_disable_while_typing_reset(struct libinput_device *device)
> +{
> +	if (device->config.dwt)
> +		device->config.dwt->reset(device);
> +}
> diff --git a/src/libinput.h b/src/libinput.h
> index 1b6207c..62d0c0f 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -1657,6 +1657,62 @@ libinput_device_config_accel_get_precision(struct libinput_device *device);
>  void
>  libinput_device_config_accel_reset(struct libinput_device *device);
>  
> +/**
> + * @ingroup config
> + *
> + * Check if this device supports a disable-while-typing feature. This
> + * feature is usually available on built-in touchpads where hand placement
> + * may cause erroneous events on the touchpad while typing.
> + *
> + * This feature is available on the device that is being disabled (i.e. the
> + * touchpad), not on the device causing the device to be disabled. Which
> + * devices trigger this feature is implementation-dependent.
> + *
> + * @param device The device to configure
> + * @return non-zero if disable while typing is available for this device
> + */
> +int
> +libinput_device_config_disable_while_typing_is_available(struct libinput_device *device);
> +
> +/**
> + * @ingroup config
> + *
> + * Enable or disable the disable-while-typing feature. When enabled, the
> + * device will not send events while and shortly after another device
> + * generates events.
> + *
> + * @param device The device to configure
> + * @param enable 0 to disable, 1 to enable
> + *
> + * @return 0 on success or a negative errno on failure
> + * @retval A config status code
> + */
> +enum libinput_config_status
> +libinput_device_config_disable_while_typing_enable(struct libinput_device *device,
> +						   int enable);
> +
> +/**
> + * @ingroup config
> + *
> + * Check if the feature is currently enabled.
> + *
> + * @param device The device to configure
> + *
> + * @return 0 if the feature is disabled, non-zero if the feature is enabled
> + */
> +int
> +libinput_device_config_disable_while_typing_is_enabled(struct libinput_device *device);
> +
> +/**
> + * @ingroup config
> + *
> + * Reset to the default settings.
> + *
> + * @param device The device to configure
> + */
> +void
> +libinput_device_config_disable_while_typing_reset(struct libinput_device *device);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> 


More information about the wayland-devel mailing list