mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 14:00:06 +01:00
evdev: Disable the udev monitor when another vt becomes active
We dont want to receive hotplug events while being inactive. When getting back active we enumerate all devices and would end up with two sources for one device that may be hotplugged in the mean time.
This commit is contained in:
parent
5cc1e3263a
commit
38bb7a001b
2 changed files with 25 additions and 6 deletions
25
src/evdev.c
25
src/evdev.c
|
|
@ -632,9 +632,10 @@ evdev_udev_handler(int fd, uint32_t mask, void *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
evdev_config_udev_monitor(struct udev *udev, struct evdev_input *master)
|
||||
int
|
||||
evdev_enable_udev_monitor(struct udev *udev, struct weston_input_device *input_base)
|
||||
{
|
||||
struct evdev_input *master = (struct evdev_input *) input_base;
|
||||
struct wl_event_loop *loop;
|
||||
struct weston_compositor *c = master->base.compositor;
|
||||
int fd;
|
||||
|
|
@ -667,6 +668,20 @@ evdev_config_udev_monitor(struct udev *udev, struct evdev_input *master)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
evdev_disable_udev_monitor(struct weston_input_device *input_base)
|
||||
{
|
||||
struct evdev_input *input = (struct evdev_input *) input_base;
|
||||
|
||||
if (!input->udev_monitor)
|
||||
return;
|
||||
|
||||
udev_monitor_unref(input->udev_monitor);
|
||||
input->udev_monitor = NULL;
|
||||
wl_event_source_remove(input->udev_monitor_source);
|
||||
input->udev_monitor_source = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
evdev_input_create(struct weston_compositor *c, struct udev *udev,
|
||||
const char *seat)
|
||||
|
|
@ -682,7 +697,7 @@ evdev_input_create(struct weston_compositor *c, struct udev *udev,
|
|||
|
||||
wl_list_init(&input->devices_list);
|
||||
input->seat_id = strdup(seat);
|
||||
if (!evdev_config_udev_monitor(udev, input)) {
|
||||
if (!evdev_enable_udev_monitor(udev, &input->base)) {
|
||||
free(input->seat_id);
|
||||
free(input);
|
||||
return;
|
||||
|
|
@ -709,9 +724,7 @@ evdev_input_destroy(struct weston_input_device *input_base)
|
|||
struct evdev_input *input = (struct evdev_input *) input_base;
|
||||
|
||||
evdev_remove_devices(input_base);
|
||||
|
||||
udev_monitor_unref(input->udev_monitor);
|
||||
wl_event_source_remove(input->udev_monitor_source);
|
||||
evdev_disable_udev_monitor(&input->base);
|
||||
|
||||
wl_list_remove(&input->base.link);
|
||||
free(input->seat_id);
|
||||
|
|
|
|||
|
|
@ -33,3 +33,9 @@ evdev_input_create(struct weston_compositor *c, struct udev *udev,
|
|||
|
||||
void
|
||||
evdev_input_destroy(struct weston_input_device *input_base);
|
||||
|
||||
int
|
||||
evdev_enable_udev_monitor(struct udev *udev, struct weston_input_device *input_base);
|
||||
|
||||
void
|
||||
evdev_disable_udev_monitor(struct weston_input_device *input_base);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue