forked from enlightenment/enlightenment
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
This commit is contained in:
parent
57fdd5613d
commit
c59595e964
|
@ -352,6 +352,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
|
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)
|
_e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
|
||||||
{
|
{
|
||||||
|
@ -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,
|
evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER,
|
||||||
_e_comp_wl_evas_cb_mouse_wheel, ec);
|
_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,
|
evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_IN, EVAS_CALLBACK_PRIORITY_AFTER,
|
||||||
_e_comp_wl_evas_cb_focus_in, ec);
|
_e_comp_wl_evas_cb_focus_in, ec);
|
||||||
evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_FOCUS_OUT, EVAS_CALLBACK_PRIORITY_AFTER,
|
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)
|
if (e_comp->comp_type == E_PIXMAP_TYPE_X)
|
||||||
{
|
{
|
||||||
e_comp_wl_input_pointer_enabled_set(cdata, EINA_TRUE);
|
e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
|
||||||
e_comp_wl_input_keyboard_enabled_set(cdata, EINA_TRUE);
|
e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
|
||||||
|
e_comp_wl_input_touch_enabled_set(EINA_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
|
|
@ -81,6 +81,12 @@ static const struct wl_keyboard_interface _e_keyboard_interface =
|
||||||
_e_comp_wl_input_cb_resource_destroy
|
_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
|
static void
|
||||||
_e_comp_wl_input_cb_pointer_unbind(struct wl_resource *resource)
|
_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
|
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;
|
E_Comp_Data *cdata;
|
||||||
|
|
||||||
/* DBG("Input Touch Get"); */
|
|
||||||
|
|
||||||
/* NB: Needs new resource !! */
|
|
||||||
|
|
||||||
/* get compositor data */
|
/* get compositor data */
|
||||||
if (!(cdata = wl_resource_get_user_data(resource))) return;
|
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 =
|
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_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 */
|
/* check for valid compositor data */
|
||||||
if (!cdata)
|
if (!e_comp->wl_comp_data)
|
||||||
{
|
{
|
||||||
ERR("No compositor data");
|
ERR("No compositor data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata->ptr.enabled = enabled;
|
e_comp->wl_comp_data->ptr.enabled = !!enabled;
|
||||||
_e_comp_wl_input_update_seat_caps(cdata);
|
_e_comp_wl_input_update_seat_caps(e_comp->wl_comp_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
E_API void
|
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 */
|
/* check for valid compositor data */
|
||||||
if (!cdata)
|
if (!e_comp->wl_comp_data)
|
||||||
{
|
{
|
||||||
ERR("No compositor data");
|
ERR("No compositor data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cdata->kbd.enabled = enabled;
|
e_comp->wl_comp_data->kbd.enabled = !!enabled;
|
||||||
_e_comp_wl_input_update_seat_caps(cdata);
|
_e_comp_wl_input_update_seat_caps(e_comp->wl_comp_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
E_API void
|
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.model);
|
||||||
free((char *)names.layout);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -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_state_update(E_Comp_Data *cdata, uint32_t keycode, Eina_Bool pressed);
|
||||||
EINTERN void e_comp_wl_input_keyboard_enter_send(E_Client *client);
|
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_pointer_enabled_set(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_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);
|
E_API void e_comp_wl_input_keymap_set(E_Comp_Data *cdata, const char *rules, const char *model, const char *layout);
|
||||||
|
|
||||||
|
|
|
@ -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,
|
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_comp_data->ptr.y);
|
||||||
|
|
||||||
e_comp_wl_input_pointer_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(e_comp->wl_comp_data, EINA_TRUE);
|
e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
|
||||||
|
e_comp_wl_input_touch_enabled_set(EINA_TRUE);
|
||||||
|
|
||||||
/* comp->pointer = */
|
/* comp->pointer = */
|
||||||
/* e_pointer_window_new(ecore_evas_window_get(comp->ee), 1); */
|
/* e_pointer_window_new(ecore_evas_window_get(comp->ee), 1); */
|
||||||
|
|
|
@ -84,8 +84,9 @@ e_modapi_init(E_Module *m)
|
||||||
if (!e_comp_wl_init()) return NULL;
|
if (!e_comp_wl_init()) return NULL;
|
||||||
if (!e_comp_canvas_init(w, h)) 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_pointer_enabled_set(EINA_TRUE);
|
||||||
e_comp_wl_input_keyboard_enabled_set(e_comp->wl_comp_data, EINA_TRUE);
|
e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
|
||||||
|
e_comp_wl_input_touch_enabled_set(EINA_TRUE);
|
||||||
|
|
||||||
/* e_comp->pointer = */
|
/* e_comp->pointer = */
|
||||||
/* e_pointer_window_new(ecore_evas_window_get(e_comp->ee), EINA_TRUE); */
|
/* e_pointer_window_new(ecore_evas_window_get(e_comp->ee), EINA_TRUE); */
|
||||||
|
|
Loading…
Reference in New Issue