2 #include "e_mod_main.h"
3 #ifdef HAVE_WAYLAND_CLIENTS
4 # include "e_mod_comp_wl.h"
5 # include "e_mod_comp_wl_input.h"
8 /* local function prototypes */
9 static void _e_mod_comp_wl_input_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id);
10 static void _e_mod_comp_wl_input_unbind(struct wl_resource *resource);
11 static void _e_mod_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);
13 /* wayland interfaces */
14 static const struct wl_input_device_interface _wl_input_interface =
16 _e_mod_comp_wl_input_attach,
19 /* private variables */
20 static Wayland_Input *_wl_input;
23 e_mod_comp_wl_input_init(void)
25 LOGFN(__FILE__, __LINE__, __FUNCTION__);
27 if (!(_wl_input = malloc(sizeof(Wayland_Input))))
29 EINA_LOG_ERR("Could not allocate space for input\n");
33 memset(_wl_input, 0, sizeof(*_wl_input));
35 wl_input_device_init(&_wl_input->input_device);
36 if (!wl_display_add_global(_wl_disp, &wl_input_device_interface, _wl_input,
37 _e_mod_comp_wl_input_bind))
39 EINA_LOG_ERR("Failed to add input to wayland\n");
44 _wl_input->hotspot_x = 16;
45 _wl_input->hotspot_y = 16;
51 e_mod_comp_wl_input_shutdown(void)
53 LOGFN(__FILE__, __LINE__, __FUNCTION__);
55 if (!_wl_input) return;
56 wl_input_device_release(&_wl_input->input_device);
61 e_mod_comp_wl_input_get(void)
68 _e_mod_comp_wl_input_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id)
70 struct wl_input_device *device;
71 struct wl_resource *resource;
73 LOGFN(__FILE__, __LINE__, __FUNCTION__);
77 wl_client_add_object(client, &wl_input_device_interface,
78 &_wl_input_interface, id, data);
79 wl_list_insert(&device->resource_list, &resource->link);
80 resource->destroy = _e_mod_comp_wl_input_unbind;
84 _e_mod_comp_wl_input_unbind(struct wl_resource *resource)
86 LOGFN(__FILE__, __LINE__, __FUNCTION__);
88 wl_list_remove(&resource->link);
93 _e_mod_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)
97 LOGFN(__FILE__, __LINE__, __FUNCTION__);
100 if (serial < wi->input_device.pointer_focus_serial) return;
101 if (!wi->input_device.pointer_focus) return;
102 if (wi->input_device.pointer_focus->resource.client != client) return;