From 7906537c021c574fe4cebabbfff4134e8c9be730 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 17 Jan 2017 11:31:48 -0500 Subject: [PATCH] send wl_touch events when we handle mouse buttons Small patch to enable sending wl_touch down/up events when pointer mouse button events are handled. This is needed in the case where we do Not have any mouse pointer at all, but we do have touch support. ref T5094 NB: This allows weston-simple-touch client to operate in Enlightenment now. There is still something strange happening with EFL clients in E wrt touch events tho... Signed-off-by: Chris Michael --- src/bin/e_comp_wl.c | 31 ++++++++++++++++++++++++++----- src/bin/e_comp_wl.h | 2 +- src/modules/xwayland/dnd.c | 6 ++++-- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index deaa6f404..58c940e9a 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -369,6 +369,15 @@ _e_comp_wl_send_mouse_move(E_Client *ec, int x, int y, unsigned int timestamp) wl_fixed_from_int(x - ec->client.x), wl_fixed_from_int(y - ec->client.y)); } + + EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res) + { + if (!e_comp_wl_input_touch_check(res)) continue; + if (wl_resource_get_client(res) != wc) continue; + wl_touch_send_motion(res, timestamp, 1, + wl_fixed_from_int(x - ec->client.x), + wl_fixed_from_int(y - ec->client.y)); + } } static void @@ -395,6 +404,7 @@ _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *o Evas_Event_Mouse_Down *ev = event; e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button, + ev->canvas.x, ev->canvas.y, WL_POINTER_BUTTON_STATE_PRESSED); } @@ -405,6 +415,7 @@ _e_comp_wl_evas_cb_mouse_up(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj Evas_Event_Mouse_Up *ev = event; e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button, + ev->canvas.x, ev->canvas.y, WL_POINTER_BUTTON_STATE_RELEASED); } @@ -1343,7 +1354,6 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state) _e_comp_wl_surface_state_buffer_set(state, NULL); - if (ec->comp_data->shell.surface) { if (ec->comp_data->shell.set.min_size.w) @@ -3317,7 +3327,7 @@ e_comp_wl_key_up(Ecore_Event_Key *ev) } E_API Eina_Bool -e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state) +e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, int x, int y, uint32_t state) { Eina_List *l; struct wl_client *wc; @@ -3368,9 +3378,6 @@ e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t bu if (!ec->comp_data->surface) return EINA_FALSE; - if (!eina_list_count(e_comp_wl->ptr.resources)) - return EINA_TRUE; - wc = wl_resource_get_client(ec->comp_data->surface); *state_serial = serial = wl_display_next_serial(e_comp_wl->wl.disp); @@ -3380,6 +3387,20 @@ e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t bu if (!e_comp_wl_input_pointer_check(res)) continue; wl_pointer_send_button(res, serial, timestamp, btn, state); } + + EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res) + { + if (wl_resource_get_client(res) != wc) continue; + if (!e_comp_wl_input_touch_check(res)) continue; + if (state == WL_POINTER_BUTTON_STATE_PRESSED) + wl_touch_send_down(res, serial, timestamp, + ec->comp_data->surface, 0, + wl_fixed_from_int(x - ec->client.x), + wl_fixed_from_int(y - ec->client.y)); + else + wl_touch_send_up(res, serial, timestamp, 0); + } + return EINA_TRUE; } diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h index a78f5cd0c..ca8164859 100644 --- a/src/bin/e_comp_wl.h +++ b/src/bin/e_comp_wl.h @@ -381,7 +381,7 @@ E_API void e_comp_wl_output_remove(const char *id); EINTERN Eina_Bool e_comp_wl_key_down(Ecore_Event_Key *ev); EINTERN Eina_Bool e_comp_wl_key_up(Ecore_Event_Key *ev); -E_API Eina_Bool e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, uint32_t state); +E_API Eina_Bool e_comp_wl_evas_handle_mouse_button(E_Client *ec, uint32_t timestamp, uint32_t button_id, int x, int y, uint32_t state); E_API extern int E_EVENT_WAYLAND_GLOBAL_ADD; diff --git a/src/modules/xwayland/dnd.c b/src/modules/xwayland/dnd.c index 47c5d9569..56b1fbaf7 100644 --- a/src/modules/xwayland/dnd.c +++ b/src/modules/xwayland/dnd.c @@ -93,9 +93,11 @@ _xwayland_drop(E_Drag *drag, int dropped) if (e_comp->comp_type != E_PIXMAP_TYPE_WL) return; e_comp_wl->drag = NULL; if ((!e_comp_wl->ptr.ec) || - (wl_resource_get_client(e_comp_wl->ptr.ec->comp_data->surface) != e_comp_wl->xwl_client)) + (wl_resource_get_client(e_comp_wl->ptr.ec->comp_data->surface) != e_comp_wl->xwl_client)) e_comp_wl_evas_handle_mouse_button(e_comp_wl->drag_client, 0, - e_comp_wl->ptr.button, WL_POINTER_BUTTON_STATE_RELEASED); + e_comp_wl->ptr.button, + e_comp_wl->ptr.x, e_comp_wl->ptr.y, + WL_POINTER_BUTTON_STATE_RELEASED); if (dropped || e_object_is_del(E_OBJECT(drag)) || (!e_comp_wl->selection.target)) _xdnd_finish(0); else