[PATCH] Add configuration option for no input device.

Peter Hutterer peter.hutterer at who-t.net
Tue Oct 18 04:20:44 UTC 2016


On Mon, Oct 17, 2016 at 04:37:37PM -0500, Daniel Diaz wrote:
> As it has been discussed in the past [1], running Weston
> without any input device at launch might be beneficial for
> some use cases.
> 
> Certainly, it's best for the vast majority of users (and
> the project) to require an input device to be present, as
> to avoid frustration and hassle, but for those brave souls
> that so prefer, this patch lets them run without any input
> device at all.
> 
> This introduces a simple configuration in weston.ini:
>   [libinput]
>   require_input=true

I don't think you need a "libinput" section here, this isn't specific to
libinput and a compositor decision of whether to proceed or not.

> 
> True is the default, so no behavioral change is introduced.
> 
> [1] https://lists.freedesktop.org/archives/wayland-devel/2015-November/025193.html
> 
> Signed-off-by: Daniel Díaz <daniel.diaz at linaro.org>
> ---
>  libweston/compositor-drm.c | 11 ++++++++++-
>  libweston/libinput-seat.c  |  8 +++++++-
>  man/weston.ini.man         |  3 +++
>  3 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index f61e3d9..86cfa67 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -3156,6 +3156,8 @@ drm_backend_create(struct weston_compositor *compositor,
>   const char *path;
>   const char *seat_id = default_seat;
>   int ret;
> + struct weston_config_section *s;
> + int require_input;
> 
>   weston_log("initializing drm backend\n");
> 
> @@ -3236,11 +3238,18 @@ drm_backend_create(struct weston_compositor *compositor,
>   wl_list_init(&b->sprite_list);
>   create_sprites(b);
> 
> + s = weston_config_get_section(compositor->config,
> +      "libinput", NULL, NULL);
> + weston_config_section_get_bool(s, "require_input",
> +       &require_input, 1);
> +
>   if (udev_input_init(&b->input,
>      compositor, b->udev, seat_id,
>      config->configure_device) < 0) {
>   weston_log("failed to create input devices\n");
> - goto err_sprite;
> + if (require_input == 1) {
> + goto err_sprite;
> + }

indentation, but aside from that: you're not differing between an actual
error (input init failed, that's a problem) and the case where there are
no input devices. I understand why the latter may be interesting, I don't
think you should paper over the former.

Cheers,
   Peter

>   }
> 
>   if (create_outputs(b, config->connector, drm_device) < 0) {
> diff --git a/libweston/libinput-seat.c b/libweston/libinput-seat.c
> index 78a5fc4..db3ae82 100644
> --- a/libweston/libinput-seat.c
> +++ b/libweston/libinput-seat.c
> @@ -232,6 +232,8 @@ udev_input_enable(struct udev_input *input)
>   int fd;
>   struct udev_seat *seat;
>   int devices_found = 0;
> + struct weston_config_section *s;
> + int require_input;
> 
>   loop = wl_display_get_event_loop(c->wl_display);
>   fd = libinput_get_fd(input->libinput);
> @@ -259,7 +261,11 @@ udev_input_enable(struct udev_input *input)
>   devices_found = 1;
>   }
> 
> - if (devices_found == 0) {
> + s = weston_config_get_section(c->config, "libinput", NULL, NULL);
> + weston_config_section_get_bool(s, "require_input",
> +       &require_input, 1);
> +
> + if (devices_found == 0 && require_input == 1) {
>   weston_log(
>   "warning: no input devices on entering Weston. "
>   "Possible causes:\n"
> diff --git a/man/weston.ini.man b/man/weston.ini.man
> index 7aa7810..6e860d2 100644
> --- a/man/weston.ini.man
> +++ b/man/weston.ini.man
> @@ -179,6 +179,9 @@ Available configuration are:
>  .TP 7
>  .BI "enable_tap=" true
>  enables tap to click on touchpad devices
> +.TP 7
> +.BI "require_input=" true
> +require an input device for launch
>  .RS
>  .PP
> 
> -- 
> 1.9.1
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


More information about the wayland-devel mailing list