[PATCH wayland v4 2/2] Input: Convert pointer co-ordinates to signed_24_8

Daniel Stone daniel at fooishbar.org
Tue May 8 09:17:26 PDT 2012


This offers more precision when using devices like tablets, and also for
transformed surfaces.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 protocol/wayland.xml |   24 ++++++++++++------------
 src/data-device.c    |   11 +++++++----
 src/wayland-server.c |   10 +++++-----
 src/wayland-server.h |   18 +++++++++++-------
 4 files changed, 35 insertions(+), 28 deletions(-)

v4: Follow rename to 'fixed'.
    Always perform explicit conversions from bare integers.

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 51072b6..d1c6f94 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -345,8 +345,8 @@
     <event name="enter">
       <arg name="serial" type="uint"/>
       <arg name="surface" type="object" interface="wl_surface"/>
-      <arg name="x" type="int"/>
-      <arg name="y" type="int"/>
+      <arg name="x" type="fixed"/>
+      <arg name="y" type="fixed"/>
       <arg name="id" type="object" interface="wl_data_offer"/>
     </event>
 
@@ -354,8 +354,8 @@
 
     <event name="motion">
       <arg name="time" type="uint"/>
-      <arg name="x" type="int"/>
-      <arg name="y" type="int"/>
+      <arg name="x" type="fixed"/>
+      <arg name="y" type="fixed"/>
     </event>
 
     <event name="drop"/>
@@ -725,8 +725,8 @@
       </description>
 
       <arg name="time" type="uint"/>
-      <arg name="surface_x" type="int"/>
-      <arg name="surface_y" type="int"/>
+      <arg name="surface_x" type="fixed"/>
+      <arg name="surface_y" type="fixed"/>
     </event>
 
     <event name="button">
@@ -778,8 +778,8 @@
 
       <arg name="serial" type="uint"/>
       <arg name="surface" type="object" interface="wl_surface"/>
-      <arg name="surface_x" type="int"/>
-      <arg name="surface_y" type="int"/>
+      <arg name="surface_x" type="fixed"/>
+      <arg name="surface_y" type="fixed"/>
     </event>
 
     <event name="pointer_leave">
@@ -805,8 +805,8 @@
       <arg name="time" type="uint"/>
       <arg name="surface" type="object" interface="wl_surface"/>
       <arg name="id" type="int" />
-      <arg name="x" type="int" />
-      <arg name="y" type="int" />
+      <arg name="x" type="fixed" />
+      <arg name="y" type="fixed" />
     </event>
 
     <event name="touch_up">
@@ -818,8 +818,8 @@
     <event name="touch_motion">
       <arg name="time" type="uint"/>
       <arg name="id" type="int" />
-      <arg name="x" type="int" />
-      <arg name="y" type="int" />
+      <arg name="x" type="fixed" />
+      <arg name="y" type="fixed" />
     </event>
 
     <event name="touch_frame">
diff --git a/src/data-device.c b/src/data-device.c
index 7c26809..25b8743 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -178,7 +178,7 @@ destroy_drag_focus(struct wl_listener *listener, void *data)
 
 static void
 drag_grab_focus(struct wl_pointer_grab *grab,
-		struct wl_surface *surface, int32_t x, int32_t y)
+		struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y)
 {
 	struct wl_input_device *device =
 		container_of(grab, struct wl_input_device, drag_grab);
@@ -217,7 +217,7 @@ drag_grab_focus(struct wl_pointer_grab *grab,
 
 static void
 drag_grab_motion(struct wl_pointer_grab *grab,
-		 uint32_t time, int32_t x, int32_t y)
+		 uint32_t time, wl_fixed_t x, wl_fixed_t y)
 {
 	struct wl_input_device *device =
 		container_of(grab, struct wl_input_device, drag_grab);
@@ -243,7 +243,8 @@ data_device_end_drag_grab(struct wl_input_device *device)
 		wl_list_remove(&device->drag_icon_listener.link);
 	}
 
-	drag_grab_focus(&device->drag_grab, NULL, 0, 0);
+	drag_grab_focus(&device->drag_grab, NULL,
+	                wl_fixed_from_int(0), wl_fixed_from_int(0));
 
 	wl_input_device_end_pointer_grab(device);
 
@@ -324,7 +325,9 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
 		wl_signal_emit(&device->drag_icon_signal, icon_resource);
 	}
 
