[PATCH v2 4/9] evdev: record absolute events were queued inside evdev_input_device

Tiago Vignatti tiago.vignatti at intel.com
Wed Oct 26 05:55:24 PDT 2011


No functional changes.

Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
 compositor/evdev.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/compositor/evdev.c b/compositor/evdev.c
index 3027c7d..49897bf 100644
--- a/compositor/evdev.c
+++ b/compositor/evdev.c
@@ -37,7 +37,6 @@ struct evdev_input_device {
 	struct evdev_input *master;
 	struct wl_event_source *source;
 	struct wlsc_output *output;
-	int tool;
 	int fd;
 	int x, y, dx, dy;
 	struct {
@@ -48,6 +47,8 @@ struct evdev_input_device {
 	} calibration;
 
 	int is_touchpad, old_x_value, old_y_value, reset_x_value, reset_y_value;
+
+	uint32_t abs_queued;
 };
 
 static inline void
@@ -63,7 +64,6 @@ evdev_process_key(struct evdev_input_device *device,
 	case BTN_TOOL_FINGER:
 	case BTN_TOOL_MOUSE:
 	case BTN_TOOL_LENS:
-		device->tool = value ? e->code : 0;
 		if (device->is_touchpad)
 		{
 			device->reset_x_value = 1;
@@ -97,23 +97,23 @@ evdev_process_key(struct evdev_input_device *device,
 
 static inline void
 evdev_process_absolute_motion(struct evdev_input_device *device,
-			struct input_event *e, int value, int *absolute_event)
+			struct input_event *e, int value)
 {
 	const int screen_width = device->output->current->width;
 	const int screen_height = device->output->current->height;
 
 	switch (e->code) {
 	case ABS_X:
-		*absolute_event = device->tool;
 		device->x = (value - device->calibration.min_x) * screen_width /
 			(device->calibration.max_x - device->calibration.min_x) + device->output->x;
 		break;
 	case ABS_Y:
-		*absolute_event = device->tool;
 		device->y = (value - device->calibration.min_y) * screen_height /
 			(device->calibration.max_y - device->calibration.min_y) + device->output->y;
 		break;
 	}
+
+	device->abs_queued = 1;
 }
 
 static inline void
@@ -168,7 +168,7 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
 	struct wlsc_compositor *ec;
 	struct evdev_input_device *device = data;
 	struct input_event ev[8], *e, *end;
-	int len, value, absolute_event;
+	int len, value;
 	uint32_t time;
 
 	ec = (struct wlsc_compositor *)
@@ -178,7 +178,6 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
 
 	device->dx = 0;
 	device->dy = 0;
-	absolute_event = 0;
 	device->x = device->master->base.input_device.x;
 	device->y = device->master->base.input_device.y;
 
@@ -204,8 +203,7 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
 				evdev_process_absolute_motion_touchpad(device,
 					e, value);
 			else
-				evdev_process_absolute_motion(device, e, value,
-					&absolute_event);
+				evdev_process_absolute_motion(device, e, value);
 			break;
 		case EV_KEY:
 			if (value == 2)
@@ -217,10 +215,11 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
 	if (device->dx != 0 || device->dy != 0)
 		notify_motion(&device->master->base.input_device,
 			      time, device->x + device->dx, device->y + device->dy);
-	if (absolute_event)
+	if (device->abs_queued)
 		notify_motion(&device->master->base.input_device, time,
 		              device->x, device->y);
 
+	device->abs_queued = 0;
 	return 1;
 }
 
@@ -297,7 +296,6 @@ evdev_input_device_create(struct evdev_input *master,
 	device->output = 
 		container_of(ec->output_list.next, struct wlsc_output, link);
 
-	device->tool = 1;
 	device->master = master;
 	device->is_touchpad = 0;
 
-- 
1.7.5.4



More information about the wayland-devel mailing list