From 4b36e969e905e5b45f4d4807798c1ce3e3e44d37 Mon Sep 17 00:00:00 2001
From: Rob Bradford <rob@linux.intel.com>
Date: Mon, 14 May 2012 15:40:44 +0100
Subject: [PATCH] Ecore_Evas (wayland): Adapt input handlers to reflect
 protocol type change

Positions for events are now sent over as fixed point. This change updates the
handler prototypes and converts to integers where necessary.
---
 src/lib/ecore_wayland/ecore_wl_dnd.c   |   16 ++++++------
 src/lib/ecore_wayland/ecore_wl_input.c |   40 ++++++++++++++++----------------
 2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/lib/ecore_wayland/ecore_wl_dnd.c b/src/lib/ecore_wayland/ecore_wl_dnd.c
index ced46c1..39e4f1c 100644
--- a/src/lib/ecore_wayland/ecore_wl_dnd.c
+++ b/src/lib/ecore_wayland/ecore_wl_dnd.c
@@ -34,7 +34,7 @@ _ecore_wl_dnd_add(Ecore_Wl_Input *input, struct wl_data_device *data_device, uns
 }
 
 void 
-_ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer)
+_ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *offer)
 {
    Ecore_Wl_Event_Dnd_Enter *event;
    Ecore_Wl_Input *input;
@@ -57,8 +57,8 @@ _ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device __UNUSED__, u
 
    event->win = win->id;
    event->source = input->drag_source->input->keyboard_focus->id;
-   event->position.x = x;
-   event->position.y = y;
+   event->position.x = wl_fixed_to_int(x);
+   event->position.y = wl_fixed_to_int(y);
    event->num_types = input->drag_source->types.size;
    event->types = input->drag_source->types.data;
 
@@ -81,7 +81,7 @@ _ecore_wl_dnd_leave(void *data, struct wl_data_device *data_device __UNUSED__)
 }
 
 void 
-_ecore_wl_dnd_motion(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, int x, int y)
+_ecore_wl_dnd_motion(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, wl_fixed_t x, wl_fixed_t y)
 {
    Ecore_Wl_Event_Dnd_Position *event;
    Ecore_Wl_Input *input;
@@ -90,15 +90,15 @@ _ecore_wl_dnd_motion(void *data, struct wl_data_device *data_device __UNUSED__,
 
    if (!(input = data)) return;
 
-   input->sx = x;
-   input->sy = y;
+   input->sx = wl_fixed_to_int(x);
+   input->sy = wl_fixed_to_int(y);
 
    if (!(event = calloc(1, sizeof(Ecore_Wl_Event_Dnd_Position)))) return;
 
    event->win = input->drag_source->input->pointer_focus->id;
    event->source = input->drag_source->input->keyboard_focus->id;
-   event->position.x = x;
-   event->position.y = y;
+   event->position.x = input->sx;
+   event->position.y = input->sy;
 
    ecore_event_add(ECORE_WL_EVENT_DND_POSITION, event, NULL, NULL);
 }
diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c
index e8d113d..a0c6bab 100644
--- a/src/lib/ecore_wayland/ecore_wl_input.c
+++ b/src/lib/ecore_wayland/ecore_wl_input.c
@@ -41,23 +41,23 @@
 #define MOD_CONTROL_MASK 0x04
 
 /* local function prototypes */
-static void _ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int sx, int sy);
+static void _ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, wl_fixed_t sx, wl_fixed_t sy);
 static void _ecore_wl_input_cb_button(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state);
 static void _ecore_wl_input_cb_axis(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, unsigned int axis, int value);
 static void _ecore_wl_input_cb_key(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, unsigned int key, unsigned int state);
-static void _ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, int sx, int sy);
+static void _ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy);
 static void _ecore_wl_input_cb_pointer_leave(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface);
 static void _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, struct wl_array *keys __UNUSED__);
 static void _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface);
-static void _ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, int x, int y);
+static void _ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, wl_fixed_t x, wl_fixed_t y);
 static void _ecore_wl_input_cb_touch_up(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, int id __UNUSED__);
-static void _ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, int x, int y);
+static void _ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, wl_fixed_t x, wl_fixed_t y);
 static void _ecore_wl_input_cb_touch_frame(void *data __UNUSED__, struct wl_input_device *input_device __UNUSED__);
 static void _ecore_wl_input_cb_touch_cancel(void *data __UNUSED__, struct wl_input_device *input_device __UNUSED__);
 static void _ecore_wl_input_cb_data_offer(void *data, struct wl_data_device *data_device, unsigned int id);
-static void _ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer);
+static void _ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *offer);
 static void _ecore_wl_input_cb_data_leave(void *data, struct wl_data_device *data_device);
-static void _ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, int x, int y);
+static void _ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, wl_fixed_t x, wl_fixed_t y);
 static void _ecore_wl_input_cb_data_drop(void *data, struct wl_data_device *data_device);
 static void _ecore_wl_input_cb_data_selection(void *data, struct wl_data_device *data_device, struct wl_data_offer *offer);
 
@@ -177,7 +177,7 @@ _ecore_wl_input_pointer_xy_get(int *x, int *y)
 
 /* local functions */
 static void 
-_ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int sx, int sy)
+_ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, wl_fixed_t sx, wl_fixed_t sy)
 {
    Ecore_Wl_Input *input;
 
@@ -188,8 +188,8 @@ _ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNU
    _pointer_x = sx;
    _pointer_y = sy;
 
-   input->sx = sx;
-   input->sy = sy;
+   input->sx = wl_fixed_to_int(sx);
+   input->sy = wl_fixed_to_int(sy);
 
    input->timestamp = timestamp;
 
@@ -376,7 +376,7 @@ _ecore_wl_input_cb_key(void *data, struct wl_input_device *input_device __UNUSED
 }
 
 static void 
-_ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, int sx, int sy)
+_ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy)
 {
    Ecore_Wl_Input *input;
    Ecore_Wl_Window *win = NULL;
@@ -393,8 +393,8 @@ _ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_devic
         input->timestamp = (tv.tv_sec * 1000 + tv.tv_usec / 1000);
      }
 
-   input->sx = sx;
-   input->sy = sy;
+   input->sx = wl_fixed_to_int(sx);
+   input->sy = wl_fixed_to_int(sy);
    input->display->serial = serial;
    input->pointer_enter_serial = serial;
 
@@ -528,7 +528,7 @@ _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_input_device *input_devi
 }
 
 static void 
-_ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, int x, int y)
+_ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, wl_fixed_t x, wl_fixed_t y)
 {
    Ecore_Wl_Input *input;
 
@@ -541,8 +541,8 @@ _ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device _
    /* input->timestamp = timestamp; */
    input->display->serial = serial;
    input->button = 0;
-   input->sx = x;
-   input->sy = y;
+   input->sx = wl_fixed_to_int(x);
+   input->sy = wl_fixed_to_int(y);
    _ecore_wl_input_mouse_down_send(input, input->pointer_focus, timestamp);
 }
 
@@ -564,7 +564,7 @@ _ecore_wl_input_cb_touch_up(void *data, struct wl_input_device *input_device __U
 }
 
 static void 
-_ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, int x, int y)
+_ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, wl_fixed_t x, wl_fixed_t y)
 {
    Ecore_Wl_Input *input;
 
@@ -575,8 +575,8 @@ _ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device
    /* FIXME: NB: Not sure yet if input->timestamp should be set here. 
     * This needs to be tested with an actual touch device */
    /* input->timestamp = timestamp; */
-   input->sx = x;
-   input->sy = y;
+   input->sx = wl_fixed_to_int(x);
+   input->sy = wl_fixed_to_int(y);
 
    _ecore_wl_input_mouse_move_send(input, input->pointer_focus, timestamp);
 }
@@ -602,7 +602,7 @@ _ecore_wl_input_cb_data_offer(void *data, struct wl_data_device *data_device, un
 }
 
 static void 
-_ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer)
+_ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *offer)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
@@ -618,7 +618,7 @@ _ecore_wl_input_cb_data_leave(void *data, struct wl_data_device *data_device)
 }
 
 static void 
-_ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, int x, int y)
+_ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, wl_fixed_t x, wl_fixed_t y)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-- 
1.7.7.6

