return EINA_TRUE;
}
+EINTERN Eina_Bool
+e_comp_wl_mouse_relative_motion_send(E_Client *ec,
+ int dx, int dy, int dx_unaccel, int dy_unaccel,
+ uint64_t time)
+{
+ struct wl_client *wc;
+ struct wl_resource *res;
+ Eina_List *l;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data->surface, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
+
+ E_Client *focused = e_client_focused_get();
+ if ((focused) && (ec != focused)) return EINA_FALSE;
+
+ e_comp_wl->relative_ptr.ec = ec;
+ e_comp_wl->relative_ptr.activated = EINA_TRUE;
+
+ wc = wl_resource_get_client(ec->comp_data->surface);
+
+ EINA_LIST_FOREACH(e_comp_wl->relative_ptr.resources, l, res)
+ {
+ if (!e_comp_wl_input_relative_pointer_check(res)) continue;
+ if (wl_resource_get_client(res) != wc) continue;
+ zwp_relative_pointer_v1_send_relative_motion(res,
+ (uint32_t)(time >> 32),
+ (uint32_t)(time),
+ wl_fixed_from_int(dx),
+ wl_fixed_from_int(dy),
+ wl_fixed_from_int(dx_unaccel),
+ wl_fixed_from_int(dy_unaccel));
+ }
+
+ return EINA_TRUE;
+}
+
EINTERN Eina_Bool
e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time)
{
# include <xkbcommon/xkbcommon.h>
+# include <relative-pointer-unstable-v1-server-protocol.h>
+
# ifdef __linux__
# include <linux/input.h>
# else
unsigned int num_devices;
} ptr;
+ struct
+ {
+ Eina_List *resources;
+ Eina_List *manager_resources;
+ E_Client *ec;
+ Eina_Bool activated : 1;
+ struct wl_global *global;
+ } relative_ptr;
+
struct
{
Eina_List *resources;
EINTERN Eina_Bool e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev, uint32_t time);
EINTERN Eina_Bool e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t time);
EINTERN Eina_Bool e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time);
+EINTERN Eina_Bool e_comp_wl_mouse_relative_motion_send(E_Client *ec, int dx, int dy, int dx_unaccel, int dy_unaccel, uint64_t time);
EINTERN void e_comp_wl_mouse_in_renew(E_Client *ec, int buttons, int x, int y, void *data, Evas_Modifier *modifiers, Evas_Lock *locks, unsigned int timestamp, Evas_Event_Flags event_flags, Evas_Device *dev, Evas_Object *event_src);
EINTERN void e_comp_wl_mouse_out_renew(E_Client *ec, int buttons, int x, int y, void *data, Evas_Modifier *modifiers, Evas_Lock *locks, unsigned int timestamp, Evas_Event_Flags event_flags, Evas_Device *dev, Evas_Object *event_src);
EINTERN Eina_Bool e_comp_wl_key_process(Ecore_Event_Key *ev, int type);
wl_seat_send_name(res, e_comp_wl->seat.name);
}
+static void
+_e_comp_wl_input_cb_relative_pointer_destroy(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ wl_resource_destroy(resource);
+}
+
+static const struct zwp_relative_pointer_v1_interface _e_relative_pointer_interface = {
+ _e_comp_wl_input_cb_relative_pointer_destroy
+};
+
+static void
+_e_comp_wl_input_cb_relative_pointer_manager_destroy(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ wl_resource_destroy(resource);
+}
+
+static void
+_e_comp_wl_input_cb_unbind_relative_pointer(struct wl_resource *resource)
+{
+ e_comp_wl->relative_ptr.resources =
+ eina_list_remove(e_comp_wl->relative_ptr.resources, resource);
+}
+
+static void
+_e_comp_wl_input_cb_relative_pointer_manager_get_relative_pointer(struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t id,
+ struct wl_resource *pointer_resource)
+{
+ struct wl_resource *res = NULL;
+
+ res = wl_resource_create(client, &zwp_relative_pointer_v1_interface, 1, id);
+
+ if (!res)
+ {
+ ERR("Could not create the resource for relative pointer: %m");
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ e_comp_wl->relative_ptr.resources =
+ eina_list_append(e_comp_wl->relative_ptr.resources, res);
+
+ /* FIXME: must consider destroying relative pointer together
+ when the wl_pointer is destroyed */
+ (void) pointer_resource;
+ wl_resource_set_implementation(res, &_e_relative_pointer_interface,
+ NULL, _e_comp_wl_input_cb_unbind_relative_pointer);
+}
+
+static const struct zwp_relative_pointer_manager_v1_interface _e_relative_pointer_manager_interface = {
+ _e_comp_wl_input_cb_relative_pointer_manager_destroy,
+ _e_comp_wl_input_cb_relative_pointer_manager_get_relative_pointer,
+};
+
+static void
+_e_comp_wl_input_cb_unbind_relative_pointer_manager(struct wl_resource *resource)
+{
+ e_comp_wl->relative_ptr.manager_resources =
+ eina_list_remove(e_comp_wl->relative_ptr.manager_resources, resource);
+}
+
+static void
+_e_comp_wl_input_cb_bind_relative_pointer_manager(struct wl_client *client,
+ void *data EINA_UNUSED,
+ uint32_t version,
+ uint32_t id)
+{
+ struct wl_resource *resource = NULL;
+
+ resource = wl_resource_create(client, &zwp_relative_pointer_manager_v1_interface, 1, id);
+
+ if (!resource)
+ {
+ ERR("Could not create resource for relative pointer manager: %m");
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ e_comp_wl->relative_ptr.manager_resources =
+ eina_list_append(e_comp_wl->relative_ptr.manager_resources, resource);
+ wl_resource_set_implementation(resource, &_e_relative_pointer_manager_interface,
+ NULL, _e_comp_wl_input_cb_unbind_relative_pointer_manager);
+}
+
static void
_e_comp_wl_input_keymap_cache_create(const char *keymap_path, char *keymap_data)
{
return EINA_FALSE;
}
+ /* create the global resource for relative pointer */
+ e_comp_wl->relative_ptr.global =
+ wl_global_create(e_comp_wl->wl.disp,
+ &zwp_relative_pointer_manager_v1_interface, 1,
+ e_comp->wl_comp_data,
+ _e_comp_wl_input_cb_bind_relative_pointer_manager);
+ if (!e_comp_wl->relative_ptr.global)
+ {
+ ERR("Could not create global for relative pointer: %m");
+ return EINA_FALSE;
+ }
+
wl_array_init(&e_comp_wl->kbd.keys);
wl_array_init(&e_comp_wl->kbd.routed_keys);
EINA_LIST_FREE(e_comp_wl->ptr.resources, res)
wl_resource_destroy(res);
+ /* destroy relative pointer resources */
+ EINA_LIST_FREE(e_comp_wl->relative_ptr.resources, res)
+ wl_resource_destroy(res);
+
+ /* destroy relative pointer manager resources */
+ EINA_LIST_FREE(e_comp_wl->relative_ptr.manager_resources, res)
+ wl_resource_destroy(res);
+
/* destroy keyboard resources */
EINA_LIST_FREE(e_comp_wl->kbd.resources, res)
wl_resource_destroy(res);
if (e_comp_wl->xkb.context)
xkb_context_unref(e_comp_wl->xkb.context);
+ /* destroy the global relative pointer resource */
+ if (e_comp_wl->relative_ptr.global)
+ wl_global_destroy(e_comp_wl->relative_ptr.global);
+ e_comp_wl->relative_ptr.global = NULL;
+
/* destroy the global seat resource */
if (e_comp_wl->seat.global)
wl_global_destroy(e_comp_wl->seat.global);
&_e_pointer_interface);
}
+EINTERN Eina_Bool
+e_comp_wl_input_relative_pointer_check(struct wl_resource *res)
+{
+ return wl_resource_instance_of(res, &zwp_relative_pointer_v1_interface,
+ &_e_relative_pointer_interface);
+}
+
EINTERN Eina_Bool
e_comp_wl_input_keyboard_check(struct wl_resource *res)
{