2014-03-13 01:08:42 +04:00
|
|
|
/*
|
|
|
|
* Copyright © 2013 Intel Corporation
|
|
|
|
* Copyright © 2013 Jonas Ådahl
|
|
|
|
*
|
2015-06-12 01:35:43 +03:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
2014-03-13 01:08:42 +04:00
|
|
|
*
|
2015-06-12 01:35:43 +03:00
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2014-03-13 01:08:42 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2016-07-19 14:16:27 +03:00
|
|
|
#include <stdint.h>
|
2014-03-13 01:08:42 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <libinput.h>
|
|
|
|
#include <libudev.h>
|
|
|
|
|
2019-03-28 17:28:47 +03:00
|
|
|
#include <libweston/libweston.h>
|
2019-07-16 23:44:21 +03:00
|
|
|
#include "backend.h"
|
2019-07-10 17:32:42 +03:00
|
|
|
#include "libweston-internal.h"
|
2019-07-09 00:36:20 +03:00
|
|
|
#include "weston-log-internal.h"
|
2014-03-13 01:08:42 +04:00
|
|
|
#include "launcher-util.h"
|
|
|
|
#include "libinput-seat.h"
|
|
|
|
#include "libinput-device.h"
|
2015-06-16 01:37:10 +03:00
|
|
|
#include "shared/helpers.h"
|
2014-03-13 01:08:42 +04:00
|
|
|
|
|
|
|
static void
|
|
|
|
process_events(struct udev_input *input);
|
|
|
|
static struct udev_seat *
|
|
|
|
udev_seat_create(struct udev_input *input, const char *seat_name);
|
|
|
|
static void
|
|
|
|
udev_seat_destroy(struct udev_seat *seat);
|
|
|
|
|
2015-05-05 23:01:51 +03:00
|
|
|
static struct udev_seat *
|
|
|
|
get_udev_seat(struct udev_input *input, struct libinput_device *device)
|
|
|
|
{
|
|
|
|
struct libinput_seat *libinput_seat;
|
|
|
|
const char *seat_name;
|
|
|
|
|
|
|
|
libinput_seat = libinput_device_get_seat(device);
|
|
|
|
seat_name = libinput_seat_get_logical_name(libinput_seat);
|
|
|
|
return udev_seat_get_named(input, seat_name);
|
|
|
|
}
|
|
|
|
|
2018-03-19 15:55:41 +03:00
|
|
|
static struct weston_output *
|
|
|
|
output_find_by_head_name(struct weston_compositor *compositor,
|
|
|
|
const char *head_name)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
struct weston_head *head;
|
|
|
|
|
|
|
|
if (!head_name)
|
|
|
|
return NULL;
|
|
|
|
|
2018-03-20 14:29:40 +03:00
|
|
|
/* Only enabled outputs with connected heads.
|
|
|
|
* This means force-enabled outputs but with disconnected heads
|
|
|
|
* will be ignored; if the touchscreen doesn't have a video signal,
|
|
|
|
* touching it is meaningless.
|
|
|
|
*/
|
2018-03-19 15:55:41 +03:00
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
|
|
|
wl_list_for_each(head, &output->head_list, output_link) {
|
2018-03-20 14:29:40 +03:00
|
|
|
if (!weston_head_is_connected(head))
|
|
|
|
continue;
|
|
|
|
|
2018-03-19 15:55:41 +03:00
|
|
|
if (strcmp(head_name, head->name) == 0)
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-08-27 14:01:38 +03:00
|
|
|
static int
|
2014-03-13 01:08:42 +04:00
|
|
|
device_added(struct udev_input *input, struct libinput_device *libinput_device)
|
|
|
|
{
|
|
|
|
struct weston_compositor *c;
|
|
|
|
struct evdev_device *device;
|
|
|
|
struct weston_output *output;
|
|
|
|
const char *output_name;
|
|
|
|
struct weston_seat *seat;
|
|
|
|
struct udev_seat *udev_seat;
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_pointer *pointer;
|
2014-03-13 01:08:42 +04:00
|
|
|
|
|
|
|
c = input->compositor;
|
|
|
|
|
2015-05-05 23:01:51 +03:00
|
|
|
udev_seat = get_udev_seat(input, libinput_device);
|
2021-08-27 14:01:38 +03:00
|
|
|
if (!udev_seat) {
|
|
|
|
weston_log("Failed to get a seat\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2014-03-13 01:08:42 +04:00
|
|
|
|
|
|
|
seat = &udev_seat->base;
|
|
|
|
device = evdev_device_create(libinput_device, seat);
|
2021-08-27 14:01:38 +03:00
|
|
|
if (device == NULL) {
|
|
|
|
weston_log("Failed to create a device\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2014-03-13 01:08:42 +04:00
|
|
|
|
2016-06-02 21:48:12 +03:00
|
|
|
if (input->configure_device != NULL)
|
|
|
|
input->configure_device(c, device->device);
|
|
|
|
evdev_device_set_calibration(device);
|
2014-03-13 01:08:42 +04:00
|
|
|
udev_seat = (struct udev_seat *) seat;
|
|
|
|
wl_list_insert(udev_seat->devices_list.prev, &device->link);
|
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
pointer = weston_seat_get_pointer(seat);
|
|
|
|
if (seat->output && pointer)
|
|
|
|
weston_pointer_clamp(pointer,
|
|
|
|
&pointer->x,
|
|
|
|
&pointer->y);
|
2014-03-13 01:08:42 +04:00
|
|
|
|
|
|
|
output_name = libinput_device_get_output_name(libinput_device);
|
|
|
|
if (output_name) {
|
|
|
|
device->output_name = strdup(output_name);
|
2018-03-19 15:55:41 +03:00
|
|
|
output = output_find_by_head_name(c, output_name);
|
|
|
|
evdev_device_set_output(device, output);
|
|
|
|
} else if (!wl_list_empty(&c->output_list)) {
|
|
|
|
/* default assignment to an arbitrary output */
|
2014-03-13 01:08:42 +04:00
|
|
|
output = container_of(c->output_list.next,
|
|
|
|
struct weston_output, link);
|
|
|
|
evdev_device_set_output(device, output);
|
|
|
|
}
|
|
|
|
|
2018-10-29 18:42:48 +03:00
|
|
|
if (!input->suspended) {
|
2014-03-13 01:08:42 +04:00
|
|
|
weston_seat_repick(seat);
|
2018-10-29 18:42:48 +03:00
|
|
|
|
|
|
|
/* Sync device leds with the actual state */
|
|
|
|
if (seat->led_update && seat->keyboard_state)
|
|
|
|
seat->led_update(seat, seat->keyboard_state->xkb_state.leds);
|
|
|
|
}
|
2021-08-27 14:01:38 +03:00
|
|
|
|
|
|
|
return 0;
|
2014-03-13 01:08:42 +04:00
|
|
|
}
|
|
|
|
|
2021-08-27 14:01:38 +03:00
|
|
|
static int
|
2015-05-05 23:01:52 +03:00
|
|
|
device_removed(struct udev_input *input, struct libinput_device *libinput_device)
|
|
|
|
{
|
|
|
|
struct evdev_device *device;
|
2015-09-30 21:34:57 +03:00
|
|
|
|
2015-05-05 23:01:52 +03:00
|
|
|
device = libinput_device_get_user_data(libinput_device);
|
2021-08-27 14:01:38 +03:00
|
|
|
if (!device) {
|
|
|
|
weston_log("Failed to retrieve device\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2021-03-30 23:09:05 +03:00
|
|
|
|
2015-05-05 23:01:52 +03:00
|
|
|
evdev_device_destroy(device);
|
2021-08-27 14:01:38 +03:00
|
|
|
return 0;
|
2015-05-05 23:01:52 +03:00
|
|
|
}
|
|
|
|
|
2014-03-13 01:08:42 +04:00
|
|
|
static void
|
|
|
|
udev_seat_remove_devices(struct udev_seat *seat)
|
|
|
|
{
|
|
|
|
struct evdev_device *device, *next;
|
|
|
|
|
|
|
|
wl_list_for_each_safe(device, next, &seat->devices_list, link) {
|
|
|
|
evdev_device_destroy(device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
udev_input_disable(struct udev_input *input)
|
|
|
|
{
|
|
|
|
if (input->suspended)
|
|
|
|
return;
|
|
|
|
|
2017-07-26 00:39:20 +03:00
|
|
|
wl_event_source_remove(input->libinput_source);
|
|
|
|
input->libinput_source = NULL;
|
2014-03-13 01:08:42 +04:00
|
|
|
libinput_suspend(input->libinput);
|
|
|
|
process_events(input);
|
|
|
|
input->suspended = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
udev_input_process_event(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
struct libinput *libinput = libinput_event_get_context(event);
|
|
|
|
struct libinput_device *libinput_device =
|
|
|
|
libinput_event_get_device(event);
|
|
|
|
struct udev_input *input = libinput_get_user_data(libinput);
|
2021-08-27 14:01:38 +03:00
|
|
|
int ret = 0;
|
2014-03-13 01:08:42 +04:00
|
|
|
|
|
|
|
switch (libinput_event_get_type(event)) {
|
|
|
|
case LIBINPUT_EVENT_DEVICE_ADDED:
|
2021-08-27 14:01:38 +03:00
|
|
|
ret = device_added(input, libinput_device);
|
2014-03-13 01:08:42 +04:00
|
|
|
break;
|
|
|
|
case LIBINPUT_EVENT_DEVICE_REMOVED:
|
2021-08-27 14:01:38 +03:00
|
|
|
ret = device_removed(input, libinput_device);
|
2014-03-13 01:08:42 +04:00
|
|
|
break;
|
|
|
|
default:
|
2021-08-27 14:01:38 +03:00
|
|
|
evdev_device_process_event(event);
|
|
|
|
break;
|
2014-03-13 01:08:42 +04:00
|
|
|
}
|
|
|
|
|
2021-08-27 14:01:38 +03:00
|
|
|
return ret;
|
2014-03-13 01:08:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
process_event(struct libinput_event *event)
|
|
|
|
{
|
|
|
|
if (udev_input_process_event(event))
|
2021-08-27 14:01:38 +03:00
|
|
|
exit(EXIT_FAILURE);
|
2014-03-13 01:08:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
process_events(struct udev_input *input)
|
|
|
|
{
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
|
|
while ((event = libinput_get_event(input->libinput))) {
|
|
|
|
process_event(event);
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
udev_input_dispatch(struct udev_input *input)
|
|
|
|
{
|
|
|
|
if (libinput_dispatch(input->libinput) != 0)
|
|
|
|
weston_log("libinput: Failed to dispatch libinput\n");
|
|
|
|
|
|
|
|
process_events(input);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
libinput_source_dispatch(int fd, uint32_t mask, void *data)
|
|
|
|
{
|
|
|
|
struct udev_input *input = data;
|
|
|
|
|
|
|
|
return udev_input_dispatch(input) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
open_restricted(const char *path, int flags, void *user_data)
|
|
|
|
{
|
|
|
|
struct udev_input *input = user_data;
|
|
|
|
struct weston_launcher *launcher = input->compositor->launcher;
|
|
|
|
|
|
|
|
return weston_launcher_open(launcher, path, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
close_restricted(int fd, void *user_data)
|
|
|
|
{
|
|
|
|
struct udev_input *input = user_data;
|
|
|
|
struct weston_launcher *launcher = input->compositor->launcher;
|
|
|
|
|
|
|
|
weston_launcher_close(launcher, fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct libinput_interface libinput_interface = {
|
|
|
|
open_restricted,
|
|
|
|
close_restricted,
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
udev_input_enable(struct udev_input *input)
|
|
|
|
{
|
|
|
|
struct wl_event_loop *loop;
|
|
|
|
struct weston_compositor *c = input->compositor;
|
|
|
|
int fd;
|
|
|
|
struct udev_seat *seat;
|
|
|
|
int devices_found = 0;
|
|
|
|
|
|
|
|
loop = wl_display_get_event_loop(c->wl_display);
|
|
|
|
fd = libinput_get_fd(input->libinput);
|
|
|
|
input->libinput_source =
|
|
|
|
wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE,
|
|
|
|
libinput_source_dispatch, input);
|
|
|
|
if (!input->libinput_source) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (input->suspended) {
|
|
|
|
if (libinput_resume(input->libinput) != 0) {
|
|
|
|
wl_event_source_remove(input->libinput_source);
|
|
|
|
input->libinput_source = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
input->suspended = 0;
|
|
|
|
process_events(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_for_each(seat, &input->compositor->seat_list, base.link) {
|
|
|
|
evdev_notify_keyboard_focus(&seat->base, &seat->devices_list);
|
|
|
|
|
|
|
|
if (!wl_list_empty(&seat->devices_list))
|
|
|
|
devices_found = 1;
|
|
|
|
}
|
|
|
|
|
2016-10-21 22:03:13 +03:00
|
|
|
if (devices_found == 0 && !c->require_input) {
|
|
|
|
weston_log("warning: no input devices found, but none required "
|
|
|
|
"as per configuration.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-13 01:08:42 +04:00
|
|
|
if (devices_found == 0) {
|
|
|
|
weston_log(
|
|
|
|
"warning: no input devices on entering Weston. "
|
|
|
|
"Possible causes:\n"
|
|
|
|
"\t- no permissions to read /dev/input/event*\n"
|
|
|
|
"\t- seats misconfigured "
|
|
|
|
"(Weston backend option 'seat', "
|
|
|
|
"udev device property ID_SEAT)\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-17 18:53:22 +04:00
|
|
|
static void
|
2014-06-25 08:07:36 +04:00
|
|
|
libinput_log_func(struct libinput *libinput,
|
|
|
|
enum libinput_log_priority priority,
|
|
|
|
const char *format, va_list args)
|
2014-04-17 18:53:22 +04:00
|
|
|
{
|
|
|
|
weston_vlog(format, args);
|
|
|
|
}
|
|
|
|
|
2014-03-13 01:08:42 +04:00
|
|
|
int
|
2014-09-12 13:07:43 +04:00
|
|
|
udev_input_init(struct udev_input *input, struct weston_compositor *c,
|
2016-06-02 21:48:12 +03:00
|
|
|
struct udev *udev, const char *seat_id,
|
|
|
|
udev_configure_device_t configure_device)
|
2014-03-13 01:08:42 +04:00
|
|
|
{
|
2014-09-12 13:07:43 +04:00
|
|
|
enum libinput_log_priority priority = LIBINPUT_LOG_PRIORITY_INFO;
|
2014-04-17 18:53:23 +04:00
|
|
|
const char *log_priority = NULL;
|
|
|
|
|
2014-03-13 01:08:42 +04:00
|
|
|
memset(input, 0, sizeof *input);
|
|
|
|
|
|
|
|
input->compositor = c;
|
2016-06-02 21:48:12 +03:00
|
|
|
input->configure_device = configure_device;
|
2014-03-13 01:08:42 +04:00
|
|
|
|
2014-04-17 18:53:23 +04:00
|
|
|
log_priority = getenv("WESTON_LIBINPUT_LOG_PRIORITY");
|
2014-05-09 22:24:40 +04:00
|
|
|
|
2014-06-25 08:07:36 +04:00
|
|
|
input->libinput = libinput_udev_create_context(&libinput_interface,
|
|
|
|
input, udev);
|
|
|
|
if (!input->libinput) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
libinput_log_set_handler(input->libinput, &libinput_log_func);
|
|
|
|
|
2014-04-17 18:53:23 +04:00
|
|
|
if (log_priority) {
|
2014-05-09 22:24:40 +04:00
|
|
|
if (strcmp(log_priority, "debug") == 0) {
|
2014-09-12 13:07:43 +04:00
|
|
|
priority = LIBINPUT_LOG_PRIORITY_DEBUG;
|
2014-05-09 22:24:40 +04:00
|
|
|
} else if (strcmp(log_priority, "info") == 0) {
|
2014-09-12 13:07:43 +04:00
|
|
|
priority = LIBINPUT_LOG_PRIORITY_INFO;
|
2014-05-09 22:24:40 +04:00
|
|
|
} else if (strcmp(log_priority, "error") == 0) {
|
2014-09-12 13:07:43 +04:00
|
|
|
priority = LIBINPUT_LOG_PRIORITY_ERROR;
|
2014-05-09 22:24:40 +04:00
|
|
|
}
|
2014-04-17 18:53:23 +04:00
|
|
|
}
|
|
|
|
|
2014-09-12 13:07:43 +04:00
|
|
|
libinput_log_set_priority(input->libinput, priority);
|
|
|
|
|
2014-06-25 08:07:36 +04:00
|
|
|
if (libinput_udev_assign_seat(input->libinput, seat_id) != 0) {
|
|
|
|
libinput_unref(input->libinput);
|
2014-03-13 01:08:42 +04:00
|
|
|
return -1;
|
|
|
|
}
|
2014-06-25 08:07:36 +04:00
|
|
|
|
2014-03-13 01:08:42 +04:00
|
|
|
process_events(input);
|
|
|
|
|
|
|
|
return udev_input_enable(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
udev_input_destroy(struct udev_input *input)
|
|
|
|
{
|
|
|
|
struct udev_seat *seat, *next;
|
|
|
|
|
2017-07-26 00:39:20 +03:00
|
|
|
if (input->libinput_source)
|
|
|
|
wl_event_source_remove(input->libinput_source);
|
2014-03-13 01:08:42 +04:00
|
|
|
wl_list_for_each_safe(seat, next, &input->compositor->seat_list, base.link)
|
|
|
|
udev_seat_destroy(seat);
|
2014-06-25 08:07:36 +04:00
|
|
|
libinput_unref(input->libinput);
|
2014-03-13 01:08:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
udev_seat_led_update(struct weston_seat *seat_base, enum weston_led leds)
|
|
|
|
{
|
|
|
|
struct udev_seat *seat = (struct udev_seat *) seat_base;
|
|
|
|
struct evdev_device *device;
|
|
|
|
|
|
|
|
wl_list_for_each(device, &seat->devices_list, link)
|
|
|
|
evdev_led_update(device, leds);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 14:29:40 +03:00
|
|
|
udev_seat_output_changed(struct udev_seat *seat, struct weston_output *output)
|
2014-03-13 01:08:42 +04:00
|
|
|
{
|
|
|
|
struct evdev_device *device;
|
2018-03-19 15:55:41 +03:00
|
|
|
struct weston_output *found;
|
2014-03-13 01:08:42 +04:00
|
|
|
|
2014-04-24 16:11:17 +04:00
|
|
|
wl_list_for_each(device, &seat->devices_list, link) {
|
2018-03-19 15:55:41 +03:00
|
|
|
/* If we find any input device without an associated output
|
|
|
|
* or an output name to associate with, just tie it with the
|
2019-02-20 18:33:32 +03:00
|
|
|
* output we got here - the default assignment.
|
2018-03-19 15:55:41 +03:00
|
|
|
*/
|
|
|
|
if (!device->output_name) {
|
|
|
|
if (!device->output)
|
|
|
|
evdev_device_set_output(device, output);
|
|
|
|
|
|
|
|
continue;
|
2014-03-13 01:08:42 +04:00
|
|
|
}
|
2014-04-24 16:11:17 +04:00
|
|
|
|
2018-03-19 15:55:41 +03:00
|
|
|
/* Update all devices' output associations, may they gain or
|
|
|
|
* lose it.
|
|
|
|
*/
|
|
|
|
found = output_find_by_head_name(output->compositor,
|
|
|
|
device->output_name);
|
|
|
|
evdev_device_set_output(device, found);
|
2014-04-24 16:11:17 +04:00
|
|
|
}
|
2014-03-13 01:08:42 +04:00
|
|
|
}
|
|
|
|
|
2018-03-20 14:29:40 +03:00
|
|
|
static void
|
|
|
|
notify_output_create(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct udev_seat *seat = container_of(listener, struct udev_seat,
|
|
|
|
output_create_listener);
|
|
|
|
struct weston_output *output = data;
|
|
|
|
|
|
|
|
udev_seat_output_changed(seat, output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
notify_output_heads_changed(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct udev_seat *seat = container_of(listener, struct udev_seat,
|
|
|
|
output_heads_listener);
|
|
|
|
struct weston_output *output = data;
|
|
|
|
|
|
|
|
udev_seat_output_changed(seat, output);
|
|
|
|
}
|
|
|
|
|
2014-03-13 01:08:42 +04:00
|
|
|
static struct udev_seat *
|
|
|
|
udev_seat_create(struct udev_input *input, const char *seat_name)
|
|
|
|
{
|
|
|
|
struct weston_compositor *c = input->compositor;
|
|
|
|
struct udev_seat *seat;
|
|
|
|
|
|
|
|
seat = zalloc(sizeof *seat);
|
|
|
|
if (!seat)
|
|
|
|
return NULL;
|
2014-04-22 03:51:02 +04:00
|
|
|
|
2014-03-13 01:08:42 +04:00
|
|
|
weston_seat_init(&seat->base, c, seat_name);
|
|
|
|
seat->base.led_update = udev_seat_led_update;
|
|
|
|
|
|
|
|
seat->output_create_listener.notify = notify_output_create;
|
|
|
|
wl_signal_add(&c->output_created_signal,
|
|
|
|
&seat->output_create_listener);
|
|
|
|
|
2018-03-20 14:29:40 +03:00
|
|
|
seat->output_heads_listener.notify = notify_output_heads_changed;
|
|
|
|
wl_signal_add(&c->output_heads_changed_signal,
|
|
|
|
&seat->output_heads_listener);
|
|
|
|
|
2014-03-13 01:08:42 +04:00
|
|
|
wl_list_init(&seat->devices_list);
|
|
|
|
|
|
|
|
return seat;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
udev_seat_destroy(struct udev_seat *seat)
|
|
|
|
{
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_keyboard *keyboard =
|
|
|
|
weston_seat_get_keyboard(&seat->base);
|
|
|
|
|
|
|
|
if (keyboard)
|
2014-03-13 01:08:42 +04:00
|
|
|
notify_keyboard_focus_out(&seat->base);
|
2015-08-06 20:19:51 +03:00
|
|
|
|
|
|
|
udev_seat_remove_devices(seat);
|
2014-03-13 01:08:42 +04:00
|
|
|
weston_seat_release(&seat->base);
|
|
|
|
wl_list_remove(&seat->output_create_listener.link);
|
2018-03-20 14:29:40 +03:00
|
|
|
wl_list_remove(&seat->output_heads_listener.link);
|
2014-03-13 01:08:42 +04:00
|
|
|
free(seat);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct udev_seat *
|
|
|
|
udev_seat_get_named(struct udev_input *input, const char *seat_name)
|
|
|
|
{
|
|
|
|
struct udev_seat *seat;
|
|
|
|
|
|
|
|
wl_list_for_each(seat, &input->compositor->seat_list, base.link) {
|
|
|
|
if (strcmp(seat->base.seat_name, seat_name) == 0)
|
|
|
|
return seat;
|
|
|
|
}
|
|
|
|
|
|
|
|
return udev_seat_create(input, seat_name);
|
|
|
|
}
|