forked from enlightenment/efl
ecore-wl2: Add start of code to support wl_keyboards
Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
5869b4afa1
commit
f0342a5ffe
|
@ -998,6 +998,10 @@ EAPI void ecore_wl2_seat_pointer_release(Ecore_Wl2_Seat *seat);
|
|||
EAPI Ecore_Wl2_Pointer *ecore_wl2_pointer_get(Ecore_Wl2_Seat *seat);
|
||||
EAPI Eina_Bool ecore_wl2_pointer_resource_create(Ecore_Wl2_Pointer *ptr, struct wl_client *client, const struct wl_pointer_interface *implementation, int version, uint32_t id);
|
||||
|
||||
EAPI Ecore_Wl2_Keyboard *ecore_wl2_keyboard_get(Ecore_Wl2_Seat *seat);
|
||||
EAPI Eina_Bool ecore_wl2_keyboard_resource_create(Ecore_Wl2_Keyboard *kbd, struct wl_client *client, const struct wl_keyboard_interface *implementation, int version, uint32_t id);
|
||||
EAPI void ecore_wl2_keyboard_repeat_info_set(Ecore_Wl2_Keyboard *kbd, double rate, double delay);
|
||||
|
||||
/* # ifdef __cplusplus */
|
||||
/* } */
|
||||
/* # endif */
|
||||
|
|
|
@ -85,6 +85,43 @@ _ecore_wl2_seat_pointer_destroy(Ecore_Wl2_Pointer *ptr)
|
|||
free(ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
_keyboard_cb_unbind(struct wl_resource *resource)
|
||||
{
|
||||
Ecore_Wl2_Keyboard *kbd;
|
||||
|
||||
DBG("Keyboard Unbind");
|
||||
|
||||
kbd = wl_resource_get_user_data(resource);
|
||||
if (!kbd) return;
|
||||
|
||||
kbd->resources = eina_list_remove(kbd->resources, resource);
|
||||
|
||||
/* wl_keyboard_release(); */
|
||||
}
|
||||
|
||||
static Ecore_Wl2_Keyboard *
|
||||
_ecore_wl2_seat_keyboard_create(Ecore_Wl2_Seat *seat)
|
||||
{
|
||||
Ecore_Wl2_Keyboard *kbd;
|
||||
|
||||
kbd = calloc(1, sizeof(Ecore_Wl2_Keyboard));
|
||||
if (!kbd) return NULL;
|
||||
|
||||
/* FIXME: Init keyboard fields */
|
||||
|
||||
kbd->seat = seat;
|
||||
|
||||
return kbd;
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_wl2_seat_keyboard_destroy(Ecore_Wl2_Keyboard *kbd)
|
||||
{
|
||||
/* FIXME: Free keyboard fields */
|
||||
free(kbd);
|
||||
}
|
||||
|
||||
EAPI Ecore_Wl2_Seat *
|
||||
ecore_wl2_seat_create(Ecore_Wl2_Display *display, const char *name, const struct wl_seat_interface *implementation, int version, Ecore_Wl2_Bind_Cb bind_cb, Ecore_Wl2_Unbind_Cb unbind_cb)
|
||||
{
|
||||
|
@ -131,6 +168,7 @@ ecore_wl2_seat_destroy(Ecore_Wl2_Seat *seat)
|
|||
eina_stringshare_del(seat->name);
|
||||
|
||||
if (seat->pointer) _ecore_wl2_seat_pointer_destroy(seat->pointer);
|
||||
if (seat->keyboard) _ecore_wl2_seat_keyboard_destroy(seat->keyboard);
|
||||
|
||||
/* NB: Hmmm, should we iterate and free resources here ?? */
|
||||
|
||||
|
@ -168,7 +206,7 @@ ecore_wl2_seat_pointer_release(Ecore_Wl2_Seat *seat)
|
|||
if (seat->touch_count > 0)
|
||||
caps |= WL_SEAT_CAPABILITY_TOUCH;
|
||||
|
||||
ecore_wl2_seat_capabilities_send(seat, 0);
|
||||
ecore_wl2_seat_capabilities_send(seat, caps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,3 +269,82 @@ ecore_wl2_pointer_resource_create(Ecore_Wl2_Pointer *ptr, struct wl_client *clie
|
|||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Ecore_Wl2_Keyboard *
|
||||
ecore_wl2_keyboard_get(Ecore_Wl2_Seat *seat)
|
||||
{
|
||||
enum wl_seat_capability caps = 0;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL);
|
||||
|
||||
if (seat->pointer_count > 0)
|
||||
caps |= WL_SEAT_CAPABILITY_POINTER;
|
||||
if (seat->keyboard_count > 0)
|
||||
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
if (seat->touch_count > 0)
|
||||
caps |= WL_SEAT_CAPABILITY_TOUCH;
|
||||
|
||||
if (seat->keyboard)
|
||||
{
|
||||
seat->keyboard_count += 1;
|
||||
if (seat->keyboard_count == 1)
|
||||
{
|
||||
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
ecore_wl2_seat_capabilities_send(seat, caps);
|
||||
}
|
||||
|
||||
return seat->keyboard;
|
||||
}
|
||||
|
||||
seat->keyboard = _ecore_wl2_seat_keyboard_create(seat);
|
||||
seat->keyboard_count = 1;
|
||||
|
||||
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
ecore_wl2_seat_capabilities_send(seat, caps);
|
||||
|
||||
return seat->keyboard;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
ecore_wl2_keyboard_resource_create(Ecore_Wl2_Keyboard *kbd, struct wl_client *client, const struct wl_keyboard_interface *implementation, int version, uint32_t id)
|
||||
{
|
||||
struct wl_resource *res;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(kbd, EINA_FALSE);
|
||||
|
||||
res = wl_resource_create(client, &wl_keyboard_interface, version, id);
|
||||
if (!res)
|
||||
{
|
||||
ERR("Could not create keyboard resource: %m");
|
||||
wl_client_post_no_memory(client);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
wl_resource_set_implementation(res, implementation, kbd, _keyboard_cb_unbind);
|
||||
|
||||
kbd->resources = eina_list_append(kbd->resources, res);
|
||||
|
||||
/* FIXME: Hmmm, should we sent a keyboard_enter to kbd->focus'd surface
|
||||
* here like weston does ? */
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ecore_wl2_keyboard_repeat_info_set(Ecore_Wl2_Keyboard *kbd, double rate, double delay)
|
||||
{
|
||||
struct wl_resource *res;
|
||||
Eina_List *l;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(kbd);
|
||||
|
||||
kbd->repeat.rate = rate;
|
||||
kbd->repeat.delay = delay;
|
||||
|
||||
EINA_LIST_FOREACH(kbd->resources, l, res)
|
||||
{
|
||||
if (wl_resource_get_version(res) >=
|
||||
WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
|
||||
wl_keyboard_send_repeat_info(res, rate, delay);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue