2012-01-22 08:32:39 -08:00
|
|
|
#include "e.h"
|
2012-01-31 08:36:07 -08:00
|
|
|
#ifdef HAVE_WAYLAND_CLIENTS
|
2013-01-09 03:34:07 -08:00
|
|
|
# include "e_comp_wl.h"
|
|
|
|
# include "e_comp_wl_input.h"
|
2012-01-22 08:32:39 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* local function prototypes */
|
2013-01-09 03:34:07 -08:00
|
|
|
static void _e_comp_wl_input_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id);
|
|
|
|
static void _e_comp_wl_input_unbind(struct wl_resource *resource);
|
|
|
|
static void _e_comp_wl_input_pointer_get(struct wl_client *client, struct wl_resource *resource, unsigned int id);
|
|
|
|
static void _e_comp_wl_input_keyboard_get(struct wl_client *client, struct wl_resource *resource, unsigned int id);
|
|
|
|
static void _e_comp_wl_input_touch_get(struct wl_client *client, struct wl_resource *resource, unsigned int id);
|
|
|
|
static void _e_comp_wl_input_pointer_cursor_set(struct wl_client *client, struct wl_resource *resource, unsigned int serial, struct wl_resource *surface_resource, int x, int y);
|
2012-01-22 08:32:39 -08:00
|
|
|
|
|
|
|
/* wayland interfaces */
|
2012-11-12 06:41:30 -08:00
|
|
|
static const struct wl_seat_interface _wl_seat_interface =
|
2012-01-22 08:32:39 -08:00
|
|
|
{
|
2013-01-09 03:34:07 -08:00
|
|
|
_e_comp_wl_input_pointer_get,
|
|
|
|
_e_comp_wl_input_keyboard_get,
|
|
|
|
_e_comp_wl_input_touch_get
|
2012-11-12 06:41:30 -08:00
|
|
|
};
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
static const struct wl_pointer_interface _wl_pointer_interface =
|
2012-11-12 06:41:30 -08:00
|
|
|
{
|
2013-01-09 03:34:07 -08:00
|
|
|
_e_comp_wl_input_pointer_cursor_set
|
2012-01-22 08:32:39 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* private variables */
|
|
|
|
static Wayland_Input *_wl_input;
|
|
|
|
|
2012-06-28 00:03:44 -07:00
|
|
|
Eina_Bool
|
2013-01-09 03:34:07 -08:00
|
|
|
e_comp_wl_input_init(void)
|
2012-01-22 08:32:39 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-01-26 10:21:54 -08:00
|
|
|
if (!(_wl_input = malloc(sizeof(Wayland_Input))))
|
2012-01-22 08:32:39 -08:00
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Could not allocate space for input\n");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(_wl_input, 0, sizeof(*_wl_input));
|
|
|
|
|
2012-11-12 06:41:30 -08:00
|
|
|
wl_seat_init(&_wl_input->seat);
|
|
|
|
if (!wl_display_add_global(_wl_disp, &wl_seat_interface, _wl_input,
|
2013-01-09 03:34:07 -08:00
|
|
|
_e_comp_wl_input_bind))
|
2012-01-26 10:21:54 -08:00
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Failed to add input to wayland\n");
|
|
|
|
free(_wl_input);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2012-01-22 08:32:39 -08:00
|
|
|
|
|
|
|
_wl_input->hotspot_x = 16;
|
|
|
|
_wl_input->hotspot_y = 16;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-28 00:03:44 -07:00
|
|
|
void
|
2013-01-09 03:34:07 -08:00
|
|
|
e_comp_wl_input_shutdown(void)
|
2012-01-22 08:32:39 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-01-26 10:21:54 -08:00
|
|
|
if (!_wl_input) return;
|
2012-11-12 06:41:30 -08:00
|
|
|
wl_seat_release(&_wl_input->seat);
|
2012-01-22 08:32:39 -08:00
|
|
|
free(_wl_input);
|
|
|
|
}
|
|
|
|
|
|
|
|
Wayland_Input *
|
2013-01-09 03:34:07 -08:00
|
|
|
e_comp_wl_input_get(void)
|
2012-01-22 08:32:39 -08:00
|
|
|
{
|
|
|
|
return _wl_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* local functions */
|
2012-06-28 00:03:44 -07:00
|
|
|
static void
|
2013-01-09 03:34:07 -08:00
|
|
|
_e_comp_wl_input_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id)
|
2012-01-22 08:32:39 -08:00
|
|
|
{
|
2012-11-12 06:41:30 -08:00
|
|
|
Wayland_Input *input;
|
|
|
|
struct wl_seat *device;
|
2012-01-22 08:32:39 -08:00
|
|
|
struct wl_resource *resource;
|
2012-11-12 06:41:30 -08:00
|
|
|
enum wl_seat_capability caps = 0;
|
2012-01-22 08:32:39 -08:00
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-11-12 06:41:30 -08:00
|
|
|
input = data;
|
|
|
|
device = &input->seat;
|
|
|
|
|
2012-06-28 00:03:44 -07:00
|
|
|
resource =
|
2012-11-12 06:41:30 -08:00
|
|
|
wl_client_add_object(client, &wl_seat_interface,
|
|
|
|
&_wl_seat_interface, id, data);
|
|
|
|
wl_list_insert(&device->base_resource_list, &resource->link);
|
2013-01-09 03:34:07 -08:00
|
|
|
resource->destroy = _e_comp_wl_input_unbind;
|
2012-11-12 06:41:30 -08:00
|
|
|
|
|
|
|
if (device->pointer) caps |= WL_SEAT_CAPABILITY_POINTER;
|
|
|
|
if (device->keyboard) caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
|
|
|
if (device->touch) caps |= WL_SEAT_CAPABILITY_TOUCH;
|
|
|
|
|
|
|
|
wl_seat_send_capabilities(resource, caps);
|
2012-01-22 08:32:39 -08:00
|
|
|
}
|
|
|
|
|
2012-06-28 00:03:44 -07:00
|
|
|
static void
|
2013-01-09 03:34:07 -08:00
|
|
|
_e_comp_wl_input_unbind(struct wl_resource *resource)
|
2012-01-22 08:32:39 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
wl_list_remove(&resource->link);
|
|
|
|
free(resource);
|
|
|
|
}
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
static void
|
2013-01-09 03:34:07 -08:00
|
|
|
_e_comp_wl_input_pointer_get(struct wl_client *client, struct wl_resource *resource, unsigned int id)
|
2012-11-12 06:41:30 -08:00
|
|
|
{
|
|
|
|
Wayland_Input *wi;
|
|
|
|
struct wl_resource *res;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(wi = resource->data)) return;
|
|
|
|
if (!wi->seat.pointer) return;
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
res = wl_client_add_object(client, &wl_pointer_interface,
|
2012-11-12 06:41:30 -08:00
|
|
|
&_wl_pointer_interface, id, wi);
|
|
|
|
wl_list_insert(&wi->seat.pointer->resource_list, &res->link);
|
2013-01-09 03:34:07 -08:00
|
|
|
res->destroy = _e_comp_wl_input_unbind;
|
2012-11-12 06:41:30 -08:00
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
if ((wi->seat.pointer->focus) &&
|
2012-11-12 06:41:30 -08:00
|
|
|
(wi->seat.pointer->focus->resource.client == client))
|
|
|
|
{
|
|
|
|
/* TODO: surface_from_global_fixed ?? */
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
wl_pointer_set_focus(wi->seat.pointer, wi->seat.pointer->focus,
|
|
|
|
wi->seat.pointer->x,
|
2012-11-12 06:41:30 -08:00
|
|
|
wi->seat.pointer->y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
static void
|
2013-01-09 03:34:07 -08:00
|
|
|
_e_comp_wl_input_keyboard_get(struct wl_client *client, struct wl_resource *resource, unsigned int id)
|
2012-01-22 08:32:39 -08:00
|
|
|
{
|
2012-01-26 10:21:54 -08:00
|
|
|
Wayland_Input *wi;
|
2012-11-12 06:41:30 -08:00
|
|
|
struct wl_resource *res;
|
2012-01-22 08:32:39 -08:00
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-11-12 06:41:30 -08:00
|
|
|
if (!(wi = resource->data)) return;
|
|
|
|
if (!wi->seat.keyboard) return;
|
|
|
|
|
|
|
|
res = wl_client_add_object(client, &wl_keyboard_interface, NULL, id, wi);
|
|
|
|
wl_list_insert(&wi->seat.keyboard->resource_list, &res->link);
|
2013-01-09 03:34:07 -08:00
|
|
|
res->destroy = _e_comp_wl_input_unbind;
|
2012-11-12 06:41:30 -08:00
|
|
|
|
|
|
|
/* TODO: wl_keyboard_send_keymap ?? */
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
if ((wi->seat.keyboard->focus) &&
|
2012-11-12 06:41:30 -08:00
|
|
|
(wi->seat.keyboard->focus->resource.client == client))
|
|
|
|
{
|
|
|
|
wl_keyboard_set_focus(wi->seat.keyboard, wi->seat.keyboard->focus);
|
|
|
|
}
|
2012-01-22 08:32:39 -08:00
|
|
|
}
|
2012-06-28 00:03:44 -07:00
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
static void
|
2013-01-09 03:34:07 -08:00
|
|
|
_e_comp_wl_input_touch_get(struct wl_client *client, struct wl_resource *resource, unsigned int id)
|
2012-11-12 06:41:30 -08:00
|
|
|
{
|
|
|
|
Wayland_Input *wi;
|
|
|
|
struct wl_resource *res;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(wi = resource->data)) return;
|
|
|
|
if (!wi->seat.touch) return;
|
|
|
|
|
|
|
|
res = wl_client_add_object(client, &wl_touch_interface, NULL, id, wi);
|
|
|
|
wl_list_insert(&wi->seat.touch->resource_list, &res->link);
|
2013-01-09 03:34:07 -08:00
|
|
|
res->destroy = _e_comp_wl_input_unbind;
|
2012-11-12 06:41:30 -08:00
|
|
|
}
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
static void
|
2013-01-09 03:34:07 -08:00
|
|
|
_e_comp_wl_input_pointer_cursor_set(struct wl_client *client, struct wl_resource *resource, unsigned int serial, struct wl_resource *surface_resource, int x, int y)
|
2012-11-12 06:41:30 -08:00
|
|
|
{
|
|
|
|
/* Wayland_Input *wi; */
|
|
|
|
/* Wayland_Surface *ws; */
|
|
|
|
|
|
|
|
/* if (!(wi = resource->data)) return; */
|
|
|
|
/* if (!wi->seat.pointer->focus) return; */
|
|
|
|
/* if (wi->seat.pointer->focus->resource.client != client) return; */
|
|
|
|
|
|
|
|
/* if (surface_resource) ws = surface_resource->data; */
|
|
|
|
|
|
|
|
/* if ((ws) && (ws != wi->sprite)) */
|
|
|
|
/* { */
|
|
|
|
/* if (ws->configure) */
|
|
|
|
/* { */
|
|
|
|
/* wl_resource_post_error(&ws->surface.resource, */
|
|
|
|
/* WL_DISPLAY_ERROR_INVALID_OBJECT, */
|
|
|
|
/* "Surface configure already set"); */
|
|
|
|
/* return; */
|
|
|
|
/* } */
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
/* TODO: Unmap sprite ? */
|
|
|
|
|
|
|
|
/* if (!ws) return; */
|
|
|
|
|
|
|
|
/* wl_signal_add(&ws->surface.resource.destroy_signal, */
|
|
|
|
/* &wi->sprite_destroy_listener); */
|
|
|
|
|
|
|
|
/* ws->configure = ; */
|
|
|
|
/* ws->private = seat; */
|
|
|
|
/* wi->sprite = ws; */
|
|
|
|
/* wi->hotspot_x = x; */
|
|
|
|
/* wi->hotspot_y = y; */
|
|
|
|
|
|
|
|
/* if (ws->buffer) */
|
|
|
|
/* { */
|
2013-01-11 02:34:29 -08:00
|
|
|
/* TODO: cursor surface configure */
|
|
|
|
/* } */
|
2012-11-12 06:41:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static void */
|
2013-01-09 03:34:07 -08:00
|
|
|
/* _e_comp_wl_input_attach(struct wl_client *client, struct wl_resource *resource, uint32_t serial, struct wl_resource *buffer_resource __UNUSED__, int32_t x, int32_t y) */
|
2012-11-12 06:41:30 -08:00
|
|
|
/* { */
|
|
|
|
/* Wayland_Input *wi; */
|
|
|
|
|
|
|
|
/* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
|
|
|
|
|
|
|
|
/* wi = resource->data; */
|
|
|
|
/* if (serial < wi->input_device.pointer_focus_serial) return; */
|
|
|
|
/* if (!wi->input_device.pointer_focus) return; */
|
|
|
|
/* if (wi->input_device.pointer_focus->resource.client != client) return; */
|
|
|
|
/* wi->hotspot_x = x; */
|
|
|
|
/* wi->hotspot_y = y; */
|
|
|
|
/* } */
|
|
|
|
|