devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=c59595e96481d4d34b812feab680847e3ebc58df

commit c59595e96481d4d34b812feab680847e3ebc58df
Author: jhyuni.kang <jhyuni.k...@samsung.com>
Date:   Wed May 13 12:05:57 2015 -0400

    Support wl_touch and send wl_touch events to client
    
    Summary:
    Currently enlightenment-wayland support pointer and keyboard events.(in 
input)
             So I added EVAS_CALLBACK_MULTI_* event handler and hanling 
functions for wl_touch interface.
             This code send wl_touch events to client like a pointer event.
    
    Test Plan:
    In wayland + enlightenment environment, generate multi touch events.
               The enlightenment will be send wl_touch events to client.
    
    Reviewers: raster, devilhorns, zmike
    
    Reviewed By: devilhorns, zmike
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D2482
---
 src/bin/e_comp_wl.c             | 91 ++++++++++++++++++++++++++++++++++++++++-
 src/bin/e_comp_wl_input.c       | 75 +++++++++++++++++++++++++++------
 src/bin/e_comp_wl_input.h       |  5 ++-
 src/modules/wl_drm/e_mod_main.c |  5 ++-
 src/modules/wl_x11/e_mod_main.c |  5 ++-
 5 files changed, 160 insertions(+), 21 deletions(-)

diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index 1e86e05..1259ca5 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -353,6 +353,84 @@ _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas 
EINA_UNUSED, Evas_Object *
 }
 
 static void
+_e_comp_wl_evas_cb_multi_down(void *data, Evas *evas EINA_UNUSED, Evas_Object 
*obj EINA_UNUSED, void *event)
+{
+   Eina_List *l;
+   struct wl_client *wc;
+   uint32_t serial;
+   struct wl_resource *res;
+   E_Client *ec = data;
+   Evas_Event_Multi_Down *ev = event;
+   wl_fixed_t x, y;
+
+   if (!ec->comp_data->surface) return EINA_FALSE;
+
+   wc = wl_resource_get_client(ec->comp_data->surface);
+   serial = wl_display_next_serial(ec->comp->wl_comp_data->wl.disp);
+
+   x = wl_fixed_from_int(ev->canvas.x - ec->client.x);
+   y = wl_fixed_from_int(ev->canvas.y - ec->client.y);
+
+   EINA_LIST_FOREACH(ec->comp->wl_comp_data->touch.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_touch_check(res)) continue;
+        wl_touch_send_down(res, serial, ev->timestamp, ec->comp_data->surface, 
ev->device, x, y);
+     }
+}
+
+static void
+_e_comp_wl_evas_cb_multi_up(void *data, Evas *evas EINA_UNUSED, Evas_Object 
*obj EINA_UNUSED, void *event)
+{
+   Eina_List *l;
+   struct wl_client *wc;
+   uint32_t serial;
+   struct wl_resource *res;
+   E_Client *ec = data;
+   Evas_Event_Multi_Up *ev = event;
+
+   if (!ec->comp_data->surface) return EINA_FALSE;
+
+   wc = wl_resource_get_client(ec->comp_data->surface);
+   serial = wl_display_next_serial(ec->comp->wl_comp_data->wl.disp);
+
+   EINA_LIST_FOREACH(ec->comp->wl_comp_data->touch.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_touch_check(res)) continue;
+        wl_touch_send_up(res, serial, ev->timestamp, ev->device);
+     }
+}
+
+static void
+_e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object 
*obj EINA_UNUSED, void *event)
+{
+   Eina_List *l;
+   struct wl_client *wc;
+   uint32_t serial;
+   struct wl_resource *res;
+   E_Client *ec = data;
+   Evas_Event_Multi_Move *ev = event;
+   wl_fixed_t x, y;
+
+   if (!ec->comp_data->surface) return EINA_FALSE;
+
+   wc = wl_resource_get_client(ec->comp_data->surface);
+   serial = wl_display_next_serial(ec->comp->wl_comp_data->wl.disp);
+
+   x = wl_fixed_from_int(ev->cur.canvas.x - ec->client.x);
+   y = wl_fixed_from_int(ev->cur.canvas.y - ec->client.y);
+
+   EINA_LIST_FOREACH(ec->comp->wl_comp_data->touch.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_touch_check(res)) continue;
+        wl_touch_send_motion(res, ev->timestamp, ev->device, x, y);
+     }
+}
+
+
+static void
 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool 
