}
}
+static E_Comp_Wl_Input_Device *
+_e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class)
+{
+ switch (dev_class)
+ {
+ case ECORE_DEVICE_CLASS_MOUSE:
+ return e_comp_wl->input_device_manager.last_device_ptr;
+ case ECORE_DEVICE_CLASS_KEYBOARD:
+ return e_comp_wl->input_device_manager.last_device_kbd;
+ case ECORE_DEVICE_CLASS_TOUCH:
+ return e_comp_wl->input_device_manager.last_device_touch;
+ default:
+ return NULL;;
+ }
+ return NULL;
+}
+
static void
-_e_comp_wl_device_send_event_device(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, uint32_t timestamp)
+_e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Comp_Wl_Input_Device *device)
+{
+ switch (dev_class)
+ {
+ case ECORE_DEVICE_CLASS_MOUSE:
+ e_comp_wl->input_device_manager.last_device_ptr = device;
+ break;
+ case ECORE_DEVICE_CLASS_KEYBOARD:
+ e_comp_wl->input_device_manager.last_device_kbd = device;
+ break;
+ case ECORE_DEVICE_CLASS_TOUCH:
+ e_comp_wl->input_device_manager.last_device_touch = device;
+ break;
+ default:
+ break;
+ }
+}
+
+static E_Comp_Wl_Input_Device *
+_e_comp_wl_device_client_last_device_get(E_Client *ec, Ecore_Device_Class dev_class)
{
- const char *last_dev_name;
- E_Comp_Wl_Input_Device *input_dev;
+ switch (dev_class)
+ {
+ case ECORE_DEVICE_CLASS_MOUSE:
+ return ec->comp_data->last_device_ptr;
+ case ECORE_DEVICE_CLASS_KEYBOARD:
+ return ec->comp_data->last_device_kbd;
+ case ECORE_DEVICE_CLASS_TOUCH:
+ return ec->comp_data->last_device_touch;
+ default:
+ return NULL;;
+ }
+ return NULL;
+}
+
+static void
+_e_comp_wl_device_client_last_device_set(E_Client *ec, Ecore_Device_Class dev_class, E_Comp_Wl_Input_Device *device)
+{
+ switch (dev_class)
+ {
+ case ECORE_DEVICE_CLASS_MOUSE:
+ ec->comp_data->last_device_ptr = device;
+ break;
+ case ECORE_DEVICE_CLASS_KEYBOARD:
+ ec->comp_data->last_device_kbd = device;
+ break;
+ case ECORE_DEVICE_CLASS_TOUCH:
+ ec->comp_data->last_device_touch = device;
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+_e_comp_wl_device_send_event_device(E_Client *ec, Evas_Device *dev, uint32_t timestamp)
+{
+ E_Comp_Wl_Input_Device *last_device, *ec_last_device, *input_dev;
struct wl_resource *dev_res;
+ const char *dev_name;
+ Ecore_Device_Class dev_class;
struct wl_client *wc;
uint32_t serial;
Eina_List *l, *ll;
+ EINA_SAFETY_ON_NULL_RETURN(dev);
+
if (!ec) return;
if (ec->cur_mouse_action || e_comp_wl->drag)
return;
if (ec->ignored) return;
if (!ec->comp_data->surface) return;
- last_dev_name = e_comp_wl->input_device_manager.last_device_name;
- if (!last_dev_name || (last_dev_name && (strcmp(last_dev_name, dev_name))))
- {
- if (last_dev_name)
- eina_stringshare_del(last_dev_name);
- last_dev_name = eina_stringshare_add(dev_name);
- e_comp_wl->input_device_manager.last_device_name= last_dev_name;
-
- wc = wl_resource_get_client(ec->comp_data->surface);
- serial = wl_display_next_serial(e_comp_wl->wl.disp);
+ dev_class = (Ecore_Device_Class)evas_device_class_get(dev);
+ dev_name = evas_device_description_get(dev);
+ last_device = _e_comp_wl_device_last_device_get(dev_class);
+ ec_last_device = _e_comp_wl_device_client_last_device_get(ec, dev_class);
- EINA_LIST_FOREACH(e_comp_wl->input_device_manager.device_list, l, input_dev)
+ serial = wl_display_next_serial(e_comp_wl->wl.disp);
+ wc = wl_resource_get_client(ec->comp_data->surface);
+ EINA_LIST_FOREACH(e_comp_wl->input_device_manager.device_list, l, input_dev)
+ {
+ if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != dev_class)) continue;
+ if ((!last_device) || (last_device != input_dev) || (!ec_last_device) || (ec_last_device != input_dev))
{
- if ((strcmp(input_dev->identifier, dev_name)) || (input_dev->clas != (Ecore_Device_Class)dev_class)) continue;
- e_comp_wl->input_device_manager.last_device_clas = input_dev->clas;
+ _e_comp_wl_device_last_device_set(dev_class, input_dev);
+ _e_comp_wl_device_client_last_device_set(ec, dev_class, input_dev);
+
EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
{
if (wl_resource_get_client(dev_res) != wc) continue;
}
static void
-_e_comp_wl_device_send_last_event_device(E_Client *ec, uint32_t timestamp)
+_e_comp_wl_device_send_last_event_device(E_Client *ec, Ecore_Device_Class dev_class, uint32_t timestamp)
{
- E_Comp_Wl_Input_Device *input_dev;
+ E_Comp_Wl_Input_Device *last_device;
struct wl_resource *dev_res;
struct wl_client *wc;
uint32_t serial;
- Eina_List *l, *ll;
+ Eina_List *l;
if (!ec->comp_data->surface) return;
- if (!e_comp_wl->input_device_manager.last_device_name) return;
+
+ last_device = _e_comp_wl_device_last_device_get(dev_class);
+ if (!last_device) return;
+
+ _e_comp_wl_device_client_last_device_set(ec, dev_class, last_device);
serial = wl_display_next_serial(e_comp_wl->wl.disp);
wc = wl_resource_get_client(ec->comp_data->surface);
- EINA_LIST_FOREACH(e_comp_wl->input_device_manager.device_list, l, input_dev)
+ EINA_LIST_FOREACH(last_device->resources, l, dev_res)
{
- if ((strcmp(input_dev->identifier, e_comp_wl->input_device_manager.last_device_name)) ||
- (input_dev->clas != e_comp_wl->input_device_manager.last_device_clas))
- continue;
-
- EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
- {
- if (wl_resource_get_client(dev_res) != wc) continue;
- tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
- }
+ if (wl_resource_get_client(dev_res) != wc) continue;
+ tizen_input_device_send_event_device(dev_res, serial, last_device->identifier, timestamp);
}
-}
+ }
static void
_e_comp_wl_cursor_reload(E_Client *ec)
e_comp_wl->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec);
}
- if ((e_comp_wl->input_device_manager.last_device_clas == ECORE_DEVICE_CLASS_MOUSE) ||
- (e_comp_wl->input_device_manager.last_device_clas == ECORE_DEVICE_CLASS_TOUCH))
- _e_comp_wl_device_send_last_event_device(ec, ev->timestamp);
-
if (!eina_list_count(e_comp_wl->ptr.resources)) return;
wc = wl_resource_get_client(ec->comp_data->surface);
serial = wl_display_next_serial(e_comp_wl->wl.disp);
if (!e_comp_wl_input_pointer_check(res)) continue;
if (wl_resource_get_client(res) != wc) continue;
+ _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
+
wl_pointer_send_enter(res, serial, ec->comp_data->surface,
wl_fixed_from_int(ev->canvas.x - ec->client.x),
wl_fixed_from_int(ev->canvas.y - ec->client.y));
if (!e_comp_wl_input_pointer_check(res)) continue;
if (wl_resource_get_client(res) != wc) continue;
if (ec->pointer_enter_sent == EINA_FALSE) continue;
+
+ _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
+
wl_pointer_send_leave(res, serial, ec->comp_data->surface);
ec->pointer_enter_sent = EINA_FALSE;
}
dev = ev->dev;
dev_name = evas_device_description_get(dev);
- if (dev && dev_name)
- _e_comp_wl_device_send_event_device(dev_name, evas_device_class_get(dev), ec, ev->timestamp);
+ _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
{
dev = ev->dev;
dev_name = evas_device_description_get(dev);
- if (dev && dev_name)
- _e_comp_wl_device_send_event_device(dev_name, evas_device_class_get(dev), ec, ev->timestamp);
+ _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
{
if (need_send_leave)
{
need_send_leave = EINA_FALSE;
+ _e_comp_wl_device_send_event_device(focused, dev, ev->timestamp);
_e_comp_wl_send_mouse_out(focused);
}
}
dev = ev->dev;
dev_name = evas_device_description_get(dev);
- if (dev && dev_name)
- _e_comp_wl_device_send_event_device(dev_name, evas_device_class_get(dev), ec, ev->timestamp);
+ _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
if (dev && (evas_device_class_get(dev) == EVAS_DEVICE_CLASS_TOUCH))
{
if (!ec->comp_data->surface) return;
+ if (!eina_list_count(e_comp_wl->ptr.resources))
+ return;
+
+ _e_comp_wl_device_send_event_device(ec, ev->dev, ev->timestamp);
+
wc = wl_resource_get_client(ec->comp_data->surface);
EINA_LIST_FOREACH(e_comp_wl->ptr.resources, l, res)
{
if (e_object_is_del(E_OBJECT(ec))) return;
if (!ec->comp_data->surface) return;
- dev = ev->dev;
+ /* Do not deliver emulated single touch events to client */
+ if (ev->device == 0) return;
+ dev = ev->dev;
if (dev && (dev_name = evas_device_description_get(dev)))
{
- dev_class = evas_device_class_get(dev);
- _e_comp_wl_device_send_event_device(dev_name, dev_class, ec, ev->timestamp);
+ dev_class = evas_device_class_get(dev);
+ _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
_e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
}
- /* Do not deliver emulated single touch events to client */
- if (ev->device == 0) return;
-
wc = wl_resource_get_client(ec->comp_data->surface);
serial = wl_display_next_serial(e_comp_wl->wl.disp);
if (e_object_is_del(E_OBJECT(ec))) return;
if (!ec->comp_data->surface) return;
- dev = ev->dev;
+ /* Do not deliver emulated single touch events to client */
+ if (ev->device == 0) return;
+ dev = ev->dev;
if (dev && (dev_name = evas_device_description_get(dev)))
{
- dev_class = evas_device_class_get(dev);
- _e_comp_wl_device_send_event_device(dev_name, dev_class, ec, ev->timestamp);
+ dev_class = evas_device_class_get(dev);
+ _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
_e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
}
- /* Do not deliver emulated single touch events to client */
- if (ev->device == 0) return;
-
wc = wl_resource_get_client(ec->comp_data->surface);
serial = wl_display_next_serial(e_comp_wl->wl.disp);
if (e_object_is_del(E_OBJECT(ec))) return;
if (!ec->comp_data->surface) return;
- dev = ev->dev;
+ /* Do not deliver emulated single touch events to client */
+ if (ev->device == 0) return;
+ dev = ev->dev;
if (dev && (dev_name = evas_device_description_get(dev)))
{
- dev_class = evas_device_class_get(dev);
- _e_comp_wl_device_send_event_device(dev_name, dev_class, ec, ev->timestamp);
+ dev_class = evas_device_class_get(dev);
+ _e_comp_wl_device_send_event_device(ec, dev, ev->timestamp);
_e_comp_wl_device_handle_axes(dev_name, dev_class, ec, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
}
- /* Do not deliver emulated single touch events to client */
- if (ev->device == 0) return;
-
wc = wl_resource_get_client(ec->comp_data->surface);
x = wl_fixed_from_int(ev->cur.canvas.x - ec->client.x);
struct wl_resource *res;
Eina_List *l;
double t;
+ struct wl_client *wc;
if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE;
if (!e_comp_wl->kbd.focused) return EINA_FALSE;
serial = wl_display_next_serial(e_comp_wl->wl.disp);
t = ecore_time_unix_get();
- if (e_comp_wl->input_device_manager.last_device_clas == ECORE_DEVICE_CLASS_KEYBOARD)
- _e_comp_wl_device_send_last_event_device(ec, t);
EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res)
- wl_array_for_each(k, &e_comp_wl->kbd.keys)
- wl_keyboard_send_key(res, serial, t,
- *k, WL_KEYBOARD_KEY_STATE_PRESSED);
+ {
+ if (e_comp_wl->kbd.keys.size > 0)
+ {
+ wc = wl_resource_get_client(ec->comp_data->surface);
+ if (wl_resource_get_client(res) == wc)
+ _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, t);
+ }
+ wl_array_for_each(k, &e_comp_wl->kbd.keys)
+ wl_keyboard_send_key(res, serial, t,
+ *k, WL_KEYBOARD_KEY_STATE_PRESSED);
+ }
return EINA_FALSE;
}
uint32_t serial, *k;
Eina_List *l, *ll;
double t;
+ struct wl_client *wc;
if (!(ec = data)) return;
/* send keyboard_leave to all keyboard resources */
serial = wl_display_next_serial(e_comp_wl->wl.disp);
t = ecore_time_unix_get();
- if (e_comp_wl->input_device_manager.last_device_clas == ECORE_DEVICE_CLASS_KEYBOARD)
- _e_comp_wl_device_send_last_event_device(ec, t);
EINA_LIST_FOREACH_SAFE(e_comp_wl->kbd.focused, l, ll, res)
{
+ if (e_comp_wl->kbd.keys.size > 0)
+ {
+ wc = wl_resource_get_client(ec->comp_data->surface);
+ if (wl_resource_get_client(res) == wc)
+ _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, t);
+ }
wl_array_for_each(k, &e_comp_wl->kbd.keys)
wl_keyboard_send_key(res, serial, t,
*k, WL_KEYBOARD_KEY_STATE_RELEASED);
}
static void
-_e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, const char *dev_name, uint32_t serial)
+_e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial)
{
- const char *last_dev_name;
- E_Comp_Wl_Input_Device *input_dev;
+ E_Comp_Wl_Input_Device *last_device, *input_dev;
struct wl_resource *dev_res;
+ const char *dev_name;
Eina_List *l, *ll;
- last_dev_name = e_comp_wl->input_device_manager.last_device_name;
- if (!last_dev_name || (last_dev_name && (strcmp(last_dev_name, dev_name))))
+ EINA_SAFETY_ON_NULL_RETURN(dev);
+
+ dev_name = ecore_device_identifier_get(dev);
+ last_device = _e_comp_wl_device_last_device_get(ECORE_DEVICE_CLASS_KEYBOARD);
+ EINA_LIST_FOREACH(e_comp_wl->input_device_manager.device_list, l, input_dev)
{
- if (last_dev_name)
- eina_stringshare_del(last_dev_name);
- last_dev_name = eina_stringshare_add(dev_name);
- e_comp_wl->input_device_manager.last_device_name = last_dev_name;
+ if (!eina_streq(input_dev->identifier, dev_name) || (input_dev->clas != ECORE_DEVICE_CLASS_KEYBOARD)) continue;
+ _e_comp_wl_device_last_device_set(ECORE_DEVICE_CLASS_KEYBOARD, input_dev);
- EINA_LIST_FOREACH(e_comp_wl->input_device_manager.device_list, l, input_dev)
+ EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
{
- if ((strcmp(input_dev->identifier, dev_name)) ||
- (input_dev->clas != ECORE_DEVICE_CLASS_KEYBOARD))
- continue;
- e_comp_wl->input_device_manager.last_device_clas = input_dev->clas;
- EINA_LIST_FOREACH(input_dev->resources, ll, dev_res)
- {
- if (wl_resource_get_client(dev_res) != wc) continue;
- tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
- }
+ if (wl_resource_get_client(dev_res) != wc) continue;
+ tizen_input_device_send_event_device(dev_res, serial, input_dev->identifier, timestamp);
}
}
}
struct wl_resource *res;
Eina_List *l;
uint32_t serial, keycode;
- const char *dev_name;
keycode = (ev->keycode - 8);
serial = wl_display_next_serial(e_comp_wl->wl.disp);
- if (ev->dev)
- {
- dev_name = ecore_device_identifier_get(ev->dev);
- if (dev_name)
- _e_comp_wl_send_event_device(ev->data, ev->timestamp, dev_name, serial);
- }
EINA_LIST_FOREACH(key_list, l, res)
{
if (!focused && wl_resource_get_client(res) != ev->data) continue;
TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
+ _e_comp_wl_send_event_device(ev->data, ev->timestamp, ev->dev, serial);
wl_keyboard_send_key(res, serial, ev->timestamp,
keycode, state);
TRACE_INPUT_END();