[PATCH] Add configuration option for no input device.

Daniel Diaz daniel.diaz at linaro.org
Mon Oct 17 21:37:37 UTC 2016


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

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;
+ }
  }

  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


More information about the wayland-devel mailing list