e_client: Add a API to send a mouse wheel event 64/90464/2
authorJengHyun Kang <jhyuni.kang@samsung.com>
Fri, 30 Sep 2016 07:30:06 +0000 (16:30 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Wed, 5 Oct 2016 01:05:16 +0000 (18:05 -0700)
Change-Id: Ibcc234976560df4bc11f665c6c807b54154933d1

src/bin/e_client.c
src/bin/e_client.h
src/bin/e_comp_wl.c
src/bin/e_comp_wl.h

index 93eec8c1f7b7f92cd268106b2d1c2293b80af4de..d9293609e71486f111bfeaaf6719e6bb63ba1d17 100644 (file)
@@ -6085,6 +6085,16 @@ e_client_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, unsigned
    return res;
 }
 
+E_API Eina_Bool
+e_client_mouse_wheel_send(E_Client *ec, int x, int y, Ecore_Device *dev, unsigned int time)
+{
+   Eina_Bool res;
+
+   res = e_comp_wl_mouse_wheel_send(ec, x, y, dev, time);
+
+   return res;
+}
+
 E_API Eina_Bool
 e_client_video_client_has(E_Client *ec)
 {
index 2bd8b2e047171f104c61f950082e9513b70bad1e..c4b896dcf652d0a0c7feef16af6adaa44a5dd5d5 100644 (file)
@@ -1032,6 +1032,7 @@ E_API Eina_Bool e_client_touch_update_send(E_Client *ec, int idx, int x, int y,
 E_API Eina_Bool e_client_touch_cancel_send(E_Client *ec);
 E_API Eina_Bool e_client_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, unsigned int time);
 E_API Eina_Bool e_client_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, unsigned int time);
+E_API Eina_Bool e_client_mouse_wheel_send(E_Client *ec, int x, int y, Ecore_Device *dev, unsigned int time);
 
 E_API Eina_Bool e_client_video_client_has(E_Client *ec);
 E_API Eina_Bool e_client_normal_client_has(E_Client *ec);
index 0170521be93111b6ebcd31e34ffbef450644ab11..90fbe8056808fd0615e6160a1c1427f442478935 100644 (file)
@@ -852,8 +852,8 @@ _e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Dev
 
    EINA_LIST_FOREACH(e_comp_wl->input_device_manager.device_list, l, input_dev)
      {
-        if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != ECORE_DEVICE_CLASS_KEYBOARD)) continue;
-        _e_comp_wl_device_last_device_set(ECORE_DEVICE_CLASS_KEYBOARD, input_dev);
+        if (!eina_streq(input_dev->identifier, dev_name)) continue;
+        _e_comp_wl_device_last_device_set(ecore_device_class_get(dev), input_dev);
 
         EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
           {
@@ -1355,30 +1355,43 @@ finish:
 }
 
 static void
-_e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
+_e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, int timestamp)
 {
-   E_Client *ec;
-   Evas_Event_Mouse_Wheel *ev;
    struct wl_resource *res;
    struct wl_client *wc;
    Eina_List *l;
    uint32_t axis, dir;
 
-   ev = event;
-   if (!(ec = data)) return;
-   if (ec->cur_mouse_action) return;
-   if (e_object_is_del(E_OBJECT(ec))) return;
-   if (ec->ignored) return;
-
-   if (ev->direction == 0)
+   if (direction == 0)
      axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
    else
      axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
 
-   if (ev->z < 0)
-     dir = -wl_fixed_from_int(abs(ev->z));
+   if (z < 0)
+     dir = -wl_fixed_from_int(abs(z));
    else
-     dir = wl_fixed_from_int(ev->z);
+     dir = wl_fixed_from_int(z);
+
+   wc = wl_resource_get_client(ec->comp_data->surface);
+   EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
+     {
+        if (!e_comp_wl_input_pointer_check(res)) continue;
+        if (wl_resource_get_client(res) != wc) continue;
+        wl_pointer_send_axis(res, timestamp, axis, dir);
+     }
+}
+
+static void
+_e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
+{
+   E_Client *ec;
+   Evas_Event_Mouse_Wheel *ev;
+
+   ev = event;
+   if (!(ec = data)) return;
+   if (ec->cur_mouse_action) return;
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if (ec->ignored) return;
 
    if (!ec->comp_data->surface) return;
 
@@ -1387,13 +1400,7 @@ _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *
 
    _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
 
-   wc = wl_resource_get_client(ec->comp_data->surface);
-   EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
-     {
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        if (wl_resource_get_client(res) != wc) continue;
-        wl_pointer_send_axis(res, ev->timestamp, axis, dir);
-     }
+  _e_comp_wl_mouse_wheel_send(ec, ev->direction, ev->z, ev->timestamp);
 }
 
 static void
@@ -5704,3 +5711,25 @@ e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_
 
    return EINA_TRUE;
 }
+
+EINTERN Eina_Bool
+e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time)
+{
+   uint32_t serial;
+   struct wl_client *wc;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
+
+   wc = wl_resource_get_client(ec->comp_data->surface);
+   if (!time) time = (uint32_t)(ecore_time_get() * 1000);
+   serial = wl_display_next_serial(e_comp_wl->wl.disp);
+
+   if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
+   else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, time);
+
+   _e_comp_wl_mouse_wheel_send(ec, direction, z, time);
+
+   return EINA_TRUE;
+}
index d2af2471c19cbb9c9caf8350a019702901356fa9..5488ec4428b94a73a2b9521aafce65ef90130852 100644 (file)
@@ -536,6 +536,7 @@ EINTERN Eina_Bool e_comp_wl_touch_update_send(E_Client *ec, int idx, int x, int
 EINTERN Eina_Bool e_comp_wl_touch_cancel_send(E_Client *ec);
 EINTERN Eina_Bool e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_Device *dev, uint32_t time);
 EINTERN Eina_Bool e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time);
+EINTERN Eina_Bool e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time);
 
 E_API extern int E_EVENT_WAYLAND_GLOBAL_ADD;