|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 89febb631a4710992cd41e402a643451b19c11a7 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Sat, 20 Sep 2014 12:39:59 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] terminal: forward evdev RESYNC events to linked devices
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Whenever we resync an evdev device (or disable it), we should send RESYNC
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
events to the linked upper layers. This allows to disable key-repeat and
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assume some events got dropped.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/idev-evdev.c | 22 ++++++++++++++++++----
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 18 insertions(+), 4 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/idev-evdev.c b/src/libsystemd-terminal/idev-evdev.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 25ac849b8d..719e18c316 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/idev-evdev.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/idev-evdev.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -102,7 +102,16 @@ static void idev_evdev_name(char *out, dev_t devnum) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
sprintf(out, "evdev/%u:%u", major(devnum), minor(devnum));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-static int idev_evdev_raise(idev_evdev *evdev, struct input_event *event) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static int idev_evdev_feed_resync(idev_evdev *evdev) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ idev_data data = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .type = IDEV_DATA_RESYNC,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .resync = evdev->resync,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ };
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return idev_element_feed(&evdev->element, &data);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static int idev_evdev_feed_evdev(idev_evdev *evdev, struct input_event *event) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
idev_data data = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
.type = IDEV_DATA_EVDEV,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
.resync = evdev->resync,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -156,7 +165,6 @@ static int idev_evdev_io(idev_evdev *evdev) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* case we cannot keep up with the kernel.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* TODO: Make sure libevdev always reports SYN_DROPPED to us, regardless
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* whether any event was synced afterwards.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * TODO: Forward SYN_DROPPED to attached devices.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
*/
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
flags = LIBEVDEV_READ_FLAG_NORMAL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -191,7 +199,7 @@ static int idev_evdev_io(idev_evdev *evdev) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else if (r == LIBEVDEV_READ_STATUS_SYNC) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (evdev->resync) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* sync-event */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = idev_evdev_raise(evdev, &ev;;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = idev_evdev_feed_evdev(evdev, &ev;;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r != 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
error = r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
break;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -200,10 +208,15 @@ static int idev_evdev_io(idev_evdev *evdev) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* start of sync */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
evdev->resync = true;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
flags = LIBEVDEV_READ_FLAG_SYNC;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = idev_evdev_feed_resync(evdev);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (r != 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ error = r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ break;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* normal event */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = idev_evdev_raise(evdev, &ev;;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = idev_evdev_feed_evdev(evdev, &ev;;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r != 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
error = r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
break;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -288,6 +301,7 @@ static void idev_evdev_disable(idev_evdev *evdev) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
evdev->running = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ idev_evdev_feed_resync(evdev);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
sd_event_source_set_enabled(evdev->fd_src, SD_EVENT_OFF);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
sd_event_source_set_enabled(evdev->idle_src, SD_EVENT_OFF);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|