bool unsync : 1; /* not in-sync with kernel */
bool resync : 1; /* re-syncing with kernel */
+ bool running : 1;
};
struct unmanaged_evdev {
assert(evdev->fd_src);
assert(evdev->idle_src);
+ if (evdev->running)
+ return;
+ if (evdev->fd < 0 || evdev->element.n_open < 1 || !evdev->element.enabled)
+ return;
+
+ evdev->running = true;
sd_event_source_set_enabled(evdev->fd_src, SD_EVENT_ON);
sd_event_source_set_enabled(evdev->idle_src, SD_EVENT_ONESHOT);
}
assert(evdev->fd_src);
assert(evdev->idle_src);
+ if (!evdev->running)
+ return;
+
+ evdev->running = false;
sd_event_source_set_enabled(evdev->fd_src, SD_EVENT_OFF);
sd_event_source_set_enabled(evdev->idle_src, SD_EVENT_OFF);
}
if (fd < 0 || evdev->fd == fd) {
fd = -1;
- if (evdev->fd >= 0 && e->n_open > 0 && e->enabled)
- idev_evdev_enable(evdev);
-
+ idev_evdev_enable(evdev);
return 0;
}
return r;
}
- if (e->n_open < 1 || !e->enabled) {
- sd_event_source_set_enabled(evdev->fd_src, SD_EVENT_OFF);
- sd_event_source_set_enabled(evdev->idle_src, SD_EVENT_OFF);
- }
+ sd_event_source_set_enabled(evdev->fd_src, SD_EVENT_OFF);
+ sd_event_source_set_enabled(evdev->idle_src, SD_EVENT_OFF);
evdev->unsync = true;
evdev->fd = fd;
-
fd = -1;
+
+ idev_evdev_enable(evdev);
return 0;
}
log_debug("idev-evdev: %s/%s: pause", e->session->name, e->name);
+ idev_evdev_disable(evdev);
if (release) {
evdev->idle_src = sd_event_source_unref(evdev->idle_src);
evdev->fd_src = sd_event_source_unref(evdev->fd_src);
evdev->fd = safe_close(evdev->fd);
- } else {
- idev_evdev_disable(evdev);
}
}