2015-02-13 12:48:00 -08:00
|
|
|
#define EXECUTIVE_MODE_ENABLED
|
2014-08-04 09:58:49 -07:00
|
|
|
#define E_COMP_WL
|
2014-05-09 02:28:47 -07:00
|
|
|
#include "e.h"
|
|
|
|
#include <sys/mman.h>
|
2016-01-05 10:07:27 -08:00
|
|
|
#ifdef HAVE_WL_DRM
|
2017-08-10 11:28:15 -07:00
|
|
|
#include <Ecore_Drm2.h>
|
2016-01-05 10:07:27 -08:00
|
|
|
#endif
|
2018-01-23 13:51:58 -08:00
|
|
|
#include <Efl_Wl.h>
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-09-28 12:51:51 -07:00
|
|
|
E_API int E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = -1;
|
2016-01-20 09:38:22 -08:00
|
|
|
static xkb_keycode_t (*_xkb_keymap_key_by_name)(void *, const char *);
|
2016-03-23 01:38:34 -07:00
|
|
|
static void _e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, struct xkb_context *context);
|
|
|
|
|
2017-02-24 11:15:42 -08:00
|
|
|
static Eina_Hash *input_gen_modifiers;
|
2016-03-23 01:38:34 -07:00
|
|
|
|
|
|
|
//the following two fields are just set by e_comp_wl_input_keymap_set if it is called before e_comp_wl is valid.
|
|
|
|
//when then later init is called those two fields are used in the keymap of the e_comp_wl struct
|
|
|
|
static struct xkb_context *cached_context;
|
|
|
|
static struct xkb_keymap *cached_keymap;
|
2016-06-30 11:19:33 -07:00
|
|
|
static xkb_layout_index_t choosen_group;
|
2015-08-20 11:55:14 -07:00
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_comp_wl_input_update_seat_caps(void)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
struct wl_resource *res;
|
|
|
|
enum wl_seat_capability caps = 0;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->ptr.enabled)
|
2014-05-09 02:28:47 -07:00
|
|
|
caps |= WL_SEAT_CAPABILITY_POINTER;
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->kbd.enabled)
|
2014-05-09 02:28:47 -07:00
|
|
|
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->touch.enabled)
|
2014-05-09 02:28:47 -07:00
|
|
|
caps |= WL_SEAT_CAPABILITY_TOUCH;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
EINA_LIST_FOREACH(e_comp_wl->seat.resources, l, res)
|
2015-10-26 07:24:28 -07:00
|
|
|
wl_seat_send_capabilities(res, caps);
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_cb_resource_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2017-11-03 10:23:26 -07:00
|
|
|
_e_comp_wl_input_pointer_cb_cursor_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial EINA_UNUSED, struct wl_resource *surface_resource, int32_t x, int32_t y)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
2015-02-06 15:28:11 -08:00
|
|
|
E_Client *ec;
|
2017-11-03 10:23:26 -07:00
|
|
|
E_Comp_Wl_Pointer *ptr = wl_resource_get_user_data(resource);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-02-10 16:15:53 -08:00
|
|
|
if (!surface_resource)
|
|
|
|
{
|
2017-11-03 10:23:26 -07:00
|
|
|
ptr->cursor_set = 1;
|
|
|
|
ptr->cursor = NULL;
|
|
|
|
ptr->offset.x = x;
|
|
|
|
ptr->offset.y = y;
|
|
|
|
if (ptr->entered)
|
2017-03-22 13:15:15 -07:00
|
|
|
{
|
|
|
|
ecore_evas_cursor_unset(e_comp->ee);
|
|
|
|
evas_object_hide(e_comp->pointer->o_ptr);
|
|
|
|
}
|
2015-02-10 16:15:53 -08:00
|
|
|
return;
|
|
|
|
}
|
2015-04-21 12:19:20 -07:00
|
|
|
ec = wl_resource_get_user_data(surface_resource);
|
2017-09-08 12:38:08 -07:00
|
|
|
/* I think this only happens when we've deleted the resource from
|
|
|
|
* the client del callback - so the client is gone and shouldn't be
|
|
|
|
* setting a cursor, but the surface still exists so stale requests
|
|
|
|
* are being processed... let's BAIL.
|
|
|
|
*/
|
|
|
|
if (!ec) return;
|
2017-11-03 10:23:26 -07:00
|
|
|
ptr->cursor_set = 1;
|
|
|
|
ptr->cursor = ec;
|
|
|
|
ptr->offset.x = x;
|
|
|
|
ptr->offset.y = y;
|
2017-10-18 08:41:04 -07:00
|
|
|
if (ec->comp_data->pending.input)
|
|
|
|
eina_tiler_clear(ec->comp_data->pending.input);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ec->comp_data->pending.input = eina_tiler_new(65535, 65535);
|
|
|
|
eina_tiler_tile_size_set(ec->comp_data->pending.input, 1, 1);
|
|
|
|
}
|
2015-03-30 09:13:04 -07:00
|
|
|
if (!ec->re_manage)
|
2015-02-06 15:28:11 -08:00
|
|
|
{
|
2016-01-20 12:55:10 -08:00
|
|
|
ec->comp_data->cursor = ec->re_manage = 1;
|
2015-03-30 09:13:04 -07:00
|
|
|
ec->ignored = 0;
|
2016-12-02 07:51:01 -08:00
|
|
|
evas_object_layer_set(ec->frame, E_LAYER_CLIENT_PRIO);
|
2015-02-13 12:48:00 -08:00
|
|
|
|
2015-02-13 12:11:43 -08:00
|
|
|
ec->lock_focus_out = ec->layer_block = ec->visible = ec->override = 1;
|
2015-02-06 15:28:11 -08:00
|
|
|
ec->icccm.title = eina_stringshare_add("noshadow");
|
|
|
|
evas_object_pass_events_set(ec->frame, 1);
|
2016-01-20 12:55:10 -08:00
|
|
|
evas_object_show(ec->frame);
|
2016-01-20 13:23:02 -08:00
|
|
|
if (e_comp_object_damage_exists(ec->frame))
|
|
|
|
e_comp_object_render_update_add(ec->frame);
|
2016-01-20 12:55:10 -08:00
|
|
|
ec->comp_data->mapped = 1;
|
2015-03-30 09:13:04 -07:00
|
|
|
e_client_focus_stack_set(eina_list_remove(e_client_focus_stack_get(), ec));
|
|
|
|
EC_CHANGED(ec);
|
2015-02-06 15:28:11 -08:00
|
|
|
}
|
2015-03-30 09:13:04 -07:00
|
|
|
|
2017-11-03 10:23:26 -07:00
|
|
|
if (ptr->entered)
|
|
|
|
e_comp_wl_input_pointer_cursor_update(ptr);
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static const struct wl_pointer_interface _e_pointer_interface =
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
_e_comp_wl_input_pointer_cb_cursor_set,
|
|
|
|
_e_comp_wl_input_cb_resource_destroy
|
|
|
|
};
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static const struct wl_keyboard_interface _e_keyboard_interface =
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
_e_comp_wl_input_cb_resource_destroy
|
|
|
|
};
|
|
|
|
|
2015-05-13 09:05:57 -07:00
|
|
|
static const struct wl_touch_interface _e_touch_interface =
|
|
|
|
{
|
|
|
|
_e_comp_wl_input_cb_resource_destroy
|
|
|
|
};
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_cb_pointer_unbind(struct wl_resource *resource)
|
|
|
|
{
|
2017-11-03 10:23:26 -07:00
|
|
|
E_Comp_Wl_Pointer *ptr = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
if (ptr->cursor_set && ptr->entered)
|
|
|
|
e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->ptr.resources =
|
|
|
|
eina_list_remove(e_comp_wl->ptr.resources, resource);
|
2017-11-03 10:23:26 -07:00
|
|
|
free(ptr);
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_cb_pointer_get(struct wl_client *client, struct wl_resource *resource, uint32_t id)
|
|
|
|
{
|
|
|
|
struct wl_resource *res;
|
2017-11-03 10:23:26 -07:00
|
|
|
E_Comp_Wl_Pointer *ptr;
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* try to create pointer resource */
|
2015-03-13 17:04:16 -07:00
|
|
|
res = wl_resource_create(client, &wl_pointer_interface,
|
2014-05-09 02:28:47 -07:00
|
|
|
wl_resource_get_version(resource), id);
|
|
|
|
if (!res)
|
|
|
|
{
|
2016-01-14 09:41:47 -08:00
|
|
|
ERR("Could not create pointer on seat %s",
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->seat.name);
|
2014-05-09 02:28:47 -07:00
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
2017-11-03 10:23:26 -07:00
|
|
|
ptr = E_NEW(E_Comp_Wl_Pointer, 1);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->ptr.resources =
|
|
|
|
eina_list_append(e_comp_wl->ptr.resources, res);
|
2015-07-01 10:18:55 -07:00
|
|
|
wl_resource_set_implementation(res, &_e_pointer_interface,
|
2017-11-03 10:23:26 -07:00
|
|
|
ptr,
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_cb_pointer_unbind);
|
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_cb_keyboard_unbind(struct wl_resource *resource)
|
|
|
|
{
|
2015-07-22 14:38:40 -07:00
|
|
|
Eina_List *l, *ll;
|
|
|
|
struct wl_resource *res;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.resources =
|
|
|
|
eina_list_remove(e_comp_wl->kbd.resources, resource);
|
|
|
|
EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
|
2015-10-26 07:24:28 -07:00
|
|
|
{
|
|
|
|
if (res == resource)
|
|
|
|
{
|
|
|
|
e_comp_wl->kbd.focused =
|
|
|
|
eina_list_remove_list(e_comp_wl->kbd.focused, l);
|
|
|
|
}
|
|
|
|
}
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-03-20 12:21:39 -07:00
|
|
|
void
|
|
|
|
e_comp_wl_input_keyboard_enter_send(E_Client *ec)
|
|
|
|
{
|
|
|
|
struct wl_resource *res;
|
|
|
|
Eina_List *l;
|
|
|
|
uint32_t serial;
|
|
|
|
|
|
|
|
if (!ec->comp_data->surface) return;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
if (!e_comp_wl->kbd.focused) return;
|
2015-03-20 12:21:39 -07:00
|
|
|
|
2015-05-18 06:08:52 -07:00
|
|
|
e_comp_wl_input_keyboard_modifiers_serialize();
|
2015-03-20 12:21:39 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
serial = wl_display_next_serial(e_comp_wl->wl.disp);
|
2015-03-20 12:21:39 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
|
2015-03-20 12:21:39 -07:00
|
|
|
{
|
|
|
|
wl_keyboard_send_enter(res, serial, ec->comp_data->surface,
|
2015-08-13 13:05:57 -07:00
|
|
|
&e_comp_wl->kbd.keys);
|
2015-03-20 12:21:39 -07:00
|
|
|
wl_keyboard_send_modifiers(res, serial,
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.mod_depressed,
|
|
|
|
e_comp_wl->kbd.mod_latched,
|
|
|
|
e_comp_wl->kbd.mod_locked,
|
|
|
|
e_comp_wl->kbd.mod_group);
|
2015-03-20 12:21:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *resource, uint32_t id)
|
|
|
|
{
|
2015-03-20 12:21:39 -07:00
|
|
|
E_Client *focused;
|
2014-05-09 02:28:47 -07:00
|
|
|
struct wl_resource *res;
|
|
|
|
|
|
|
|
/* try to create keyboard resource */
|
2015-03-13 17:04:16 -07:00
|
|
|
res = wl_resource_create(client, &wl_keyboard_interface,
|
2014-05-09 02:28:47 -07:00
|
|
|
wl_resource_get_version(resource), id);
|
|
|
|
if (!res)
|
|
|
|
{
|
2016-01-14 09:41:47 -08:00
|
|
|
ERR("Could not create keyboard on seat %s", e_comp_wl->seat.name);
|
2014-05-09 02:28:47 -07:00
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
2017-02-03 12:13:48 -08:00
|
|
|
wl_resource_set_user_data(res, resource);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.resources =
|
|
|
|
eina_list_append(e_comp_wl->kbd.resources, res);
|
2015-07-01 10:18:55 -07:00
|
|
|
wl_resource_set_implementation(res, &_e_keyboard_interface,
|
|
|
|
e_comp->wl_comp_data,
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_cb_keyboard_unbind);
|
|
|
|
|
(1) e_config.c/e_comp_wl.c: add code for making repeat values configurable
(2) e.src(s): add keyboard.repeat_delay, keyboard.repeat_rate into e.src files
Summary:
As of now, the default values of repeat delay/rate are being set in e_comp_wl.c.
Those values need to be configurable and will be used in e_comp_wl_init().
The limit of each of the values is defined from -1 to 1000. (maximum 1s).
If one of the two is negative, it means default repeat delay/rate are going to be used.
(e.g. delay:400, rate:25)
Test Plan:
N/A
Signed-off-by: Sung-Jin Park <input.hacker@gmail.com>
Reviewers: raster, stefan_schmidt, gwanglim, devilhorns, zmike
Subscribers: Jeon, ohduna, cedric
Differential Revision: https://phab.enlightenment.org/D3364
2015-11-30 11:05:10 -08:00
|
|
|
/* send current repeat_info */
|
2015-07-14 08:58:24 -07:00
|
|
|
if (wl_resource_get_version(res) >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
|
2015-11-30 11:12:27 -08:00
|
|
|
wl_keyboard_send_repeat_info(res, e_config->keyboard.repeat_rate, e_config->keyboard.repeat_delay);
|
2015-07-14 08:58:24 -07:00
|
|
|
|
2014-05-09 02:28:47 -07:00
|
|
|
/* send current keymap */
|
2015-03-13 17:04:16 -07:00
|
|
|
wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
|
2015-10-26 07:24:28 -07:00
|
|
|
e_comp_wl->xkb.fd, e_comp_wl->xkb.size);
|
2015-03-20 12:21:39 -07:00
|
|
|
|
|
|
|
/* if the client owns the focused surface, we need to send an enter */
|
|
|
|
focused = e_client_focused_get();
|
2015-07-01 10:18:55 -07:00
|
|
|
if (!focused) return;
|
2015-03-20 12:21:39 -07:00
|
|
|
|
2015-10-21 11:05:02 -07:00
|
|
|
if (client != wl_resource_get_client(focused->comp_data->surface)) return;
|
|
|
|
e_comp_wl->kbd.focused = eina_list_append(e_comp_wl->kbd.focused, res);
|
|
|
|
|
2015-03-20 12:21:39 -07:00
|
|
|
e_comp_wl_input_keyboard_enter_send(focused);
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2015-05-13 09:05:57 -07:00
|
|
|
_e_comp_wl_input_cb_touch_unbind(struct wl_resource *resource)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->touch.resources =
|
|
|
|
eina_list_remove(e_comp_wl->touch.resources, resource);
|
2015-05-13 09:05:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_comp_wl_input_cb_touch_get(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t id EINA_UNUSED)
|
|
|
|
{
|
2015-10-26 07:24:28 -07:00
|
|
|
struct wl_resource *res;
|
2015-05-13 09:05:57 -07:00
|
|
|
|
|
|
|
/* try to create pointer resource */
|
2015-10-26 07:24:28 -07:00
|
|
|
res = wl_resource_create(client, &wl_touch_interface,
|
|
|
|
wl_resource_get_version(resource), id);
|
|
|
|
if (!res)
|
|
|
|
{
|
2016-01-14 09:41:47 -08:00
|
|
|
ERR("Could not create touch on seat %s",
|
2015-10-26 07:24:28 -07:00
|
|
|
e_comp_wl->seat.name);
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
e_comp_wl->touch.resources =
|
2015-08-13 13:05:57 -07:00
|
|
|
eina_list_append(e_comp_wl->touch.resources, res);
|
2015-10-26 07:24:28 -07:00
|
|
|
wl_resource_set_implementation(res, &_e_touch_interface,
|
|
|
|
e_comp->wl_comp_data,
|
2015-05-13 09:05:57 -07:00
|
|
|
_e_comp_wl_input_cb_touch_unbind);
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2016-03-01 07:45:21 -08:00
|
|
|
static void
|
2016-03-16 05:40:41 -07:00
|
|
|
_e_comp_wl_input_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
|
2016-03-01 07:45:21 -08:00
|
|
|
{
|
2016-03-16 05:40:41 -07:00
|
|
|
wl_resource_destroy(resource);
|
2016-03-01 07:45:21 -08:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static const struct wl_seat_interface _e_seat_interface =
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
_e_comp_wl_input_cb_pointer_get,
|
|
|
|
_e_comp_wl_input_cb_keyboard_get,
|
|
|
|
_e_comp_wl_input_cb_touch_get,
|
2016-03-01 07:45:21 -08:00
|
|
|
_e_comp_wl_input_cb_release,
|
2014-05-09 02:28:47 -07:00
|
|
|
};
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_cb_unbind_seat(struct wl_resource *resource)
|
|
|
|
{
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->seat.resources =
|
|
|
|
eina_list_remove(e_comp_wl->seat.resources, resource);
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_comp_wl_input_cb_bind_seat(struct wl_client *client, void *data EINA_UNUSED, uint32_t version, uint32_t id)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
struct wl_resource *res;
|
|
|
|
|
2015-11-26 17:12:47 -08:00
|
|
|
res = wl_resource_create(client, &wl_seat_interface, version, id);
|
2015-03-13 17:04:16 -07:00
|
|
|
if (!res)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
2016-01-14 09:41:47 -08:00
|
|
|
ERR("Could not create seat resource");
|
2014-05-09 02:28:47 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* store version of seat interface for reuse in updating capabilities */
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->seat.version = version;
|
|
|
|
e_comp_wl->seat.resources =
|
|
|
|
eina_list_append(e_comp_wl->seat.resources, res);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-07-01 10:18:55 -07:00
|
|
|
wl_resource_set_implementation(res, &_e_seat_interface,
|
|
|
|
e_comp->wl_comp_data,
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_cb_unbind_seat);
|
|
|
|
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_comp_wl_input_update_seat_caps();
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->seat.version >= WL_SEAT_NAME_SINCE_VERSION)
|
|
|
|
wl_seat_send_name(res, e_comp_wl->seat.name);
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static int
|
2014-05-09 02:28:47 -07:00
|
|
|
_e_comp_wl_input_keymap_fd_get(off_t size)
|
|
|
|
{
|
|
|
|
int fd = 0, blen = 0, len = 0;
|
|
|
|
const char *path;
|
|
|
|
char tmp[PATH_MAX];
|
|
|
|
long flags;
|
|
|
|
|
|
|
|
blen = sizeof(tmp) - 1;
|
|
|
|
|
|
|
|
if (!(path = getenv("XDG_RUNTIME_DIR")))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
len = strlen(path);
|
|
|
|
if (len < blen)
|
|
|
|
{
|
|
|
|
strcpy(tmp, path);
|
|
|
|
strcat(tmp, "/e-wl-keymap-XXXXXX");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if ((fd = mkstemp(tmp)) < 0) return -1;
|
|
|
|
|
|
|
|
flags = fcntl(fd, F_GETFD);
|
2015-02-02 09:00:38 -08:00
|
|
|
if (flags < 0)
|
|
|
|
{
|
|
|
|
close(fd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fcntl(fd, F_SETFD, (flags | FD_CLOEXEC)) == -1)
|
|
|
|
{
|
|
|
|
close(fd);
|
|
|
|
return -1;
|
|
|
|
}
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
if (ftruncate(fd, size) < 0)
|
|
|
|
{
|
|
|
|
close(fd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
unlink(tmp);
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
static void
|
2016-06-30 11:19:33 -07:00
|
|
|
_e_comp_wl_input_state_update(void)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
2016-01-25 13:29:28 -08:00
|
|
|
xkb_mod_mask_t latched = 0, locked = 0;
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* unreference any existing keyboard state */
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->xkb.state)
|
2015-02-03 12:35:19 -08:00
|
|
|
{
|
2015-03-13 17:04:16 -07:00
|
|
|
latched =
|
2015-08-13 13:05:57 -07:00
|
|
|
xkb_state_serialize_mods(e_comp_wl->xkb.state,
|
2015-07-01 10:18:55 -07:00
|
|
|
XKB_STATE_MODS_LATCHED);
|
2015-03-13 17:04:16 -07:00
|
|
|
locked =
|
2015-08-13 13:05:57 -07:00
|
|
|
xkb_state_serialize_mods(e_comp_wl->xkb.state,
|
2015-07-01 10:18:55 -07:00
|
|
|
XKB_STATE_MODS_LOCKED);
|
2015-08-13 13:05:57 -07:00
|
|
|
xkb_state_unref(e_comp_wl->xkb.state);
|
2015-02-03 12:35:19 -08:00
|
|
|
}
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* create a new xkb state */
|
2016-06-30 11:19:33 -07:00
|
|
|
e_comp_wl->xkb.state = xkb_state_new(e_comp_wl->xkb.keymap);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2016-01-25 13:29:28 -08:00
|
|
|
xkb_state_update_mask(e_comp_wl->xkb.state, 0,
|
2017-01-17 05:43:21 -08:00
|
|
|
latched, locked, e_comp_wl->kbd.choosen_group,
|
|
|
|
0, 0);
|
2016-06-30 11:19:33 -07:00
|
|
|
}
|
|
|
|
|
2018-01-23 13:51:58 -08:00
|
|
|
static void
|
|
|
|
nested_keymap_update(void)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(e_comp_wl->efl_wls, l, obj)
|
|
|
|
efl_wl_seat_keymap_set(obj, NULL, e_comp_wl->xkb.state, e_comp_wl->xkb.fd, e_comp_wl->xkb.size, &e_comp_wl->kbd.keys);
|
|
|
|
}
|
|
|
|
|
2016-06-30 11:19:33 -07:00
|
|
|
static void
|
|
|
|
_e_comp_wl_input_keymap_update(struct xkb_keymap *keymap)
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
struct wl_resource *res;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
/* unreference any existing keymap */
|
|
|
|
if (e_comp_wl->xkb.keymap)
|
|
|
|
xkb_map_unref(e_comp_wl->xkb.keymap);
|
|
|
|
|
|
|
|
/* unmap any existing keyboard area */
|
|
|
|
if (e_comp_wl->xkb.area)
|
|
|
|
munmap(e_comp_wl->xkb.area, e_comp_wl->xkb.size);
|
|
|
|
if (e_comp_wl->xkb.fd >= 0) close(e_comp_wl->xkb.fd);
|
|
|
|
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* increment keymap reference */
|
2015-10-19 08:43:07 -07:00
|
|
|
e_comp_wl->xkb.keymap = keymap;
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2016-06-30 11:19:33 -07:00
|
|
|
/* update the state */
|
|
|
|
_e_comp_wl_input_state_update();
|
|
|
|
|
2014-05-09 02:28:47 -07:00
|
|
|
if (!(tmp = xkb_map_get_as_string(keymap)))
|
|
|
|
{
|
|
|
|
ERR("Could not get keymap string");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->xkb.size = strlen(tmp) + 1;
|
|
|
|
e_comp_wl->xkb.fd =
|
|
|
|
_e_comp_wl_input_keymap_fd_get(e_comp_wl->xkb.size);
|
|
|
|
if (e_comp_wl->xkb.fd < 0)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
ERR("Could not create keymap file");
|
2015-03-13 17:04:16 -07:00
|
|
|
free(tmp);
|
2014-05-09 02:28:47 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->xkb.area =
|
|
|
|
mmap(NULL, e_comp_wl->xkb.size, (PROT_READ | PROT_WRITE),
|
|
|
|
MAP_SHARED, e_comp_wl->xkb.fd, 0);
|
|
|
|
if (e_comp_wl->xkb.area == MAP_FAILED)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
ERR("Failed to mmap keymap area: %m");
|
2015-03-13 17:04:16 -07:00
|
|
|
free(tmp);
|
2014-05-09 02:28:47 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
strcpy(e_comp_wl->xkb.area, tmp);
|
2014-05-09 02:28:47 -07:00
|
|
|
free(tmp);
|
|
|
|
|
|
|
|
/* send updated keymap */
|
2015-08-13 13:05:57 -07:00
|
|
|
EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
|
2015-03-13 17:04:16 -07:00
|
|
|
wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
|
2015-10-26 07:24:28 -07:00
|
|
|
e_comp_wl->xkb.fd, e_comp_wl->xkb.size);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* update modifiers */
|
2015-05-18 06:08:52 -07:00
|
|
|
e_comp_wl_input_keyboard_modifiers_update();
|
2018-01-23 13:51:58 -08:00
|
|
|
nested_keymap_update();
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
EINTERN Eina_Bool
|
2015-05-18 06:08:52 -07:00
|
|
|
e_comp_wl_input_init(void)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
/* set default seat name */
|
2015-08-13 13:05:57 -07:00
|
|
|
if (!e_comp_wl->seat.name)
|
2017-06-23 14:41:39 -07:00
|
|
|
e_comp_wl->seat.name = "seat0";
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->xkb.fd = -1;
|
2015-02-02 09:00:38 -08:00
|
|
|
|
2014-05-09 02:28:47 -07:00
|
|
|
/* create the global resource for input seat */
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->seat.global =
|
|
|
|
wl_global_create(e_comp_wl->wl.disp, &wl_seat_interface, 4,
|
2015-06-25 16:16:27 -07:00
|
|
|
e_comp->wl_comp_data, _e_comp_wl_input_cb_bind_seat);
|
2015-08-13 13:05:57 -07:00
|
|
|
if (!e_comp_wl->seat.global)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
2016-01-14 09:41:47 -08:00
|
|
|
ERR("Could not create global for seat");
|
2014-05-09 02:28:47 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
wl_array_init(&e_comp_wl->kbd.keys);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-08-20 11:55:14 -07:00
|
|
|
E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = ecore_event_type_new();
|
|
|
|
|
2016-01-20 09:38:22 -08:00
|
|
|
_xkb_keymap_key_by_name = dlsym(NULL, "xkb_keymap_key_by_name");
|
|
|
|
|
2016-04-11 11:53:52 -07:00
|
|
|
if (cached_keymap)
|
|
|
|
_e_comp_wl_input_context_keymap_set(cached_keymap, cached_context);
|
|
|
|
else
|
|
|
|
e_comp_wl_input_keymap_set(NULL, NULL, NULL, NULL, NULL);
|
2016-03-23 01:38:34 -07:00
|
|
|
|
2016-06-30 11:19:33 -07:00
|
|
|
if (choosen_group)
|
|
|
|
e_comp_wl_input_keymap_index_set(choosen_group);
|
|
|
|
else
|
|
|
|
e_comp_wl_input_keymap_index_set(0);
|
|
|
|
|
|
|
|
e_comp_wl_input_keyboard_modifiers_update();
|
|
|
|
|
2014-05-09 02:28:47 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
EINTERN void
|
2015-05-18 06:08:52 -07:00
|
|
|
e_comp_wl_input_shutdown(void)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
struct wl_resource *res;
|
|
|
|
|
2017-02-24 11:15:42 -08:00
|
|
|
E_FREE_FUNC(input_gen_modifiers, eina_hash_free);
|
|
|
|
|
2014-05-09 02:28:47 -07:00
|
|
|
/* destroy pointer resources */
|
2015-08-13 13:05:57 -07:00
|
|
|
EINA_LIST_FREE(e_comp_wl->ptr.resources, res)
|
2014-05-09 02:28:47 -07:00
|
|
|
wl_resource_destroy(res);
|
|
|
|
|
|
|
|
/* destroy keyboard resources */
|
2015-08-13 13:05:57 -07:00
|
|
|
EINA_LIST_FREE(e_comp_wl->kbd.resources, res)
|
2014-05-09 02:28:47 -07:00
|
|
|
wl_resource_destroy(res);
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.resources = eina_list_free(e_comp_wl->kbd.resources);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-01-22 06:15:07 -08:00
|
|
|
/* destroy touch resources */
|
2015-08-13 13:05:57 -07:00
|
|
|
EINA_LIST_FREE(e_comp_wl->touch.resources, res)
|
2015-01-22 06:15:07 -08:00
|
|
|
wl_resource_destroy(res);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
/* destroy e_comp_wl->kbd.keys array */
|
|
|
|
wl_array_release(&e_comp_wl->kbd.keys);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-02-02 09:00:38 -08:00
|
|
|
/* unmap any existing keyboard area */
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->xkb.area)
|
|
|
|
munmap(e_comp_wl->xkb.area, e_comp_wl->xkb.size);
|
|
|
|
if (e_comp_wl->xkb.fd >= 0) close(e_comp_wl->xkb.fd);
|
2015-02-02 09:00:38 -08:00
|
|
|
|
|
|
|
/* unreference any existing keyboard state */
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->xkb.state)
|
|
|
|
xkb_state_unref(e_comp_wl->xkb.state);
|
2015-02-02 09:00:38 -08:00
|
|
|
|
2015-07-01 10:25:20 -07:00
|
|
|
/* unreference any existing keymap */
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->xkb.keymap)
|
|
|
|
xkb_map_unref(e_comp_wl->xkb.keymap);
|
2015-07-01 10:25:20 -07:00
|
|
|
|
2015-02-02 09:00:38 -08:00
|
|
|
/* unreference any existing context */
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->xkb.context)
|
|
|
|
xkb_context_unref(e_comp_wl->xkb.context);
|
2015-02-02 09:00:38 -08:00
|
|
|
|
2014-05-09 02:28:47 -07:00
|
|
|
/* destroy the global seat resource */
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->seat.global)
|
|
|
|
wl_global_destroy(e_comp_wl->seat.global);
|
|
|
|
e_comp_wl->seat.global = NULL;
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:23:26 -07:00
|
|
|
EINTERN void
|
|
|
|
e_comp_wl_input_pointer_cursor_update(E_Comp_Wl_Pointer *ptr)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(!ptr->entered);
|
|
|
|
if (ptr->cursor_set && (!e_comp_util_mouse_grabbed()))
|
|
|
|
{
|
|
|
|
if (ptr->cursor)
|
|
|
|
e_pointer_object_set(e_comp->pointer, ptr->cursor->frame, ptr->offset.x, ptr->offset.y);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ecore_evas_cursor_unset(e_comp->ee);
|
|
|
|
evas_object_hide(e_comp->pointer->o_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_pointer_object_set(e_comp->pointer, NULL, 0, 0);
|
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
EINTERN Eina_Bool
|
2014-05-09 02:28:47 -07:00
|
|
|
e_comp_wl_input_pointer_check(struct wl_resource *res)
|
|
|
|
{
|
2015-03-13 17:04:16 -07:00
|
|
|
return wl_resource_instance_of(res, &wl_pointer_interface,
|
2014-05-09 02:28:47 -07:00
|
|
|
&_e_pointer_interface);
|
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
EINTERN Eina_Bool
|
2014-05-09 02:28:47 -07:00
|
|
|
e_comp_wl_input_keyboard_check(struct wl_resource *res)
|
|
|
|
{
|
2015-03-13 17:04:16 -07:00
|
|
|
return wl_resource_instance_of(res, &wl_keyboard_interface,
|
2014-05-09 02:28:47 -07:00
|
|
|
&_e_keyboard_interface);
|
|
|
|
}
|
|
|
|
|
2015-07-22 14:46:39 -07:00
|
|
|
EINTERN Eina_Bool
|
2015-05-18 06:08:52 -07:00
|
|
|
e_comp_wl_input_keyboard_modifiers_serialize(void)
|
2015-03-09 12:49:08 -07:00
|
|
|
{
|
2015-07-22 14:46:39 -07:00
|
|
|
Eina_Bool changed = EINA_FALSE;
|
|
|
|
xkb_mod_mask_t mod;
|
|
|
|
xkb_layout_index_t grp;
|
|
|
|
|
2015-10-26 07:24:28 -07:00
|
|
|
mod = xkb_state_serialize_mods(e_comp_wl->xkb.state, XKB_STATE_DEPRESSED);
|
2015-08-13 13:05:57 -07:00
|
|
|
changed |= mod != e_comp_wl->kbd.mod_depressed;
|
|
|
|
e_comp_wl->kbd.mod_depressed = mod;
|
2015-07-22 14:46:39 -07:00
|
|
|
|
2015-10-26 07:24:28 -07:00
|
|
|
mod = xkb_state_serialize_mods(e_comp_wl->xkb.state, XKB_STATE_MODS_LATCHED);
|
2015-08-13 13:05:57 -07:00
|
|
|
changed |= mod != e_comp_wl->kbd.mod_latched;
|
|
|
|
e_comp_wl->kbd.mod_latched = mod;
|
2015-07-22 14:46:39 -07:00
|
|
|
|
2015-10-26 07:24:28 -07:00
|
|
|
mod = xkb_state_serialize_mods(e_comp_wl->xkb.state, XKB_STATE_MODS_LOCKED);
|
2015-08-13 13:05:57 -07:00
|
|
|
changed |= mod != e_comp_wl->kbd.mod_locked;
|
|
|
|
e_comp_wl->kbd.mod_locked = mod;
|
2015-07-22 14:46:39 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
grp = xkb_state_serialize_layout(e_comp_wl->xkb.state,
|
2015-10-26 07:24:28 -07:00
|
|
|
XKB_STATE_LAYOUT_EFFECTIVE);
|
2016-01-25 13:31:11 -08:00
|
|
|
if (grp != e_comp_wl->kbd.mod_group)
|
|
|
|
{
|
|
|
|
e_config->xkb.cur_group = grp;
|
|
|
|
ecore_event_add(E_EVENT_XKB_CHANGED, NULL, NULL, NULL);
|
|
|
|
}
|
2015-08-13 13:05:57 -07:00
|
|
|
changed |= grp != e_comp_wl->kbd.mod_group;
|
|
|
|
e_comp_wl->kbd.mod_group = grp;
|
2015-07-22 14:46:39 -07:00
|
|
|
return changed;
|
2015-03-09 12:49:08 -07:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
EINTERN void
|
2015-05-18 06:08:52 -07:00
|
|
|
e_comp_wl_input_keyboard_modifiers_update(void)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
2015-02-03 12:35:19 -08:00
|
|
|
uint32_t serial;
|
|
|
|
struct wl_resource *res;
|
|
|
|
Eina_List *l;
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-07-22 14:46:39 -07:00
|
|
|
if (!e_comp_wl_input_keyboard_modifiers_serialize()) return;
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2016-03-31 08:14:27 -07:00
|
|
|
if ((!e_comp_wl->kbd.focused) || e_comp->input_key_grabs) return;
|
2015-03-10 13:24:45 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
serial = wl_display_next_serial(e_comp_wl->wl.disp);
|
|
|
|
EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
|
2015-03-13 17:04:16 -07:00
|
|
|
wl_keyboard_send_modifiers(res, serial,
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.mod_depressed,
|
|
|
|
e_comp_wl->kbd.mod_latched,
|
|
|
|
e_comp_wl->kbd.mod_locked,
|
|
|
|
e_comp_wl->kbd.mod_group);
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-03-13 17:04:16 -07:00
|
|
|
EINTERN void
|
2015-05-18 06:08:52 -07:00
|
|
|
e_comp_wl_input_keyboard_state_update(uint32_t keycode, Eina_Bool pressed)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
enum xkb_key_direction dir;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
if (!e_comp_wl->xkb.state) return;
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
if (pressed) dir = XKB_KEY_DOWN;
|
|
|
|
else dir = XKB_KEY_UP;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.mod_changed =
|
|
|
|
xkb_state_update_key(e_comp_wl->xkb.state, keycode + 8, dir);
|
2015-07-01 10:18:55 -07:00
|
|
|
|
|
|
|
e_comp_wl_input_keyboard_modifiers_update();
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API void
|
2015-05-13 09:05:57 -07:00
|
|
|
e_comp_wl_input_pointer_enabled_set(Eina_Bool enabled)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
/* check for valid compositor data */
|
2015-05-13 09:05:57 -07:00
|
|
|
if (!e_comp->wl_comp_data)
|
2014-07-29 05:35:28 -07:00
|
|
|
{
|
|
|
|
ERR("No compositor data");
|
|
|
|
return;
|
|
|
|
}
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->ptr.enabled = !!enabled;
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_comp_wl_input_update_seat_caps();
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API void
|
2015-05-13 09:05:57 -07:00
|
|
|
e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
/* check for valid compositor data */
|
2015-05-13 09:05:57 -07:00
|
|
|
if (!e_comp->wl_comp_data)
|
2014-07-29 05:35:28 -07:00
|
|
|
{
|
|
|
|
ERR("No compositor data");
|
|
|
|
return;
|
|
|
|
}
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.enabled = !!enabled;
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_comp_wl_input_update_seat_caps();
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
|
|
|
|
2016-03-23 01:38:34 -07:00
|
|
|
static void
|
|
|
|
_e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, struct xkb_context *context)
|
|
|
|
{
|
|
|
|
if (e_comp_wl)
|
|
|
|
{
|
|
|
|
//we have a initializied and running compositor here
|
|
|
|
if (e_comp_wl->xkb.context)
|
|
|
|
xkb_context_unref(e_comp_wl->xkb.context);
|
|
|
|
e_comp_wl->xkb.context = context;
|
|
|
|
|
|
|
|
/* update compositor keymap */
|
|
|
|
_e_comp_wl_input_keymap_update(keymap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//we dont have a running compositor here, cache the values, init will pick them
|
|
|
|
cached_context = context;
|
|
|
|
cached_keymap = keymap;
|
|
|
|
}
|
|
|
|
|
2017-05-26 13:34:13 -07:00
|
|
|
if (!e_comp->ee) return;
|
2016-03-23 01:38:34 -07:00
|
|
|
//set the values to the drm devices
|
|
|
|
#ifdef HAVE_WL_DRM
|
2017-05-26 13:34:13 -07:00
|
|
|
if (strstr(ecore_evas_engine_name_get(e_comp->ee), "drm"))
|
2016-05-11 07:02:22 -07:00
|
|
|
{
|
|
|
|
Ecore_Drm2_Device *dev;
|
|
|
|
|
|
|
|
dev = ecore_evas_data_get(e_comp->ee, "device");
|
|
|
|
if (dev)
|
2017-05-26 13:34:13 -07:00
|
|
|
ecore_drm2_device_keyboard_info_set(dev, context, keymap,
|
|
|
|
e_comp_wl ? e_comp_wl->kbd.choosen_group : choosen_group);
|
2016-05-11 07:02:22 -07:00
|
|
|
}
|
2016-03-23 01:38:34 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-06-30 11:19:33 -07:00
|
|
|
E_API void
|
|
|
|
e_comp_wl_input_keymap_index_set(xkb_layout_index_t index)
|
|
|
|
{
|
2017-05-26 13:34:13 -07:00
|
|
|
#ifdef HAVE_WL_DRM
|
|
|
|
if (e_comp && e_comp->ee && strstr(ecore_evas_engine_name_get(e_comp->ee), "drm"))
|
|
|
|
{
|
|
|
|
Ecore_Drm2_Device *dev;
|
|
|
|
|
|
|
|
dev = ecore_evas_data_get(e_comp->ee, "device");
|
|
|
|
if (dev)
|
|
|
|
ecore_drm2_device_keyboard_group_set(dev, index);
|
|
|
|
}
|
|
|
|
#endif
|
2016-06-30 11:19:33 -07:00
|
|
|
if (e_comp_wl)
|
|
|
|
{
|
|
|
|
e_comp_wl->kbd.choosen_group = index;
|
|
|
|
_e_comp_wl_input_state_update();
|
|
|
|
e_comp_wl_input_keyboard_modifiers_update();
|
2018-01-23 13:51:58 -08:00
|
|
|
nested_keymap_update();
|
2016-06-30 11:19:33 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
choosen_group = index;
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API void
|
2016-01-25 16:06:57 -08:00
|
|
|
e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout, const char *variant, const char *options)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
struct xkb_keymap *keymap;
|
2016-03-23 01:38:34 -07:00
|
|
|
struct xkb_context *context;
|
2014-05-09 02:28:47 -07:00
|
|
|
struct xkb_rule_names names;
|
|
|
|
|
|
|
|
/* DBG("COMP_WL: Keymap Set: %s %s %s", rules, model, layout); */
|
|
|
|
|
|
|
|
/* assemble xkb_rule_names so we can fetch keymap */
|
2016-01-25 16:06:57 -08:00
|
|
|
memset(&names, 0, sizeof(names));
|
2016-01-25 15:26:34 -08:00
|
|
|
|
2016-01-25 16:06:57 -08:00
|
|
|
if (rules) names.rules = rules;
|
|
|
|
else names.rules = "evdev";
|
2016-01-25 15:26:34 -08:00
|
|
|
|
2016-01-25 16:06:57 -08:00
|
|
|
if (model) names.model = model;
|
|
|
|
else names.model = "pc105";
|
2016-01-25 15:26:34 -08:00
|
|
|
|
2016-01-25 16:06:57 -08:00
|
|
|
if (layout) names.layout = layout;
|
|
|
|
else names.layout = "us";
|
2016-01-25 15:26:34 -08:00
|
|
|
|
2016-01-25 16:06:57 -08:00
|
|
|
if (variant) names.variant = variant;
|
|
|
|
else names.variant = NULL;
|
2016-01-25 15:26:34 -08:00
|
|
|
|
2016-01-25 16:06:57 -08:00
|
|
|
if (options) names.options = options;
|
|
|
|
else names.options = NULL;
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* create a new xkb context */
|
2016-03-23 01:38:34 -07:00
|
|
|
context = xkb_context_new(0);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* fetch new keymap based on names */
|
2016-03-23 01:38:34 -07:00
|
|
|
keymap = xkb_map_new_from_names(context, &names, 0);
|
2016-01-25 15:26:34 -08:00
|
|
|
|
|
|
|
if (!keymap)
|
2015-06-30 06:10:54 -07:00
|
|
|
{
|
2016-01-25 15:26:34 -08:00
|
|
|
ERR("Failed to compile keymap");
|
2016-01-25 16:06:57 -08:00
|
|
|
return;
|
2015-06-30 06:10:54 -07:00
|
|
|
}
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2016-03-23 01:38:34 -07:00
|
|
|
_e_comp_wl_input_context_keymap_set(keymap, context);
|
2014-05-09 02:28:47 -07:00
|
|
|
}
|
2015-05-13 09:05:57 -07:00
|
|
|
|
2015-09-28 12:51:51 -07:00
|
|
|
E_API void
|
2015-05-13 09:05:57 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->touch.enabled = !!enabled;
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_comp_wl_input_update_seat_caps();
|
2015-05-13 09:05:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2015-12-11 10:29:36 -08:00
|
|
|
|
|
|
|
EINTERN void
|
|
|
|
e_comp_wl_input_keyboard_modifers_clear(void)
|
|
|
|
{
|
|
|
|
e_comp_wl->kbd.mod_depressed = 0;
|
|
|
|
e_comp_wl->kbd.mod_latched = 0;
|
|
|
|
e_comp_wl->kbd.mod_locked = 0;
|
|
|
|
e_comp_wl->kbd.mod_group = 0;
|
|
|
|
|
|
|
|
e_comp_wl_input_keyboard_modifiers_serialize();
|
|
|
|
}
|
2016-01-20 09:38:22 -08:00
|
|
|
|
|
|
|
static void
|
|
|
|
_event_generate(const char *key, const char *keyname, int mods, Eina_Bool up)
|
|
|
|
{
|
|
|
|
Ecore_Event_Key *ev;
|
|
|
|
int keycode;
|
|
|
|
|
|
|
|
keycode = _xkb_keymap_key_by_name(e_comp_wl->xkb.keymap, keyname ?: key);
|
2017-02-10 14:23:44 -08:00
|
|
|
if (keycode == -1)
|
2016-01-20 09:38:22 -08:00
|
|
|
{
|
2017-02-10 14:23:44 -08:00
|
|
|
ERR("no keycode found for key '%s'", keyname ?: key);
|
2016-01-20 09:38:22 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ev = calloc(1, sizeof(Ecore_Event_Key) + (2 * (strlen(key) + 1)));
|
|
|
|
|
|
|
|
ev->keyname = (char *)(ev + 1);
|
|
|
|
ev->key = ev->keyname + strlen(key) + 1;
|
|
|
|
|
|
|
|
strcpy((char *)ev->keyname, key);
|
|
|
|
strcpy((char *)ev->key, key);
|
|
|
|
|
|
|
|
ev->window = e_comp->ee_win;
|
|
|
|
ev->event_window = e_comp->ee_win;
|
|
|
|
ev->timestamp = 0;
|
|
|
|
ev->modifiers = mods;
|
|
|
|
ev->keycode = keycode;
|
|
|
|
ecore_event_add(up ? ECORE_EVENT_KEY_UP : ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_event_generate_mods(int mods, Eina_Bool up)
|
|
|
|
{
|
|
|
|
if (!mods) return;
|
|
|
|
if (mods & ECORE_EVENT_MODIFIER_SHIFT)
|
|
|
|
_event_generate("Shift", "LFSH", mods, up);
|
|
|
|
if (mods & ECORE_EVENT_MODIFIER_CTRL)
|
|
|
|
_event_generate("Control_L", "LCTL", mods, up);
|
|
|
|
if (mods & ECORE_EVENT_MODIFIER_ALT)
|
|
|
|
_event_generate("Alt_L", "LALT", mods, up);
|
|
|
|
if (mods & ECORE_EVENT_MODIFIER_WIN)
|
|
|
|
_event_generate("Super_L", "LWIN", mods, up);
|
|
|
|
if (mods & ECORE_EVENT_MODIFIER_ALTGR)
|
|
|
|
_event_generate("Mode_switch", "ALGR", mods, up);
|
|
|
|
}
|
|
|
|
|
|
|
|
E_API void
|
|
|
|
e_comp_wl_input_keyboard_event_generate(const char *key, int mods, Eina_Bool up)
|
|
|
|
{
|
2017-02-24 11:15:42 -08:00
|
|
|
const char *keyname = NULL;
|
|
|
|
/* assumes qwerty layout */
|
|
|
|
/* /usr/share/X11/xkb/keycodes/evdev */
|
|
|
|
static const char *keycodes[] =
|
|
|
|
{
|
|
|
|
['`'] = "TLDE",
|
|
|
|
['1'] = "AE01",
|
|
|
|
['2'] = "AE02",
|
|
|
|
['3'] = "AE03",
|
|
|
|
['4'] = "AE04",
|
|
|
|
['5'] = "AE05",
|
|
|
|
['6'] = "AE06",
|
|
|
|
['7'] = "AE07",
|
|
|
|
['8'] = "AE08",
|
|
|
|
['9'] = "AE09",
|
|
|
|
['0'] = "AE10",
|
|
|
|
['-'] = "AE11",
|
|
|
|
['='] = "AE12",
|
|
|
|
//''] = "BKSP",
|
|
|
|
['\t'] = "TAB",
|
|
|
|
['q'] = "AD01",
|
|
|
|
['w'] = "AD02",
|
|
|
|
['e'] = "AD03",
|
|
|
|
['r'] = "AD04",
|
|
|
|
['t'] = "AD05",
|
|
|
|
['y'] = "AD06",
|
|
|
|
['u'] = "AD07",
|
|
|
|
['i'] = "AD08",
|
|
|
|
['o'] = "AD09",
|
|
|
|
['p'] = "AD10",
|
|
|
|
['['] = "AD11",
|
|
|
|
[']'] = "AD12",
|
|
|
|
['\\'] = "BKSL",
|
|
|
|
['\r'] = "RTRN",
|
|
|
|
//''] = "CAPS",
|
|
|
|
['a'] = "AC01",
|
|
|
|
['s'] = "AC02",
|
|
|
|
['d'] = "AC03",
|
|
|
|
['f'] = "AC04",
|
|
|
|
['g'] = "AC05",
|
|
|
|
['h'] = "AC06",
|
|
|
|
['j'] = "AC07",
|
|
|
|
['k'] = "AC08",
|
|
|
|
['l'] = "AC09",
|
|
|
|
[';'] = "AC10",
|
|
|
|
['\''] = "AC11",
|
|
|
|
//''] = "LFSH",
|
|
|
|
['z'] = "AB01",
|
|
|
|
['x'] = "AB02",
|
|
|
|
['c'] = "AB03",
|
|
|
|
['v'] = "AB04",
|
|
|
|
['b'] = "AB05",
|
|
|
|
['n'] = "AB06",
|
|
|
|
['m'] = "AB07",
|
|
|
|
[','] = "AB08",
|
|
|
|
['.'] = "AB09",
|
|
|
|
['/'] = "AB10",
|
|
|
|
//''] = "RTSH",
|
|
|
|
[' '] = "SPCE",
|
|
|
|
};
|
|
|
|
|
2016-01-20 09:38:22 -08:00
|
|
|
if (!_xkb_keymap_key_by_name)
|
|
|
|
{
|
|
|
|
ERR("xkbcommon >= 0.6.0 required for keyboard event generation!");
|
|
|
|
return;
|
|
|
|
}
|
2017-02-24 11:15:42 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(key);
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(!key[0]);
|
|
|
|
if (!input_gen_modifiers)
|
|
|
|
{
|
|
|
|
//<RTSH> = 62;
|
|
|
|
//<LALT> = 64;
|
|
|
|
//<LCTL> = 37;
|
|
|
|
//<RCTL> = 105;
|
|
|
|
//<RALT> = 108;
|
|
|
|
//<LWIN> = 133;
|
|
|
|
//<RWIN> = 134;
|
|
|
|
//<COMP> = 135;
|
|
|
|
//alias <MENU> = <COMP>;
|
|
|
|
//<ESC> = 9;
|
|
|
|
static const char *modcodes[] =
|
|
|
|
{
|
|
|
|
"Shift_L",
|
|
|
|
"LFSH",
|
|
|
|
|
|
|
|
"Control_L",
|
|
|
|
"LCTL",
|
|
|
|
|
|
|
|
"Super_L",
|
|
|
|
"LWIN",
|
|
|
|
|
|
|
|
"Alt_L",
|
|
|
|
"LALT",
|
|
|
|
|
|
|
|
"Escape",
|
|
|
|
"ESC",
|
|
|
|
|
|
|
|
"Alt_R",
|
|
|
|
"RALT",
|
|
|
|
|
|
|
|
"Super_R",
|
|
|
|
"RWIN",
|
|
|
|
|
|
|
|
"Menu",
|
|
|
|
"MENU",
|
|
|
|
|
|
|
|
"Control_R",
|
|
|
|
"RCTRL",
|
|
|
|
|
|
|
|
"Mode_switch",
|
|
|
|
"ALGR",
|
2017-03-03 08:56:16 -08:00
|
|
|
|
|
|
|
"Return",
|
|
|
|
"RTRN",
|
|
|
|
|
|
|
|
"Caps_Lock",
|
|
|
|
"CAPS",
|
2017-02-24 11:15:42 -08:00
|
|
|
};
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
input_gen_modifiers = eina_hash_string_superfast_new(NULL);
|
|
|
|
for (i = 0; i < EINA_C_ARRAY_LENGTH(modcodes); i += 2)
|
|
|
|
eina_hash_add(input_gen_modifiers, modcodes[i], modcodes[i + 1]);
|
|
|
|
}
|
2016-01-20 09:38:22 -08:00
|
|
|
|
|
|
|
if (!up)
|
|
|
|
_event_generate_mods(mods, up);
|
2017-02-24 11:15:42 -08:00
|
|
|
keyname = eina_hash_find(input_gen_modifiers, key);
|
|
|
|
if ((!keyname) && (!key[1]))
|
|
|
|
{
|
|
|
|
if (key[0] < (int)EINA_C_ARRAY_LENGTH(keycodes))
|
|
|
|
keyname = keycodes[(unsigned char)key[0]];
|
|
|
|
}
|
|
|
|
_event_generate(key, keyname, mods, up);
|
2016-01-20 09:38:22 -08:00
|
|
|
if (up)
|
|
|
|
_event_generate_mods(mods, up);
|
|
|
|
}
|