[PATCH weston v4 2/3] Convert internal input co-ordinates to GLfloat

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


Change all client motion handlers to take GLfloat for co-ordinates,
rather than int32_t.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 clients/desktop-shell.c |    4 ++--
 clients/dnd.c           |    6 +++---
 clients/eventdemo.c     |    4 ++--
 clients/flower.c        |    2 +-
 clients/gears.c         |    2 +-
 clients/smoke.c         |    2 +-
 clients/terminal.c      |    2 +-
 clients/window.c        |   12 ++++++------
 clients/window.h        |    7 ++++---
 src/compositor.c        |    6 +++---
 src/compositor.h        |    6 +++---
 tests/test-client.c     |    3 ++-
 12 files changed, 29 insertions(+), 27 deletions(-)

v4: Use GLfloat instead of double.

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 3617cf9..77e6a18 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -233,7 +233,7 @@ panel_redraw_handler(struct widget *widget, void *data)
 
 static int
 panel_launcher_enter_handler(struct widget *widget, struct input *input,
-			     int32_t x, int32_t y, void *data)
+			     GLfloat x, GLfloat y, void *data)
 {
 	struct panel_launcher *launcher = data;
 
@@ -504,7 +504,7 @@ unlock_dialog_keyboard_focus_handler(struct window *window,
 static int
 unlock_dialog_widget_enter_handler(struct widget *widget,
 				   struct input *input,
-				   int32_t x, int32_t y, void *data)
+				   GLfloat x, GLfloat y, void *data)
 {
 	struct unlock_dialog *dialog = data;
 
diff --git a/clients/dnd.c b/clients/dnd.c
index 54fc1f2..c2975d5 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -450,7 +450,7 @@ lookup_cursor(struct dnd *dnd, int x, int y)
 
 static int
 dnd_enter_handler(struct widget *widget,
-		  struct input *input, int32_t x, int32_t y, void *data)
+		  struct input *input, GLfloat x, GLfloat y, void *data)
 {
 	return lookup_cursor(data, x, y);
 }
@@ -458,7 +458,7 @@ dnd_enter_handler(struct widget *widget,
 static int
 dnd_motion_handler(struct widget *widget,
 		   struct input *input, uint32_t time,
-		   int32_t x, int32_t y, void *data)
+		   GLfloat x, GLfloat y, void *data)
 {
 	return lookup_cursor(data, x, y);
 }
@@ -466,7 +466,7 @@ dnd_motion_handler(struct widget *widget,
 static void
 dnd_data_handler(struct window *window,
 		 struct input *input,
-		 int32_t x, int32_t y, const char **types, void *data)
+		 GLfloat x, GLfloat y, const char **types, void *data)
 {
 	struct dnd *dnd = data;
 
diff --git a/clients/eventdemo.c b/clients/eventdemo.c
index 6ecb7d7..3189497 100644
--- a/clients/eventdemo.c
+++ b/clients/eventdemo.c
@@ -238,12 +238,12 @@ button_handler(struct widget *widget, struct input *input, uint32_t time,
  */
 static int
 motion_handler(struct widget *widget, struct input *input, uint32_t time,
-	       int32_t x, int32_t y, void *data)
+	       GLfloat x, GLfloat y, void *data)
 {
 	struct eventdemo *e = data;
 
 	if (log_motion) {
-		printf("motion time: %d, x: %d, y: %d\n", time, x, y);
+		printf("motion time: %d, x: %f, y: %f\n", time, x, y);
 	}
 
 	if (x > e->x && x < e->x + e->w)
diff --git a/clients/flower.c b/clients/flower.c
index 0827c14..5fc14b5 100644
--- a/clients/flower.c
+++ b/clients/flower.c
@@ -134,7 +134,7 @@ redraw_handler(struct widget *widget, void *data)
 
 static int
 motion_handler(struct widget *widget, struct input *input,
-	       uint32_t time, int32_t x, int32_t y, void *data)
+	       uint32_t time, GLfloat x, GLfloat y, void *data)
 {
 	return POINTER_HAND1;
 }
diff --git a/clients/gears.c b/clients/gears.c
index 9d0fba1..3a57fa6 100644
--- a/clients/gears.c
+++ b/clients/gears.c
@@ -223,7 +223,7 @@ static const struct wl_callback_listener listener = {
 
 static int
 motion_handler(struct widget *widget, struct input *input,
-		uint32_t time, int32_t x, int32_t y, void *data)
+		uint32_t time, GLfloat x, GLfloat y, void *data)
 {
 	struct gears *gears = data;
 	int offset_x, offset_y;
diff --git a/clients/smoke.c b/clients/smoke.c
index 2ab171f..1cf8162 100644
--- a/clients/smoke.c
+++ b/clients/smoke.c
@@ -230,7 +230,7 @@ redraw_handler(struct widget *widget, void *data)
 
 static int
 smoke_motion_handler(struct widget *widget, struct input *input,
-		     uint32_t time, int32_t x, int32_t y, void *data)
+		     uint32_t time, GLfloat x, GLfloat y, void *data)
 {
 	struct smoke *smoke = data;
 	int i, i0, i1, j, j0, j1, k, d = 5;
diff --git a/clients/terminal.c b/clients/terminal.c
index fd6fb5e..4fbc1ff 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -2237,7 +2237,7 @@ button_handler(struct widget *widget,
 static int
 motion_handler(struct widget *widget,
 	       struct input *input, uint32_t time,
-	       int32_t x, int32_t y, void *data)
+	       GLfloat x, GLfloat y, void *data)
 {
 	struct terminal *terminal = data;
 
diff --git a/clients/window.c b/clients/window.c
index c7da54a..f5114bd 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -178,7 +178,7 @@ struct input {
 	int current_cursor;
 	uint32_t modifiers;
 	uint32_t pointer_enter_serial;
-	int32_t sx, sy;
+	GLfloat sx, sy;
 	struct wl_list link;
 
 	struct widget *focus_widget;
@@ -1336,7 +1336,7 @@ window_show_frame_menu(struct window *window,
 
 static int
 frame_enter_handler(struct widget *widget,
-		    struct input *input, int32_t x, int32_t y, void *data)
+		    struct input *input, GLfloat x, GLfloat y, void *data)
 {
 	return frame_get_pointer_image_for_location(data, input);
 }
@@ -1344,7 +1344,7 @@ frame_enter_handler(struct widget *widget,
 static int
 frame_motion_handler(struct widget *widget,
 		     struct input *input, uint32_t time,
-		     int32_t x, int32_t y, void *data)
+		     GLfloat x, GLfloat y, void *data)
 {
 	return frame_get_pointer_image_for_location(data, input);
 }
@@ -1439,7 +1439,7 @@ frame_destroy(struct frame *frame)
 
 static void
 input_set_focus_widget(struct input *input, struct widget *focus,
-		       int32_t x, int32_t y)
+		       GLfloat x, GLfloat y)
 {
 	struct widget *old, *widget;
 	int pointer = POINTER_LEFT_PTR;
@@ -2458,7 +2458,7 @@ menu_set_item(struct menu *menu, int sy)
 static int
 menu_motion_handler(struct widget *widget,
 		    struct input *input, uint32_t time,
-		    int32_t x, int32_t y, void *data)
+		    GLfloat x, GLfloat y, void *data)
 {
 	struct menu *menu = data;
 
@@ -2470,7 +2470,7 @@ menu_motion_handler(struct widget *widget,
 
 static int
 menu_enter_handler(struct widget *widget,
-		   struct input *input, int32_t x, int32_t y, void *data)
+		   struct input *input, GLfloat x, GLfloat y, void *data)
 {
 	struct menu *menu = data;
 
diff --git a/clients/window.h b/clients/window.h
index 1dd5f0c..ac52935 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -23,6 +23,7 @@
 #ifndef _WINDOW_H_
 #define _WINDOW_H_
 
+#include <GLES2/gl2.h>
 #include <xkbcommon/xkbcommon.h>
 #include <wayland-client.h>
 #include <cairo.h>
@@ -165,7 +166,7 @@ typedef void (*window_keyboard_focus_handler_t)(struct window *window,
 
 typedef void (*window_data_handler_t)(struct window *window,
 				      struct input *input,
-				      int32_t x, int32_t y,
+				      GLfloat x, GLfloat y,
 				      const char **types,
 				      void *data);
 
@@ -182,12 +183,12 @@ typedef void (*widget_redraw_handler_t)(struct widget *widget, void *data);
 
 typedef int (*widget_enter_handler_t)(struct widget *widget,
 				      struct input *input,
-				      int32_t x, int32_t y, void *data);
+				      GLfloat x, GLfloat y, void *data);
 typedef void (*widget_leave_handler_t)(struct widget *widget,
 				       struct input *input, void *data);
 typedef int (*widget_motion_handler_t)(struct widget *widget,
 				       struct input *input, uint32_t time,
-				       int32_t x, int32_t y, void *data);
+				       GLfloat x, GLfloat y, void *data);
 typedef void (*widget_button_handler_t)(struct widget *widget,
 					struct input *input, uint32_t time,
 					uint32_t button, uint32_t state,
diff --git a/src/compositor.c b/src/compositor.c
index 2e1c9e4..e3b4118 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1553,7 +1553,7 @@ weston_input_update_drag_surface(struct wl_input_device *input_device,
 				 int dx, int dy);
 
 WL_EXPORT void
-notify_motion(struct wl_input_device *device, uint32_t time, int x, int y)
+notify_motion(struct wl_input_device *device, uint32_t time, GLfloat x, GLfloat y)
 {
 	struct weston_output *output;
 	const struct wl_pointer_grab_interface *interface;
@@ -1769,7 +1769,7 @@ notify_key(struct wl_input_device *device,
 
 WL_EXPORT void
 notify_pointer_focus(struct wl_input_device *device,
-		     struct weston_output *output, int32_t x, int32_t y)
+		     struct weston_output *output, GLfloat x, GLfloat y)
 {
 	struct weston_input_device *wd = (struct weston_input_device *) device;
 	struct weston_compositor *compositor = wd->compositor;
@@ -1917,7 +1917,7 @@ touch_set_focus(struct weston_input_device *device,
  */
 WL_EXPORT void
 notify_touch(struct wl_input_device *device, uint32_t time, int touch_id,
-             int x, int y, int touch_type)
+             GLfloat x, GLfloat y, int touch_type)
 {
 	struct weston_input_device *wd = (struct weston_input_device *) device;
 	struct weston_compositor *ec = wd->compositor;
diff --git a/src/compositor.h b/src/compositor.h
index 3d9ddd8..0278cf9 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -421,7 +421,7 @@ weston_surface_draw(struct weston_surface *es,
 
 void
 notify_motion(struct wl_input_device *device,
-	      uint32_t time, int x, int y);
+	      uint32_t time, GLfloat x, GLfloat y);
 void
 notify_button(struct wl_input_device *device,
 	      uint32_t time, int32_t button, uint32_t state);
@@ -435,14 +435,14 @@ notify_key(struct wl_input_device *device,
 void
 notify_pointer_focus(struct wl_input_device *device,
 		     struct weston_output *output,
-		     int32_t x, int32_t y);
+		     GLfloat x, GLfloat y);
 
 void
 notify_keyboard_focus(struct wl_input_device *device, struct wl_array *keys);
 
 void
 notify_touch(struct wl_input_device *device, uint32_t time, int touch_id,
-	     int x, int y, int touch_type);
+	     GLfloat x, GLfloat y, int touch_type);
 
 void
 weston_layer_init(struct weston_layer *layer, struct wl_list *below);
diff --git a/tests/test-client.c b/tests/test-client.c
index f490b27..05156bd 100644
--- a/tests/test-client.c
+++ b/tests/test-client.c
@@ -27,6 +27,7 @@
 #include <assert.h>
 #include <poll.h>
 #include <wayland-client.h>
+#include <GLES2/gl2.h> /* needed for GLfloat */
 
 struct display {
 	struct wl_display *display;
@@ -37,7 +38,7 @@ struct display {
 
 struct input {
 	struct wl_input_device *input_device;
-	int32_t x, y;
+	GLfloat x, y;
 	uint32_t button_mask;
 	struct surface *pointer_focus;
 	struct surface *keyboard_focus;
-- 
1.7.10



More information about the wayland-devel mailing list