Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2013 Intel Corporation |
| 3 | * Copyright © 2013 Jonas Ådahl |
| 4 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 5 | * Permission is hereby granted, free of charge, to any person obtaining |
| 6 | * a copy of this software and associated documentation files (the |
| 7 | * "Software"), to deal in the Software without restriction, including |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, |
| 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 10 | * permit persons to whom the Software is furnished to do so, subject to |
| 11 | * the following conditions: |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 12 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 13 | * The above copyright notice and this permission notice (including the |
| 14 | * next paragraph) shall be included in all copies or substantial |
| 15 | * portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 | * SOFTWARE. |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 25 | */ |
| 26 | |
| 27 | #include "config.h" |
| 28 | |
Jussi Kukkonen | 649bbce | 2016-07-19 14:16:27 +0300 | [diff] [blame] | 29 | #include <stdint.h> |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 30 | #include <stdlib.h> |
| 31 | #include <string.h> |
| 32 | #include <unistd.h> |
| 33 | #include <fcntl.h> |
| 34 | #include <libinput.h> |
| 35 | #include <libudev.h> |
| 36 | |
| 37 | #include "compositor.h" |
| 38 | #include "launcher-util.h" |
| 39 | #include "libinput-seat.h" |
| 40 | #include "libinput-device.h" |
Jon Cruz | 867d50e | 2015-06-15 15:37:10 -0700 | [diff] [blame] | 41 | #include "shared/helpers.h" |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 42 | |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 43 | static void |
| 44 | process_events(struct udev_input *input); |
| 45 | static struct udev_seat * |
| 46 | udev_seat_create(struct udev_input *input, const char *seat_name); |
| 47 | static void |
| 48 | udev_seat_destroy(struct udev_seat *seat); |
| 49 | |
Derek Foreman | a6714fa | 2015-05-05 15:01:51 -0500 | [diff] [blame] | 50 | static struct udev_seat * |
| 51 | get_udev_seat(struct udev_input *input, struct libinput_device *device) |
| 52 | { |
| 53 | struct libinput_seat *libinput_seat; |
| 54 | const char *seat_name; |
| 55 | |
| 56 | libinput_seat = libinput_device_get_seat(device); |
| 57 | seat_name = libinput_seat_get_logical_name(libinput_seat); |
| 58 | return udev_seat_get_named(input, seat_name); |
| 59 | } |
| 60 | |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 61 | static void |
| 62 | device_added(struct udev_input *input, struct libinput_device *libinput_device) |
| 63 | { |
| 64 | struct weston_compositor *c; |
| 65 | struct evdev_device *device; |
| 66 | struct weston_output *output; |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 67 | const char *output_name; |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 68 | struct weston_seat *seat; |
| 69 | struct udev_seat *udev_seat; |
Derek Foreman | 1281a36 | 2015-07-31 16:55:32 -0500 | [diff] [blame] | 70 | struct weston_pointer *pointer; |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 71 | |
| 72 | c = input->compositor; |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 73 | |
Derek Foreman | a6714fa | 2015-05-05 15:01:51 -0500 | [diff] [blame] | 74 | udev_seat = get_udev_seat(input, libinput_device); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 75 | if (!udev_seat) |
| 76 | return; |
| 77 | |
| 78 | seat = &udev_seat->base; |
| 79 | device = evdev_device_create(libinput_device, seat); |
| 80 | if (device == NULL) |
| 81 | return; |
| 82 | |
Giulio Camuffo | 8aedf7b | 2016-06-02 21:48:12 +0300 | [diff] [blame] | 83 | if (input->configure_device != NULL) |
| 84 | input->configure_device(c, device->device); |
| 85 | evdev_device_set_calibration(device); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 86 | udev_seat = (struct udev_seat *) seat; |
| 87 | wl_list_insert(udev_seat->devices_list.prev, &device->link); |
| 88 | |
Derek Foreman | 1281a36 | 2015-07-31 16:55:32 -0500 | [diff] [blame] | 89 | pointer = weston_seat_get_pointer(seat); |
| 90 | if (seat->output && pointer) |
| 91 | weston_pointer_clamp(pointer, |
| 92 | &pointer->x, |
| 93 | &pointer->y); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 94 | |
| 95 | output_name = libinput_device_get_output_name(libinput_device); |
| 96 | if (output_name) { |
| 97 | device->output_name = strdup(output_name); |
| 98 | wl_list_for_each(output, &c->output_list, link) |
Derek Foreman | f3723d9 | 2015-03-17 13:22:35 -0500 | [diff] [blame] | 99 | if (output->name && |
| 100 | strcmp(output->name, device->output_name) == 0) |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 101 | evdev_device_set_output(device, output); |
Ander Conselvan de Oliveira | a7caef9 | 2014-04-24 15:11:17 +0300 | [diff] [blame] | 102 | } else if (device->output == NULL && !wl_list_empty(&c->output_list)) { |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 103 | output = container_of(c->output_list.next, |
| 104 | struct weston_output, link); |
| 105 | evdev_device_set_output(device, output); |
| 106 | } |
| 107 | |
| 108 | if (!input->suspended) |
| 109 | weston_seat_repick(seat); |
| 110 | } |
| 111 | |
| 112 | static void |
Derek Foreman | 6b557a7 | 2015-05-05 15:01:52 -0500 | [diff] [blame] | 113 | device_removed(struct udev_input *input, struct libinput_device *libinput_device) |
| 114 | { |
| 115 | struct evdev_device *device; |
Derek Foreman | 0b7da01 | 2015-09-30 13:34:57 -0500 | [diff] [blame] | 116 | |
Derek Foreman | 6b557a7 | 2015-05-05 15:01:52 -0500 | [diff] [blame] | 117 | device = libinput_device_get_user_data(libinput_device); |
| 118 | evdev_device_destroy(device); |
| 119 | } |
| 120 | |
| 121 | static void |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 122 | udev_seat_remove_devices(struct udev_seat *seat) |
| 123 | { |
| 124 | struct evdev_device *device, *next; |
| 125 | |
| 126 | wl_list_for_each_safe(device, next, &seat->devices_list, link) { |
| 127 | evdev_device_destroy(device); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | void |
| 132 | udev_input_disable(struct udev_input *input) |
| 133 | { |
| 134 | if (input->suspended) |
| 135 | return; |
| 136 | |
| 137 | libinput_suspend(input->libinput); |
| 138 | process_events(input); |
| 139 | input->suspended = 1; |
| 140 | } |
| 141 | |
| 142 | static int |
| 143 | udev_input_process_event(struct libinput_event *event) |
| 144 | { |
| 145 | struct libinput *libinput = libinput_event_get_context(event); |
| 146 | struct libinput_device *libinput_device = |
| 147 | libinput_event_get_device(event); |
| 148 | struct udev_input *input = libinput_get_user_data(libinput); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 149 | int handled = 1; |
| 150 | |
| 151 | switch (libinput_event_get_type(event)) { |
| 152 | case LIBINPUT_EVENT_DEVICE_ADDED: |
| 153 | device_added(input, libinput_device); |
| 154 | break; |
| 155 | case LIBINPUT_EVENT_DEVICE_REMOVED: |
Derek Foreman | 6b557a7 | 2015-05-05 15:01:52 -0500 | [diff] [blame] | 156 | device_removed(input, libinput_device); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 157 | break; |
| 158 | default: |
| 159 | handled = 0; |
| 160 | } |
| 161 | |
| 162 | return handled; |
| 163 | } |
| 164 | |
| 165 | static void |
| 166 | process_event(struct libinput_event *event) |
| 167 | { |
| 168 | if (udev_input_process_event(event)) |
| 169 | return; |
| 170 | if (evdev_device_process_event(event)) |
| 171 | return; |
| 172 | } |
| 173 | |
| 174 | static void |
| 175 | process_events(struct udev_input *input) |
| 176 | { |
| 177 | struct libinput_event *event; |
| 178 | |
| 179 | while ((event = libinput_get_event(input->libinput))) { |
| 180 | process_event(event); |
| 181 | libinput_event_destroy(event); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | static int |
| 186 | udev_input_dispatch(struct udev_input *input) |
| 187 | { |
| 188 | if (libinput_dispatch(input->libinput) != 0) |
| 189 | weston_log("libinput: Failed to dispatch libinput\n"); |
| 190 | |
| 191 | process_events(input); |
| 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | static int |
| 197 | libinput_source_dispatch(int fd, uint32_t mask, void *data) |
| 198 | { |
| 199 | struct udev_input *input = data; |
| 200 | |
| 201 | return udev_input_dispatch(input) != 0; |
| 202 | } |
| 203 | |
| 204 | static int |
| 205 | open_restricted(const char *path, int flags, void *user_data) |
| 206 | { |
| 207 | struct udev_input *input = user_data; |
| 208 | struct weston_launcher *launcher = input->compositor->launcher; |
| 209 | |
| 210 | return weston_launcher_open(launcher, path, flags); |
| 211 | } |
| 212 | |
| 213 | static void |
| 214 | close_restricted(int fd, void *user_data) |
| 215 | { |
| 216 | struct udev_input *input = user_data; |
| 217 | struct weston_launcher *launcher = input->compositor->launcher; |
| 218 | |
| 219 | weston_launcher_close(launcher, fd); |
| 220 | } |
| 221 | |
| 222 | const struct libinput_interface libinput_interface = { |
| 223 | open_restricted, |
| 224 | close_restricted, |
| 225 | }; |
| 226 | |
| 227 | int |
| 228 | udev_input_enable(struct udev_input *input) |
| 229 | { |
| 230 | struct wl_event_loop *loop; |
| 231 | struct weston_compositor *c = input->compositor; |
| 232 | int fd; |
| 233 | struct udev_seat *seat; |
| 234 | int devices_found = 0; |
| 235 | |
| 236 | loop = wl_display_get_event_loop(c->wl_display); |
| 237 | fd = libinput_get_fd(input->libinput); |
| 238 | input->libinput_source = |
| 239 | wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE, |
| 240 | libinput_source_dispatch, input); |
| 241 | if (!input->libinput_source) { |
| 242 | return -1; |
| 243 | } |
| 244 | |
| 245 | if (input->suspended) { |
| 246 | if (libinput_resume(input->libinput) != 0) { |
| 247 | wl_event_source_remove(input->libinput_source); |
| 248 | input->libinput_source = NULL; |
| 249 | return -1; |
| 250 | } |
| 251 | input->suspended = 0; |
| 252 | process_events(input); |
| 253 | } |
| 254 | |
| 255 | wl_list_for_each(seat, &input->compositor->seat_list, base.link) { |
| 256 | evdev_notify_keyboard_focus(&seat->base, &seat->devices_list); |
| 257 | |
| 258 | if (!wl_list_empty(&seat->devices_list)) |
| 259 | devices_found = 1; |
| 260 | } |
| 261 | |
Daniel Díaz | 75b7197 | 2016-10-21 14:03:13 -0500 | [diff] [blame^] | 262 | if (devices_found == 0 && !c->require_input) { |
| 263 | weston_log("warning: no input devices found, but none required " |
| 264 | "as per configuration.\n"); |
| 265 | return 0; |
| 266 | } |
| 267 | |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 268 | if (devices_found == 0) { |
| 269 | weston_log( |
| 270 | "warning: no input devices on entering Weston. " |
| 271 | "Possible causes:\n" |
| 272 | "\t- no permissions to read /dev/input/event*\n" |
| 273 | "\t- seats misconfigured " |
| 274 | "(Weston backend option 'seat', " |
| 275 | "udev device property ID_SEAT)\n"); |
| 276 | return -1; |
| 277 | } |
| 278 | |
| 279 | return 0; |
| 280 | } |
| 281 | |
U. Artie Eoff | 71db0fd | 2014-04-17 07:53:22 -0700 | [diff] [blame] | 282 | static void |
Peter Hutterer | 3b843d3 | 2014-06-25 14:07:36 +1000 | [diff] [blame] | 283 | libinput_log_func(struct libinput *libinput, |
| 284 | enum libinput_log_priority priority, |
| 285 | const char *format, va_list args) |
U. Artie Eoff | 71db0fd | 2014-04-17 07:53:22 -0700 | [diff] [blame] | 286 | { |
| 287 | weston_vlog(format, args); |
| 288 | } |
| 289 | |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 290 | int |
Pekka Paalanen | eb4fd35 | 2014-09-12 12:07:43 +0300 | [diff] [blame] | 291 | udev_input_init(struct udev_input *input, struct weston_compositor *c, |
Giulio Camuffo | 8aedf7b | 2016-06-02 21:48:12 +0300 | [diff] [blame] | 292 | struct udev *udev, const char *seat_id, |
| 293 | udev_configure_device_t configure_device) |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 294 | { |
Pekka Paalanen | eb4fd35 | 2014-09-12 12:07:43 +0300 | [diff] [blame] | 295 | enum libinput_log_priority priority = LIBINPUT_LOG_PRIORITY_INFO; |
U. Artie Eoff | c81c424 | 2014-04-17 07:53:23 -0700 | [diff] [blame] | 296 | const char *log_priority = NULL; |
| 297 | |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 298 | memset(input, 0, sizeof *input); |
| 299 | |
| 300 | input->compositor = c; |
Giulio Camuffo | 8aedf7b | 2016-06-02 21:48:12 +0300 | [diff] [blame] | 301 | input->configure_device = configure_device; |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 302 | |
U. Artie Eoff | c81c424 | 2014-04-17 07:53:23 -0700 | [diff] [blame] | 303 | log_priority = getenv("WESTON_LIBINPUT_LOG_PRIORITY"); |
U. Artie Eoff | 24713f6 | 2014-05-09 11:24:40 -0700 | [diff] [blame] | 304 | |
Peter Hutterer | 3b843d3 | 2014-06-25 14:07:36 +1000 | [diff] [blame] | 305 | input->libinput = libinput_udev_create_context(&libinput_interface, |
| 306 | input, udev); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 307 | if (!input->libinput) { |
| 308 | return -1; |
| 309 | } |
Peter Hutterer | 3b843d3 | 2014-06-25 14:07:36 +1000 | [diff] [blame] | 310 | |
| 311 | libinput_log_set_handler(input->libinput, &libinput_log_func); |
| 312 | |
| 313 | if (log_priority) { |
| 314 | if (strcmp(log_priority, "debug") == 0) { |
Pekka Paalanen | eb4fd35 | 2014-09-12 12:07:43 +0300 | [diff] [blame] | 315 | priority = LIBINPUT_LOG_PRIORITY_DEBUG; |
Peter Hutterer | 3b843d3 | 2014-06-25 14:07:36 +1000 | [diff] [blame] | 316 | } else if (strcmp(log_priority, "info") == 0) { |
Pekka Paalanen | eb4fd35 | 2014-09-12 12:07:43 +0300 | [diff] [blame] | 317 | priority = LIBINPUT_LOG_PRIORITY_INFO; |
Peter Hutterer | 3b843d3 | 2014-06-25 14:07:36 +1000 | [diff] [blame] | 318 | } else if (strcmp(log_priority, "error") == 0) { |
Pekka Paalanen | eb4fd35 | 2014-09-12 12:07:43 +0300 | [diff] [blame] | 319 | priority = LIBINPUT_LOG_PRIORITY_ERROR; |
Peter Hutterer | 3b843d3 | 2014-06-25 14:07:36 +1000 | [diff] [blame] | 320 | } |
| 321 | } |
| 322 | |
Pekka Paalanen | eb4fd35 | 2014-09-12 12:07:43 +0300 | [diff] [blame] | 323 | libinput_log_set_priority(input->libinput, priority); |
| 324 | |
Peter Hutterer | 3b843d3 | 2014-06-25 14:07:36 +1000 | [diff] [blame] | 325 | if (libinput_udev_assign_seat(input->libinput, seat_id) != 0) { |
| 326 | libinput_unref(input->libinput); |
| 327 | return -1; |
| 328 | } |
| 329 | |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 330 | process_events(input); |
| 331 | |
| 332 | return udev_input_enable(input); |
| 333 | } |
| 334 | |
| 335 | void |
| 336 | udev_input_destroy(struct udev_input *input) |
| 337 | { |
| 338 | struct udev_seat *seat, *next; |
| 339 | |
| 340 | wl_event_source_remove(input->libinput_source); |
| 341 | wl_list_for_each_safe(seat, next, &input->compositor->seat_list, base.link) |
| 342 | udev_seat_destroy(seat); |
Peter Hutterer | 3b843d3 | 2014-06-25 14:07:36 +1000 | [diff] [blame] | 343 | libinput_unref(input->libinput); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | static void |
| 347 | udev_seat_led_update(struct weston_seat *seat_base, enum weston_led leds) |
| 348 | { |
| 349 | struct udev_seat *seat = (struct udev_seat *) seat_base; |
| 350 | struct evdev_device *device; |
| 351 | |
| 352 | wl_list_for_each(device, &seat->devices_list, link) |
| 353 | evdev_led_update(device, leds); |
| 354 | } |
| 355 | |
| 356 | static void |
| 357 | notify_output_create(struct wl_listener *listener, void *data) |
| 358 | { |
| 359 | struct udev_seat *seat = container_of(listener, struct udev_seat, |
| 360 | output_create_listener); |
| 361 | struct evdev_device *device; |
| 362 | struct weston_output *output = data; |
| 363 | |
Ander Conselvan de Oliveira | a7caef9 | 2014-04-24 15:11:17 +0300 | [diff] [blame] | 364 | wl_list_for_each(device, &seat->devices_list, link) { |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 365 | if (device->output_name && |
| 366 | strcmp(output->name, device->output_name) == 0) { |
| 367 | evdev_device_set_output(device, output); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 368 | } |
Ander Conselvan de Oliveira | a7caef9 | 2014-04-24 15:11:17 +0300 | [diff] [blame] | 369 | |
| 370 | if (device->output_name == NULL && device->output == NULL) |
| 371 | evdev_device_set_output(device, output); |
| 372 | } |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | static struct udev_seat * |
| 376 | udev_seat_create(struct udev_input *input, const char *seat_name) |
| 377 | { |
| 378 | struct weston_compositor *c = input->compositor; |
| 379 | struct udev_seat *seat; |
| 380 | |
| 381 | seat = zalloc(sizeof *seat); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 382 | if (!seat) |
| 383 | return NULL; |
Bryce W. Harrington | bfd74f4 | 2014-04-21 23:51:02 +0000 | [diff] [blame] | 384 | |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 385 | weston_seat_init(&seat->base, c, seat_name); |
| 386 | seat->base.led_update = udev_seat_led_update; |
| 387 | |
| 388 | seat->output_create_listener.notify = notify_output_create; |
| 389 | wl_signal_add(&c->output_created_signal, |
| 390 | &seat->output_create_listener); |
| 391 | |
| 392 | wl_list_init(&seat->devices_list); |
| 393 | |
| 394 | return seat; |
| 395 | } |
| 396 | |
| 397 | static void |
| 398 | udev_seat_destroy(struct udev_seat *seat) |
| 399 | { |
Derek Foreman | 1281a36 | 2015-07-31 16:55:32 -0500 | [diff] [blame] | 400 | struct weston_keyboard *keyboard = |
| 401 | weston_seat_get_keyboard(&seat->base); |
| 402 | |
Derek Foreman | 1281a36 | 2015-07-31 16:55:32 -0500 | [diff] [blame] | 403 | if (keyboard) |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 404 | notify_keyboard_focus_out(&seat->base); |
Derek Foreman | 87c862a | 2015-08-06 12:19:51 -0500 | [diff] [blame] | 405 | |
| 406 | udev_seat_remove_devices(seat); |
Jonas Ådahl | e0de3c2 | 2014-03-12 22:08:42 +0100 | [diff] [blame] | 407 | weston_seat_release(&seat->base); |
| 408 | wl_list_remove(&seat->output_create_listener.link); |
| 409 | free(seat); |
| 410 | } |
| 411 | |
| 412 | struct udev_seat * |
| 413 | udev_seat_get_named(struct udev_input *input, const char *seat_name) |
| 414 | { |
| 415 | struct udev_seat *seat; |
| 416 | |
| 417 | wl_list_for_each(seat, &input->compositor->seat_list, base.link) { |
| 418 | if (strcmp(seat->base.seat_name, seat_name) == 0) |
| 419 | return seat; |
| 420 | } |
| 421 | |
| 422 | return udev_seat_create(input, seat_name); |
| 423 | } |