Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame^] | 1 | From bbf2e6ebbd9c051775f43e1e3c3a2f41322342e8 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?Daniel=20D=C3=ADaz?= <daniel.diaz@linaro.org> |
| 3 | Date: Fri, 21 Oct 2016 14:03:13 -0500 |
| 4 | Subject: [PATCH] Add configuration option for no input device. |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | [Backported from master, 75b7197.] |
| 10 | |
| 11 | As it has been discussed in the past [1], running Weston |
| 12 | without any input device at launch might be beneficial for |
| 13 | some use cases. |
| 14 | |
| 15 | Certainly, it's best for the vast majority of users (and |
| 16 | the project) to require an input device to be present, as |
| 17 | to avoid frustration and hassle, but for those brave souls |
| 18 | that so prefer, this patch lets them run without any input |
| 19 | device at all. |
| 20 | |
| 21 | This introduces a simple configuration in weston.ini: |
| 22 | [core] |
| 23 | require-input=true |
| 24 | |
| 25 | True is the default, so no behavioral change is introduced. |
| 26 | |
| 27 | [1] https://lists.freedesktop.org/archives/wayland-devel/2015-November/025193.html |
| 28 | |
| 29 | Signed-off-by: Daniel Díaz <daniel.diaz@linaro.org> |
| 30 | --- |
| 31 | man/weston.ini.man | 5 +++++ |
| 32 | src/compositor.h | 4 ++++ |
| 33 | src/libinput-seat.c | 6 ++++++ |
| 34 | src/main.c | 5 +++++ |
| 35 | weston.ini.in | 1 + |
| 36 | 5 files changed, 21 insertions(+) |
| 37 | |
| 38 | diff --git a/man/weston.ini.man b/man/weston.ini.man |
| 39 | index d7c4a6f..c7d0f01 100644 |
| 40 | --- a/man/weston.ini.man |
| 41 | +++ b/man/weston.ini.man |
| 42 | @@ -169,6 +169,11 @@ time, the one specified in the command-line will be used. On the other |
| 43 | hand, if none of these sets the value, default idle timeout will be |
| 44 | set to 300 seconds. |
| 45 | .RS |
| 46 | +.PP |
| 47 | +.RE |
| 48 | +.TP 7 |
| 49 | +.BI "require-input=" true |
| 50 | +require an input device for launch |
| 51 | |
| 52 | .SH "LIBINPUT SECTION" |
| 53 | The |
| 54 | diff --git a/src/compositor.h b/src/compositor.h |
| 55 | index 0bbf458..476b650 100644 |
| 56 | --- a/src/compositor.h |
| 57 | +++ b/src/compositor.h |
| 58 | @@ -803,6 +803,10 @@ struct weston_compositor { |
| 59 | |
| 60 | void *user_data; |
| 61 | void (*exit)(struct weston_compositor *c); |
| 62 | + |
| 63 | + /* Whether to let the compositor run without any input device. */ |
| 64 | + bool require_input; |
| 65 | + |
| 66 | }; |
| 67 | |
| 68 | struct weston_buffer { |
| 69 | diff --git a/src/libinput-seat.c b/src/libinput-seat.c |
| 70 | index 8ce0ee0..e1fdcf0 100644 |
| 71 | --- a/src/libinput-seat.c |
| 72 | +++ b/src/libinput-seat.c |
| 73 | @@ -255,6 +255,12 @@ udev_input_enable(struct udev_input *input) |
| 74 | devices_found = 1; |
| 75 | } |
| 76 | |
| 77 | + if (devices_found == 0 && !c->require_input) { |
| 78 | + weston_log("warning: no input devices found, but none required " |
| 79 | + "as per configuration.\n"); |
| 80 | + return 0; |
| 81 | + } |
| 82 | + |
| 83 | if (devices_found == 0) { |
| 84 | weston_log( |
| 85 | "warning: no input devices on entering Weston. " |
| 86 | diff --git a/src/main.c b/src/main.c |
| 87 | index 3279ac6..09905ea 100644 |
| 88 | --- a/src/main.c |
| 89 | +++ b/src/main.c |
| 90 | @@ -1298,6 +1298,7 @@ int main(int argc, char *argv[]) |
| 91 | struct wl_client *primary_client; |
| 92 | struct wl_listener primary_client_destroyed; |
| 93 | struct weston_seat *seat; |
| 94 | + int require_input; |
| 95 | |
| 96 | const struct weston_option core_options[] = { |
| 97 | { WESTON_OPTION_STRING, "backend", 'B', &backend }, |
| 98 | @@ -1373,6 +1374,10 @@ int main(int argc, char *argv[]) |
| 99 | if (weston_compositor_init_config(ec, config) < 0) |
| 100 | goto out; |
| 101 | |
| 102 | + weston_config_section_get_bool(section, "require-input", |
| 103 | + &require_input, true); |
| 104 | + ec->require_input = require_input; |
| 105 | + |
| 106 | if (load_backend(ec, backend, &argc, argv, config) < 0) { |
| 107 | weston_log("fatal: failed to create compositor backend\n"); |
| 108 | goto out; |
| 109 | diff --git a/weston.ini.in b/weston.ini.in |
| 110 | index 14a4c0c..d837fb5 100644 |
| 111 | --- a/weston.ini.in |
| 112 | +++ b/weston.ini.in |
| 113 | @@ -2,6 +2,7 @@ |
| 114 | #modules=xwayland.so,cms-colord.so |
| 115 | #shell=desktop-shell.so |
| 116 | #gbm-format=xrgb2101010 |
| 117 | +#require-input=true |
| 118 | |
| 119 | [shell] |
| 120 | background-image=/usr/share/backgrounds/gnome/Aqua.jpg |
| 121 | -- |
| 122 | 1.9.1 |
| 123 | |