use_adj, Eina_Bool adj_child, Eina_Bool do_child)
 {
    Eina_List *files;
@@ -667,6 +745,14 @@ _e_comp_wl_client_evas_init(E_Client *ec)
    evas_object_event_callback_priority_add(ec->frame, 
EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER,
                                   _e_comp_wl_evas_cb_mouse_wheel, ec);
 
+   evas_object_event_callback_priority_add(ec->frame, 
EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER,
+                                  _e_comp_wl_evas_cb_multi_down, ec);
+   evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_UP, 
EVAS_CALLBACK_PRIORITY_AFTER,
+                                  _e_comp_wl_evas_cb_multi_up, ec);
+   evas_object_event_callback_priority_add(ec->frame, 
EVAS_CALLBACK_MULTI_MOVE, EVAS_CALLBACK_PRIORITY_AFTER,
+                                  _e_comp_wl_evas_cb_multi_move, ec);
+
+
    evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, 
EVAS_CALLBACK_PRIORITY_AFTER,
                                   _e_comp_wl_evas_cb_focus_in, ec);
    evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, 
EVAS_CALLBACK_PRIORITY_AFTER,
@@ -2446,8 +2532,9 @@ _e_comp_wl_compositor_create(void)
 
    if (e_comp->comp_type == E_PIXMAP_TYPE_X)
      {
-        e_comp_wl_input_pointer_enabled_set(cdata, EINA_TRUE);
-        e_comp_wl_input_keyboard_enabled_set(cdata, EINA_TRUE);
+        e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
+        e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
+        e_comp_wl_input_touch_enabled_set(EINA_TRUE);
      }
 
    return EINA_TRUE;
diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c
index e529b46..7cea123 100644
--- a/src/bin/e_comp_wl_input.c
+++ b/src/bin/e_comp_wl_input.c
@@ -81,6 +81,12 @@ static const struct wl_keyboard_interface 
_e_keyboard_interface =
    _e_comp_wl_input_cb_resource_destroy
 };
 
+static const struct wl_touch_interface _e_touch_interface =
+{
+   _e_comp_wl_input_cb_resource_destroy
+};
+
+
 static void
 _e_comp_wl_input_cb_pointer_unbind(struct wl_resource *resource)
 {
@@ -194,16 +200,38 @@ _e_comp_wl_input_cb_keyboard_get(struct wl_client 
*client, struct wl_resource *r
 }
 
 static void
-_e_comp_wl_input_cb_touch_get(struct wl_client *client EINA_UNUSED, struct 
wl_resource *resource, uint32_t id EINA_UNUSED)
+_e_comp_wl_input_cb_touch_unbind(struct wl_resource *resource)
 {
    E_Comp_Data *cdata;
 
-   /* DBG("Input Touch Get"); */
-
-   /* NB: Needs new resource !! */
-
    /* get compositor data */
    if (!(cdata = wl_resource_get_user_data(resource))) return;
+
+   cdata->touch.resources = eina_list_remove(cdata->touch.resources, resource);
+}
+
+static void
+_e_comp_wl_input_cb_touch_get(struct wl_client *client EINA_UNUSED, struct 
wl_resource *resource, uint32_t id EINA_UNUSED)
+{
+    E_Comp_Data *cdata;
+    struct wl_resource *res;
+
+    /* get compositor data */
+    if (!(cdata = wl_resource_get_user_data(resource))) return;
+
+    /* try to create pointer resource */
+    res = wl_resource_create(client, &wl_touch_interface,
+                             wl_resource_get_version(resource), id);
+    if (!res)
+      {
+         ERR("Could not create touch on seat %s: %m", cdata->seat.name);
+         wl_client_post_no_memory(client);
+         return;
+      }
+
+    cdata->touch.resources = eina_list_append(cdata->touch.resources, res);
+    wl_resource_set_implementation(res, &_e_touch_interface, cdata,
+                                  _e_comp_wl_input_cb_touch_unbind);
 }
 
 static const struct wl_seat_interface _e_seat_interface =
@@ -525,31 +553,31 @@ e_comp_wl_input_keyboard_state_update(E_Comp_Data *cdata, 
uint32_t keycode, Eina
 }
 
 E_API void
-e_comp_wl_input_pointer_enabled_set(E_Comp_Data *cdata, Eina_Bool enabled)
+e_comp_wl_input_pointer_enabled_set(Eina_Bool enabled)
 {
    /* check for valid compositor data */
-   if (!cdata)
+   if (!e_comp->wl_comp_data)
      {
         ERR("No compositor data");
         return;
      }
 
-   cdata->ptr.enabled = enabled;
-   _e_comp_wl_input_update_seat_caps(cdata);
+   e_comp->wl_comp_data->ptr.enabled = !!enabled;
+   _e_comp_wl_input_update_seat_caps(e_comp->wl_comp_data);
 }
 
 E_API void
-e_comp_wl_input_keyboard_enabled_set(E_Comp_Data *cdata, Eina_Bool enabled)
+e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled)
 {
    /* check for valid compositor data */
-   if (!cdata)
+   if (!e_comp->wl_comp_data)
      {
         ERR("No compositor data");
         return;
      }
 
-   cdata->kbd.enabled = enabled;
-   _e_comp_wl_input_update_seat_caps(cdata);
+   e_comp->wl_comp_data->kbd.enabled = !!enabled;
+   _e_comp_wl_input_update_seat_caps(e_comp->wl_comp_data);
 }
 
 E_API void
@@ -590,3 +618,24 @@ e_comp_wl_input_keymap_set(E_Comp_Data *cdata, const char 
*rules, const char *mo
    free((char *)names.model);
    free((char *)names.layout);
 }
+
+EAPI void
+e_comp_wl_input_touch_enabled_set(Eina_Bool enabled)
+{
+   /* check for valid compositor data */
+   if (!e_comp->wl_comp_data)
+     {
+        ERR("No compositor data");
+        return;
+     }
+
+   e_comp->wl_comp_data->touch.enabled = !!enabled;
+   _e_comp_wl_input_update_seat_caps(e_comp->wl_comp_data);
+}
+
+EINTERN Eina_Bool
+e_comp_wl_input_touch_check(struct wl_resource *res)
+{
+   return wl_resource_instance_of(res, &wl_touch_interface,
+                                  &_e_touch_interface);
+}
diff --git a/src/bin/e_comp_wl_input.h b/src/bin/e_comp_wl_input.h
index 19cad87..b3e8615 100644
--- a/src/bin/e_comp_wl_input.h
+++ b/src/bin/e_comp_wl_input.h
@@ -13,8 +13,9 @@ EINTERN void 
e_comp_wl_input_keyboard_modifiers_update(E_Comp_Data *cdata);
 EINTERN void e_comp_wl_input_keyboard_state_update(E_Comp_Data *cdata, 
uint32_t keycode, Eina_Bool pressed);
 EINTERN void e_comp_wl_input_keyboard_enter_send(E_Client *client);
 
-E_API void e_comp_wl_input_pointer_enabled_set(E_Comp_Data *cdata, Eina_Bool 
enabled);
-E_API void e_comp_wl_input_keyboard_enabled_set(E_Comp_Data *cdata, Eina_Bool 
enabled);
+E_API void e_comp_wl_input_pointer_enabled_set(Eina_Bool enabled);
+E_API void e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled);
+E_API void e_comp_wl_input_touch_enabled_set(Eina_Bool enabled);
 
 E_API void e_comp_wl_input_keymap_set(E_Comp_Data *cdata, const char *rules, 
const char *model, const char *layout);
 
diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c
index 0bf5186..c85c32b 100644
--- a/src/modules/wl_drm/e_mod_main.c
+++ b/src/modules/wl_drm/e_mod_main.c
@@ -456,8 +456,9 @@ e_modapi_init(E_Module *m)
    ecore_evas_pointer_xy_get(e_comp->ee, &e_comp->wl_comp_data->ptr.x,
                              &e_comp->wl_comp_data->ptr.y);
 
-   e_comp_wl_input_pointer_enabled_set(e_comp->wl_comp_data, EINA_TRUE);
-   e_comp_wl_input_keyboard_enabled_set(e_comp->wl_comp_data, EINA_TRUE);
+   e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
+   e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
+   e_comp_wl_input_touch_enabled_set(EINA_TRUE);
 
    /* comp->pointer =  */
    /*   e_pointer_window_new(ecore_evas_window_get(comp->ee), 1); */
diff --git a/src/modules/wl_x11/e_mod_main.c b/src/modules/wl_x11/e_mod_main.c
index 1dc2d32..095205c 100644
--- a/src/modules/wl_x11/e_mod_main.c
+++ b/src/modules/wl_x11/e_mod_main.c
@@ -84,8 +84,9 @@ e_modapi_init(E_Module *m)
    if (!e_comp_wl_init()) return NULL;
    if (!e_comp_canvas_init(w, h)) return NULL;
 
-   e_comp_wl_input_pointer_enabled_set(e_comp->wl_comp_data, EINA_TRUE);
-   e_comp_wl_input_keyboard_enabled_set(e_comp->wl_comp_data, EINA_TRUE);
+   e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
+   e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
+   e_comp_wl_input_touch_enabled_set(EINA_TRUE);
 
    /* e_comp->pointer =  */
    /*   e_pointer_window_new(ecore_evas_window_get(e_comp->ee), EINA_TRUE); */

-- 


Reply via email to