src/bin/e_single_pixel_buffer.c \
src/bin/e_comp_wl_buffer.c \
src/bin/e_compositor.c \
-src/bin/e_blender.c
+src/bin/e_blender.c \
+src/bin/e_devicemgr_keyboard_grab.c
src_bin_enlightenment_CPPFLAGS = $(E_CPPFLAGS) -DEFL_BETA_API_SUPPORT -DEFL_EO_API_SUPPORT -DE_LOGGING=2 @WAYLAND_CFLAGS@ $(TTRACE_CFLAGS) $(DLOG_CFLAGS) $(PIXMAN_CFLAGS) $(POLICY_CFLAGS) $(EGL_CFLAGS)
if HAVE_LIBGOMP
int max_touch_count;
GMutex device_list_mutex;
GMutex last_device_kbd_mutex;
+
+ struct
+ {
+ struct wl_client *client;
+ E_Client *ec;
+ unsigned int subtype;
+ } keyboard_grab;
};
struct _E_Devicemgr_Intercept_Hook
E_API Eina_Bool e_devicemgr_block_reset(void);
+EINTERN Eina_Bool e_devicemgr_keyboard_grab_subtype_is_grabbed(Ecore_Device_Subclass subclas);
+
#endif
#endif
--- /dev/null
+#include "e_devicemgr_private.h"
+
+static void _e_devicemgr_keyboard_grab_client_cb_destroy(struct wl_listener *l, void *data);
+
+EINTERN Eina_Bool
+e_devicemgr_keyboard_grab_subtype_is_grabbed(Ecore_Device_Subclass subclas)
+{
+ if ((subclas == ECORE_DEVICE_SUBCLASS_NONE) &&
+ (e_devicemgr->keyboard_grab.subtype & TIZEN_INPUT_DEVICE_MANAGER_SUBCLAS_NONE))
+ return EINA_TRUE;
+
+ if ((subclas == ECORE_DEVICE_SUBCLASS_REMOCON) &&
+ (e_devicemgr->keyboard_grab.subtype & TIZEN_INPUT_DEVICE_MANAGER_SUBCLAS_REMOCON))
+ return EINA_TRUE;
+
+ if ((subclas == ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD) &&
+ (e_devicemgr->keyboard_grab.subtype & TIZEN_INPUT_DEVICE_MANAGER_SUBCLAS_VIRTUAL_KEYBOARD))
+ return EINA_TRUE;
+
+ DMWRN("Keyboard Grab. device subclas(%d) is not grabbed", subclas);
+ return EINA_FALSE;
+}
+
+static void
+_e_devicemgr_keyboard_grab_key_handler(uint32_t keycode, uint32_t state,
+ uint32_t timestamp)
+{
+ DMINF("key(%d-%s) event is delivered to grab ec(%p)",
+ keycode, state ? "Pressed" : "Released", e_devicemgr->keyboard_grab.ec);
+
+ if (!e_comp_wl_key_send(e_devicemgr->keyboard_grab.ec, keycode, state ? EINA_TRUE : EINA_FALSE,
+ NULL, timestamp))
+ {
+ DMERR("Could not send keyboard_grab_key to client(%p)", e_devicemgr->keyboard_grab.client);
+ }
+}
+
+static Eina_Bool
+_e_devicemgr_keyboard_grab_client_remove(struct wl_client *client)
+{
+ struct wl_listener *destroy_listener = NULL;
+
+ if (client != e_devicemgr->keyboard_grab.client)
+ return EINA_FALSE;
+
+ e_devicemgr->keyboard_grab.subtype = 0x0;
+ e_devicemgr->keyboard_grab.client = NULL;
+ e_devicemgr->keyboard_grab.ec = NULL;
+
+ if (!e_input_keyboard_grab_key_handler_set(NULL))
+ {
+ DMERR("ERROR! Could not set keyboard_grab key handler to NULL!");
+ return EINA_FALSE;
+ }
+
+ destroy_listener = wl_client_get_destroy_listener(client, _e_devicemgr_keyboard_grab_client_cb_destroy);
+ if (destroy_listener)
+ {
+ wl_list_remove(&destroy_listener->link);
+ E_FREE(destroy_listener);
+ }
+
+ return EINA_TRUE;
+}
+
+static void
+_e_devicemgr_keyboard_grab_client_cb_destroy(struct wl_listener *l, void *data)
+{
+ struct wl_client *client = (struct wl_client *)data;
+
+ if (!e_devicemgr->keyboard_grab.client) return;
+
+ wl_list_remove(&l->link);
+ E_FREE(l);
+
+ _e_devicemgr_keyboard_grab_client_remove(client);
+}
+
+static Eina_Bool
+_e_devicemgr_keyboard_grab_client_add(struct wl_client *client, E_Client *ec, uint32_t subclas)
+{
+ struct wl_listener *destroy_listener = NULL;
+
+ e_devicemgr->keyboard_grab.subtype |= subclas;
+
+ if (e_devicemgr->keyboard_grab.client == client)
+ return EINA_TRUE;
+
+ e_devicemgr->keyboard_grab.client = client;
+ e_devicemgr->keyboard_grab.ec = ec;
+
+ if (!e_input_keyboard_grab_key_handler_set(_e_devicemgr_keyboard_grab_key_handler))
+ {
+ DMERR("ERROR! Could not set keyboard_grab key handler to func!");
+ return EINA_FALSE;
+ }
+
+ destroy_listener = E_NEW(struct wl_listener, 1);
+ EINA_SAFETY_ON_NULL_GOTO(destroy_listener, failed);
+ destroy_listener->notify = _e_devicemgr_keyboard_grab_client_cb_destroy;
+ wl_client_add_destroy_listener(client, destroy_listener);
+
+ return EINA_TRUE;
+
+failed:
+ e_devicemgr->keyboard_grab.client = NULL;
+ e_devicemgr->keyboard_grab.ec = NULL;
+ e_devicemgr->keyboard_grab.subtype = 0x0;
+
+ return EINA_FALSE;
+}
+
+int
+e_devicemgr_keyboard_grab(struct wl_client *client, struct wl_resource *surface, uint32_t subclas)
+{
+ int ret = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
+ E_Client *ec;
+ uint32_t all_subclass = TIZEN_INPUT_DEVICE_MANAGER_SUBCLAS_NONE |
+ TIZEN_INPUT_DEVICE_MANAGER_SUBCLAS_REMOCON |
+ TIZEN_INPUT_DEVICE_MANAGER_SUBCLAS_VIRTUAL_KEYBOARD;
+
+ if ((e_devicemgr->keyboard_grab.client) && (e_devicemgr->keyboard_grab.client != client))
+ {
+ return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED;
+ }
+ if (!(subclas & all_subclass))
+ {
+ return TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_CLASS;
+ }
+
+ ec = e_client_from_surface_resource(surface);
+ if (!ec)
+ return TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_SURFACE;
+
+ if (!_e_devicemgr_keyboard_grab_client_add(client, ec, subclas))
+ ret = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED;
+
+ return ret;
+}
+
+int
+e_devicemgr_keyboard_ungrab(struct wl_client *client, struct wl_resource *surface)
+{
+ int ret = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
+ E_Client *ec;
+
+ if ((e_devicemgr->keyboard_grab.client) && (e_devicemgr->keyboard_grab.client != client))
+ {
+ return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED;
+ }
+
+ ec = e_client_from_surface_resource(surface);
+ if (!ec)
+ return TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_SURFACE;
+
+ if (!_e_devicemgr_keyboard_grab_client_remove(client))
+ ret = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED;
+
+ return ret;
+}
\ No newline at end of file
void e_devicemgr_wl_generator_with_sync_send_event(struct wl_resource *resource, int error);
void e_devicemgr_inputgen_device_ready_send(E_Devicemgr_Input_Device *dev);
+int e_devicemgr_keyboard_ungrab(struct wl_client *client, struct wl_resource *surface);
+int e_devicemgr_keyboard_grab(struct wl_client *client, struct wl_resource *surface, uint32_t subclas);
+
tizen_input_device_manager_send_error(resource, ret);
}
+static void
+_e_devicemgr_wl_cb_keyboard_grab(struct wl_client *client, struct wl_resource *resource,
+ struct wl_resource *surface, uint32_t subclas)
+{
+ int ret = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
+
+#ifdef HAVE_CYNARA
+ if (EINA_FALSE == _e_devicemgr_util_do_privilege_check(client, wl_client_get_fd(client),
+ E_PRIVILEGE_INTERNAL_DEFAULT_PLATFORM))
+ {
+ DMERR("keyboard_grab request:priv check failed");
+ tizen_input_device_manager_send_error(resource, TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION);
+ return;
+ }
+#endif
+
+ ret = e_devicemgr_keyboard_grab(client, surface, subclas);
+ tizen_input_device_manager_send_error(resource, ret);
+}
+
+static void
+_e_devicemgr_wl_cb_keyboard_ungrab(struct wl_client *client, struct wl_resource *resource,
+ struct wl_resource *surface)
+{
+ int ret = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
+
+#ifdef HAVE_CYNARA
+ if (EINA_FALSE == _e_devicemgr_util_do_privilege_check(client, wl_client_get_fd(client),
+ E_PRIVILEGE_INTERNAL_DEFAULT_PLATFORM))
+ {
+ DMERR("keyboard_ungrab request:priv check failed");
+ tizen_input_device_manager_send_error(resource, TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION);
+ return;
+ }
+#endif
+
+ ret = e_devicemgr_keyboard_ungrab(client, surface);
+ tizen_input_device_manager_send_error(resource, ret);
+}
+
static const struct tizen_input_device_manager_interface _e_devicemgr_wl_implementation = {
_e_devicemgr_wl_cb_block_events,
_e_devicemgr_wl_cb_generate_axis,
_e_devicemgr_wl_cb_set_touch_count,
_e_devicemgr_wl_cb_init_generator_with_sync,
+ _e_devicemgr_wl_cb_keyboard_grab,
+ _e_devicemgr_wl_cb_keyboard_ungrab
};
static void
/* try to add tizen_input_device_manager to wayland globals */
e_devicemgr->wl_data->global = wl_global_create(e_comp_wl->wl.disp,
- &tizen_input_device_manager_interface, 5,
+ &tizen_input_device_manager_interface, 6,
NULL, _e_devicemgr_wl_cb_bind);
if (!e_devicemgr->wl_data->global)
{
return NULL;
}
+EINTERN Eina_Bool
+e_input_keyboard_grab_key_handler_set(e_input_keyboard_grab_key_cb handler)
+{
+ if (!e_input)
+ return EINA_FALSE;
+
+ e_input->keyboard_grab_key_handler = handler;
+ return EINA_TRUE;
+}
+
+EINTERN e_input_keyboard_grab_key_cb
+e_input_keyboard_grab_key_handler_get(void)
+{
+ if (e_input)
+ return e_input->keyboard_grab_key_handler;
+
+ return NULL;
+}
+
typedef struct _E_Input_Coord E_Input_Coord;
typedef void (*e_input_relative_motion_cb)(double dx[2], double dy[2], uint64_t time_us);
+typedef void (*e_input_keyboard_grab_key_cb)(uint32_t keycode, uint32_t state, uint32_t timestamp);
struct _E_Input
{
unsigned int touch_device_count;
e_input_relative_motion_cb relative_motion_handler;
+ e_input_keyboard_grab_key_cb keyboard_grab_key_handler;
};
struct _E_Input_Device
EINTERN Eina_Bool e_input_relative_motion_handler_set(e_input_relative_motion_cb handler);
EINTERN e_input_relative_motion_cb e_input_relative_motion_handler_get(void);
+EINTERN Eina_Bool e_input_keyboard_grab_key_handler_set(e_input_keyboard_grab_key_cb handler);
+EINTERN e_input_keyboard_grab_key_cb e_input_keyboard_grab_key_handler_get(void);
+
EINTERN Eina_Bool e_input_device_subtype_set(E_Input_Device *dev, const char *input, const char *subtype);
#endif
#include "e_device.h"
#include "e_keyrouter_private.h"
#include "e_input_event.h"
+#include "e_devicemgr.h"
#include <glib.h>
int *pressed_keycode = NULL, *idata = NULL;
Eina_Bool dup_found = EINA_FALSE;
const char* device_name = NULL;
+ Ecore_Device_Subclass device_subclas = ECORE_DEVICE_SUBCLASS_NONE;
if (!(edev = libinput_device_get_user_data(device)))
{
}
device_name = ecore_device_name_get(ecore_dev);
+ device_subclas = ecore_device_subclass_get(ecore_dev);
}
else
{
}
device_name = e_device_name_get(e_dev);
+ device_subclas = e_device_subclass_get(e_dev);
}
timestamp = libinput_event_keyboard_get_time(event);
return;
}
+ e_input_keyboard_grab_key_cb func = e_input_keyboard_grab_key_handler_get();
+ if (func)
+ {
+ if (e_devicemgr_keyboard_grab_subtype_is_grabbed(device_subclas))
+ {
+ func(code, state, timestamp);
+ return;
+ }
+ }
+
g_mutex_lock(&edev->xkb.state_mutex);
xkb_state_update_key(edev->xkb.state, code,
(state ? XKB_KEY_DOWN : XKB_KEY_UP));