-	wl_input_device_set_pointer_focus(device, NULL, 0, 0);
+	wl_input_device_set_pointer_focus(device, NULL,
+	                                  wl_fixed_from_int(0),
+					  wl_fixed_from_int(0));
 
 	wl_input_device_start_pointer_grab(device, &device->drag_grab);
 }
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 678ab39..62ab503 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -472,7 +472,7 @@ lose_keyboard_focus(struct wl_listener *listener, void *data)
 
 static void
 default_grab_focus(struct wl_pointer_grab *grab,
-		   struct wl_surface *surface, int32_t x, int32_t y)
+		   struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y)
 {
 	struct wl_input_device *device = grab->input_device;
 
@@ -484,7 +484,7 @@ default_grab_focus(struct wl_pointer_grab *grab,
 
 static void
 default_grab_motion(struct wl_pointer_grab *grab,
-		    uint32_t time, int32_t x, int32_t y)
+		    uint32_t time, wl_fixed_t x, wl_fixed_t y)
 {
 	struct wl_resource *resource;
 
@@ -564,8 +564,8 @@ wl_input_device_init(struct wl_input_device *device)
 	wl_signal_init(&device->selection_signal);
 	wl_signal_init(&device->drag_icon_signal);
 
-	device->x = 100;
-	device->y = 100;
+	device->x = wl_fixed_from_int(100);
+	device->y = wl_fixed_from_int(100);
 }
 
 WL_EXPORT void
@@ -601,7 +601,7 @@ find_resource_for_surface(struct wl_list *list, struct wl_surface *surface)
 WL_EXPORT void
 wl_input_device_set_pointer_focus(struct wl_input_device *device,
 				  struct wl_surface *surface,
-				  int32_t sx, int32_t sy)
+				  wl_fixed_t sx, wl_fixed_t sy)
 {
 	struct wl_resource *resource;
 	uint32_t serial;
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 36356a2..d426b35 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -185,9 +185,13 @@ struct wl_surface {
 struct wl_pointer_grab;
 struct wl_pointer_grab_interface {
 	void (*focus)(struct wl_pointer_grab *grab,
-		      struct wl_surface *surface, int32_t x, int32_t y);
+		      struct wl_surface *surface,
+		      wl_fixed_t x,
+		      wl_fixed_t y);
 	void (*motion)(struct wl_pointer_grab *grab,
-		       uint32_t time, int32_t x, int32_t y);
+		       uint32_t time,
+		       wl_fixed_t x,
+		       wl_fixed_t y);
 	void (*button)(struct wl_pointer_grab *grab,
 		       uint32_t time, uint32_t button, uint32_t state);
 };
@@ -196,7 +200,7 @@ struct wl_pointer_grab {
 	const struct wl_pointer_grab_interface *interface;
 	struct wl_input_device *input_device;
 	struct wl_surface *focus;
-	int32_t x, y;
+	wl_fixed_t x, y;
 };
 
 struct wl_keyboard_grab;
@@ -238,9 +242,9 @@ struct wl_input_device {
 	struct wl_listener pointer_focus_listener;
 	struct wl_listener keyboard_focus_listener;
 
-	int32_t x, y;
+	wl_fixed_t x, y;
 	struct wl_surface *current;
-	int32_t current_x, current_y;
+	wl_fixed_t current_x, current_y;
 
 	struct wl_pointer_grab *pointer_grab;
 	struct wl_pointer_grab default_pointer_grab;
@@ -249,7 +253,7 @@ struct wl_input_device {
 	uint32_t button_count;
 	uint32_t grab_time;
 	uint32_t grab_serial;
-	int32_t grab_x, grab_y;
+	wl_fixed_t grab_x, grab_y;
 	uint32_t grab_button;
 	uint32_t grab_key;
 	struct wl_listener grab_listener;
@@ -320,7 +324,7 @@ wl_input_device_release(struct wl_input_device *device);
 void
 wl_input_device_set_pointer_focus(struct wl_input_device *device,
 				  struct wl_surface *surface,
-				  int32_t sx, int32_t sy);
+				  wl_fixed_t sx, wl_fixed_t sy);
 
 void
 wl_input_device_set_keyboard_focus(struct wl_input_device *device,
-- 
1.7.10



More information about the wayland-devel mailing list