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
|
|
|
|
#include <Ecore_Drm.h>
|
|
|
|
#endif
|
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 *);
|
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
|
2015-02-06 15:28:11 -08:00
|
|
|
_e_comp_wl_input_pointer_cb_cursor_set(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, 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;
|
2015-02-13 08:46:10 -08:00
|
|
|
Eina_Bool got_mouse = EINA_FALSE;
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2015-03-13 12:45:07 -07:00
|
|
|
E_CLIENT_FOREACH(ec)
|
2015-02-13 08:46:10 -08:00
|
|
|
{
|
2015-06-25 16:16:27 -07:00
|
|
|
if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) continue;
|
2015-02-13 08:46:10 -08:00
|
|
|
if (!ec->comp_data->surface) continue;
|
|
|
|
if (client != wl_resource_get_client(ec->comp_data->surface)) continue;
|
|
|
|
if (ec->mouse.in)
|
|
|
|
{
|
|
|
|
got_mouse = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!got_mouse) return;
|
2015-02-10 16:15:53 -08:00
|
|
|
if (!surface_resource)
|
|
|
|
{
|
|
|
|
e_pointer_object_set(e_comp->pointer, NULL, x, y);
|
|
|
|
return;
|
|
|
|
}
|
2015-04-21 12:19:20 -07:00
|
|
|
ec = wl_resource_get_user_data(surface_resource);
|
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;
|
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
|
|
|
|
2015-02-06 15:28:11 -08:00
|
|
|
/* ignore cursor changes during resize/move I guess */
|
|
|
|
if (e_client_action_get()) return;
|
2015-02-09 09:24:31 -08:00
|
|
|
e_pointer_object_set(e_comp->pointer, ec->frame, x, y);
|
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)
|
|
|
|
{
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->ptr.resources =
|
|
|
|
eina_list_remove(e_comp_wl->ptr.resources, resource);
|
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;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
e_comp->wl_comp_data,
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
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
|
2015-05-18 06:08:52 -07:00
|
|
|
_e_comp_wl_input_keymap_update(struct xkb_keymap *keymap)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
char *tmp;
|
2016-01-25 13:29:28 -08:00
|
|
|
xkb_mod_mask_t latched = 0, locked = 0;
|
2014-05-09 02:28:47 -07:00
|
|
|
struct wl_resource *res;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
/* 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);
|
2014-05-09 02:28:47 -07: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);
|
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 */
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->xkb.state = xkb_state_new(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,
|
|
|
|
latched, locked, 0, 0, 0);
|
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
|
|
|
|
|
|
|
/* fetch updated modifiers */
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.mod_shift =
|
2015-07-01 10:18:55 -07:00
|
|
|
xkb_map_mod_get_index(keymap, XKB_MOD_NAME_SHIFT);
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.mod_caps =
|
2015-07-01 10:18:55 -07:00
|
|
|
xkb_map_mod_get_index(keymap, XKB_MOD_NAME_CAPS);
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.mod_ctrl =
|
2015-07-01 10:18:55 -07:00
|
|
|
xkb_map_mod_get_index(keymap, XKB_MOD_NAME_CTRL);
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.mod_alt =
|
2015-07-01 10:18:55 -07:00
|
|
|
xkb_map_mod_get_index(keymap, XKB_MOD_NAME_ALT);
|
2015-08-13 13:05:57 -07:00
|
|
|
e_comp_wl->kbd.mod_super =
|
2015-07-01 10:18:55 -07:00
|
|
|
xkb_map_mod_get_index(keymap, XKB_MOD_NAME_LOGO);
|
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();
|
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)
|
|
|
|
e_comp_wl->seat.name = "default";
|
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");
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
if (!e_comp_wl->kbd.focused) 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
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API void
|
2016-01-05 10:07:27 -08:00
|
|
|
e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout, struct xkb_context *dflt_ctx, struct xkb_keymap *dflt_map)
|
2014-05-09 02:28:47 -07:00
|
|
|
{
|
|
|
|
struct xkb_keymap *keymap;
|
|
|
|
struct xkb_rule_names names;
|
2016-01-05 10:07:27 -08:00
|
|
|
Eina_Bool use_dflt_xkb = EINA_FALSE;
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* DBG("COMP_WL: Keymap Set: %s %s %s", rules, model, layout); */
|
|
|
|
|
2016-01-05 10:07:27 -08:00
|
|
|
if (dflt_ctx && dflt_map) use_dflt_xkb = EINA_TRUE;
|
|
|
|
|
2014-05-09 02:28:47 -07:00
|
|
|
/* assemble xkb_rule_names so we can fetch keymap */
|
2016-01-05 10:07:27 -08:00
|
|
|
if (!use_dflt_xkb)
|
|
|
|
{
|
|
|
|
memset(&names, 0, sizeof(names));
|
|
|
|
if (rules) names.rules = strdup(rules);
|
|
|
|
else names.rules = strdup("evdev");
|
|
|
|
if (model) names.model = strdup(model);
|
|
|
|
else names.model = strdup("pc105");
|
|
|
|
if (layout) names.layout = strdup(layout);
|
|
|
|
else names.layout = strdup("us");
|
|
|
|
}
|
2014-05-09 02:28:47 -07: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);
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* create a new xkb context */
|
2016-01-05 10:07:27 -08:00
|
|
|
if (use_dflt_xkb) e_comp_wl->xkb.context = dflt_ctx;
|
|
|
|
else e_comp_wl->xkb.context = xkb_context_new(0);
|
|
|
|
|
|
|
|
#ifdef HAVE_WL_DRM
|
|
|
|
if (e_config->xkb.use_cache)
|
|
|
|
ecore_drm_device_keyboard_cached_context_set(e_comp_wl->xkb.context);
|
|
|
|
#endif
|
2014-05-09 02:28:47 -07:00
|
|
|
|
|
|
|
/* fetch new keymap based on names */
|
2016-01-05 10:07:27 -08:00
|
|
|
if (use_dflt_xkb) keymap = dflt_map;
|
|
|
|
else keymap = xkb_map_new_from_names(e_comp_wl->xkb.context, &names, 0);
|
2015-06-30 06:10:54 -07:00
|
|
|
if (keymap)
|
|
|
|
{
|
|
|
|
/* update compositor keymap */
|
|
|
|
_e_comp_wl_input_keymap_update(keymap);
|
|
|
|
}
|
2014-05-09 02:28:47 -07:00
|
|
|
|
2016-01-05 10:07:27 -08:00
|
|
|
#ifdef HAVE_WL_DRM
|
|
|
|
if (e_config->xkb.use_cache)
|
|
|
|
ecore_drm_device_keyboard_cached_keymap_set(keymap);
|
|
|
|
#endif
|
|
|
|
|
2014-05-09 02:28:47 -07:00
|
|
|
/* cleanup */
|
2016-01-05 10:07:27 -08:00
|
|
|
if (!use_dflt_xkb)
|
|
|
|
{
|
|
|
|
free((char *)names.rules);
|
|
|
|
free((char *)names.model);
|
|
|
|
free((char *)names.layout);
|
|
|
|
}
|
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;
|
|
|
|
|
|
|
|
/* "key" here is the platform-specific key name;
|
|
|
|
* /usr/share/X11/xkb/keycodes/evdev is probably what your system is using
|
|
|
|
*/
|
|
|
|
keycode = _xkb_keymap_key_by_name(e_comp_wl->xkb.keymap, keyname ?: key);
|
|
|
|
if (!keycode)
|
|
|
|
{
|
|
|
|
ERR("no keycode found for key '%s'", key);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (!_xkb_keymap_key_by_name)
|
|
|
|
{
|
|
|
|
ERR("xkbcommon >= 0.6.0 required for keyboard event generation!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!up)
|
|
|
|
_event_generate_mods(mods, up);
|
|
|
|
_event_generate(key, NULL, mods, up);
|
|
|
|
if (up)
|
|
|
|
_event_generate_mods(mods, up);
|
|
|
|
}
|