[PATCH weston 3/5] evdev: Use wl_fixed_t for relative motions

Jonas Ådahl jadahl at gmail.com
Wed May 9 14:31:44 PDT 2012


Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
 src/evdev-private.h |    2 +-
 src/evdev.c         |   18 +++++++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/evdev-private.h b/src/evdev-private.h
index da4fb7e..c93f219 100644
--- a/src/evdev-private.h
+++ b/src/evdev-private.h
@@ -58,7 +58,7 @@ struct evdev_input_device {
 	struct mtdev *mtdev;
 
 	struct {
-		int dx, dy;
+		wl_fixed_t dx, dy;
 	} rel;
 
 	int type; /* event type flags */
diff --git a/src/evdev.c b/src/evdev.c
index 4699586..d27fab9 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -29,12 +29,13 @@
 #include <mtdev.h>
 
 #include "compositor.h"
+#include "launcher-util.h"
 #include "evdev.h"
 #include "evdev-private.h"
 
 static inline void
 evdev_process_key(struct evdev_input_device *device,
-                        struct input_event *e, int time)
+		  struct input_event *e, int time)
 {
 	if (e->value == 2)
 		return;
@@ -150,6 +151,7 @@ evdev_process_absolute_motion_touchpad(struct evdev_input_device *device,
 {
 	/* FIXME: Make this configurable somehow. */
 	const int touchpad_speed = 700;
+	int dx, dy;
 
 	switch (e->code) {
 	case ABS_X:
@@ -157,10 +159,11 @@ evdev_process_absolute_motion_touchpad(struct evdev_input_device *device,
 		if (device->abs.reset_x)
 			device->abs.reset_x = 0;
 		else {
-			device->rel.dx =
+			dx =
 				(e->value - device->abs.old_x) *
 				touchpad_speed /
 				(device->abs.max_x - device->abs.min_x);
+			device->rel.dx = wl_fixed_from_int(dx);
 		}
 		device->abs.old_x = e->value;
 		device->type |= EVDEV_RELATIVE_MOTION;
@@ -170,11 +173,12 @@ evdev_process_absolute_motion_touchpad(struct evdev_input_device *device,
 		if (device->abs.reset_y)
 			device->abs.reset_y = 0;
 		else {
-			device->rel.dy =
+			dy =
 				(e->value - device->abs.old_y) *
 				touchpad_speed /
 				/* maybe use x size here to have the same scale? */
 				(device->abs.max_y - device->abs.min_y);
+			device->rel.dy = wl_fixed_from_int(dy);
 		}
 		device->abs.old_y = e->value;
 		device->type |= EVDEV_RELATIVE_MOTION;
@@ -188,11 +192,11 @@ evdev_process_relative(struct evdev_input_device *device,
 {
 	switch (e->code) {
 	case REL_X:
-		device->rel.dx += e->value;
+		device->rel.dx += wl_fixed_from_int(e->value);
 		device->type |= EVDEV_RELATIVE_MOTION;
 		break;
 	case REL_Y:
-		device->rel.dy += e->value;
+		device->rel.dy += wl_fixed_from_int(e->value);
 		device->type |= EVDEV_RELATIVE_MOTION;
 		break;
 	case REL_WHEEL:
@@ -254,8 +258,8 @@ evdev_flush_motion(struct evdev_input_device *device, uint32_t time)
 
 	if (device->type & EVDEV_RELATIVE_MOTION) {
 		notify_motion(master, time,
-			      master->x + wl_fixed_from_int(device->rel.dx),
-			      master->y + wl_fixed_from_int(device->rel.dy));
+			      master->x + device->rel.dx,
+			      master->y + device->rel.dy);
 		device->type &= ~EVDEV_RELATIVE_MOTION;
 		device->rel.dx = 0;
 		device->rel.dy = 0;
-- 
1.7.9.5



More information about the wayland-devel mailing list