diff options
author | Daniel Stone <daniel@fooishbar.org> | 2012-05-08 17:17:55 +0100 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-08 14:41:01 -0400 |
commit | 103db7fb56c4befa3c61c619d41ef0733d8d066a (patch) | |
tree | 3cac938f59624b335cb76d5ecf8653c9b4d40938 /clients | |
parent | b230a7ee58ebe12f07b6ace4fcbb7a410038e35c (diff) |
Convert wire input co-ordinates to fixed-point
To add greater precision when working with transformed surfaces and/or
high-resolution input devices.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'clients')
-rw-r--r-- | clients/simple-touch.c | 19 | ||||
-rw-r--r-- | clients/window.c | 22 |
2 files changed, 31 insertions, 10 deletions
diff --git a/clients/simple-touch.c b/clients/simple-touch.c index b8d9156..0dbf3db 100644 --- a/clients/simple-touch.c +++ b/clients/simple-touch.c @@ -29,6 +29,7 @@ #include <unistd.h> #include <sys/mman.h> +#include <GLES2/gl2.h> #include <wayland-client.h> #include <wayland-egl.h> @@ -103,7 +104,9 @@ struct wl_shm_listener shm_listenter = { static void input_device_handle_motion(void *data, struct wl_input_device *input_device, - uint32_t time, int32_t sx, int32_t sy) + uint32_t time, + wl_fixed_t sx_w, + wl_fixed_t sy_w) { } @@ -132,7 +135,7 @@ static void input_device_handle_pointer_enter(void *data, struct wl_input_device *input_device, uint32_t serial, struct wl_surface *surface, - int32_t sx, int32_t sy) + wl_fixed_t sx_w, wl_fixed_t sy_w) { } @@ -197,9 +200,13 @@ input_device_handle_touch_down(void *data, struct wl_input_device *wl_input_device, uint32_t serial, uint32_t time, struct wl_surface *surface, - int32_t id, int32_t x, int32_t y) + int32_t id, + wl_fixed_t x_w, + wl_fixed_t y_w) { struct touch *touch = data; + GLfloat x = wl_fixed_to_double(x_w); + GLfloat y = wl_fixed_to_double(y_w); touch_paint(touch, x, y, id); } @@ -215,9 +222,13 @@ static void input_device_handle_touch_motion(void *data, struct wl_input_device *wl_input_device, uint32_t time, - int32_t id, int32_t x, int32_t y) + int32_t id, + wl_fixed_t x_w, + wl_fixed_t y_w) { struct touch *touch = data; + GLfloat x = wl_fixed_to_double(x_w); + GLfloat y = wl_fixed_to_double(y_w); touch_paint(touch, x, y, id); } diff --git a/clients/window.c b/clients/window.c index f5114bd..b47e969 100644 --- a/clients/window.c +++ b/clients/window.c @@ -1473,12 +1473,14 @@ input_set_focus_widget(struct input *input, struct widget *focus, static void input_handle_motion(void *data, struct wl_input_device *input_device, - uint32_t time, int32_t sx, int32_t sy) + uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w) { struct input *input = data; struct window *window = input->pointer_focus; struct widget *widget; int pointer = POINTER_LEFT_PTR; + GLfloat sx = wl_fixed_to_double(sx_w); + GLfloat sy = wl_fixed_to_double(sy_w); input->sx = sx; input->sy = sy; @@ -1604,11 +1606,13 @@ static void input_handle_pointer_enter(void *data, struct wl_input_device *input_device, uint32_t serial, struct wl_surface *surface, - int32_t sx, int32_t sy) + wl_fixed_t sx_w, wl_fixed_t sy_w) { struct input *input = data; struct window *window; struct widget *widget; + GLfloat sx = wl_fixed_to_double(sx_w); + GLfloat sy = wl_fixed_to_double(sy_w); input->display->serial = serial; input->pointer_enter_serial = serial; @@ -1701,7 +1705,7 @@ input_handle_touch_down(void *data, struct wl_input_device *wl_input_device, uint32_t serial, uint32_t time, struct wl_surface *surface, - int32_t id, int32_t x, int32_t y) + int32_t id, wl_fixed_t x, wl_fixed_t y) { } @@ -1715,7 +1719,8 @@ input_handle_touch_up(void *data, static void input_handle_touch_motion(void *data, struct wl_input_device *wl_input_device, - uint32_t time, int32_t id, int32_t x, int32_t y) + uint32_t time, int32_t id, + wl_fixed_t x, wl_fixed_t y) { } @@ -1838,10 +1843,13 @@ data_device_data_offer(void *data, static void data_device_enter(void *data, struct wl_data_device *data_device, uint32_t serial, struct wl_surface *surface, - int32_t x, int32_t y, struct wl_data_offer *offer) + wl_fixed_t x_w, wl_fixed_t y_w, + struct wl_data_offer *offer) { struct input *input = data; struct window *window; + GLfloat x = wl_fixed_to_double(x_w); + GLfloat y = wl_fixed_to_double(y_w); char **p; input->pointer_enter_serial = serial; @@ -1870,10 +1878,12 @@ data_device_leave(void *data, struct wl_data_device *data_device) static void data_device_motion(void *data, struct wl_data_device *data_device, - uint32_t time, int32_t x, int32_t y) + uint32_t time, wl_fixed_t x_w, wl_fixed_t y_w) { struct input *input = data; struct window *window = input->pointer_focus; + GLfloat x = wl_fixed_to_double(x_w); + GLfloat y = wl_fixed_to_double(y_w); input->sx = x; input->sy = y; |