e_comp_wl: multi-seat feature added. new E_Comp_Wl_Seat structure introduced 27/317527/1 accepted/tizen/unified/20250106.154429 accepted/tizen/unified/x/20250106.211622 accepted/tizen/unified/x/asan/20250113.002238
authorduna.oh <duna.oh@samsung.com>
Thu, 2 Jan 2025 12:28:40 +0000 (21:28 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Fri, 3 Jan 2025 06:39:53 +0000 (15:39 +0900)
Previously, E_Comp_Wl_Data contained a single seat as a sub struct.
This patch introduces a new E_Comp_Wl_Seat structure and processes input events
according to their corresponding seats.

Some remaining tasks include:
- considering seat in drag-and-drop scenarios
- sending input events to app from a specific seat (zone)
- refactoring devicemgr to be seat-aware

Change-Id: I61760271c578c616d727438ea73e1825d3534892

12 files changed:
src/bin/e_comp_screen.c
src/bin/inputmgr/e_devicemgr_input.c
src/bin/server/e_comp_wl.c
src/bin/server/e_comp_wl_data.c
src/bin/server/e_comp_wl_input.c
src/bin/server/e_comp_wl_input_intern.h
src/bin/server/e_comp_wl_input_thread.c
src/bin/server/e_comp_wl_intern.h
src/bin/server/e_devicemgr_wl.c
src/bin/windowmgr/e_pointer.c
src/bin/windowmgr/services/e_service_volume.c
src/include/e_comp_wl.h

index 32f56b2ddafc59991b09fb40fb1b8ecf755984e0..a0784caef08b7632bdf1e175e03af12aff8dbfd7 100644 (file)
@@ -303,18 +303,22 @@ _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
 {
    Ecore_Event_Device_Info *e;
    E_Comp *comp = data;
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *seat;
 
    if (!(e = event)) goto end;
+   ELOGF("COMP_SCREEN", "Input Device Add. name:%s(%s), seat:%s", NULL, e->name, e->identifier, e->seatname);
+
+   seat = e_comp_wl_input_seat_get(e->seatname);
+   if (!seat) goto end;
 
    if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
      {
-        if (comp_wl->ptr.num_devices == 0)
+        if (seat->ptr.num_devices == 0)
           {
              e_pointer_view_set(comp->pointer, NULL, 0, 0);
-             e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
+             e_comp_wl_input_pointer_enabled_set(seat, EINA_TRUE);
           }
-        comp_wl->ptr.num_devices++;
+        seat->ptr.num_devices++;
      }
    else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
      {
@@ -327,10 +331,10 @@ _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
    else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
         E_Comp_Screen *comp_screen = e_comp_screen_get();
-        e_comp_wl_input_touch_enabled_set(EINA_TRUE);
+        e_comp_wl_input_touch_enabled_set(seat, EINA_TRUE);
         if (comp_screen)
           _e_comp_screen_input_rotation_set(comp_screen->rotation);
-        comp_wl->touch.num_devices++;
+        seat->touch.num_devices++;
      }
 
 end:
@@ -338,12 +342,12 @@ end:
 }
 
 static void
-_e_comp_screen_pointer_renew(void)
+_e_comp_screen_pointer_renew(E_Comp_Wl_Seat *seat)
 {
    E_Comp_Wl_Data *comp_wl;
 
    comp_wl = e_comp_wl_get();
-   if ((comp_wl->ptr.num_devices == 0) && comp_wl->ptr.ec && comp_wl->ptr.ec->pointer_enter_sent)
+   if ((seat->ptr.num_devices == 0) && comp_wl->ptr.ec && comp_wl->ptr.ec->pointer_enter_sent)
      {
         if (e_devicemgr->last_device_ptr)
           {
@@ -378,28 +382,32 @@ _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
 {
    Ecore_Event_Device_Info *e;
    E_Comp *comp = data;
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *seat;
 
    if (!(e = event)) goto end;
+   ELOGF("COMP_SCREEN", "Input Device Del. name:%s(%s), seat:%s", NULL, e->name, e->identifier, e->seatname);
+
+   seat = e_comp_wl_input_seat_get(e->seatname);
+   if (!seat) goto end;
 
    if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
      {
-        comp_wl->ptr.num_devices--;
-        if (comp_wl->ptr.num_devices == 0)
+        seat->ptr.num_devices--;
+        if (seat->ptr.num_devices == 0)
           {
-             e_comp_wl_input_pointer_enabled_set(EINA_FALSE);
+             e_comp_wl_input_pointer_enabled_set(seat, EINA_FALSE);
              e_pointer_view_set(comp->pointer, NULL, 0, 0);
              e_pointer_hide(comp->pointer);
 
-             _e_comp_screen_pointer_renew();
+             _e_comp_screen_pointer_renew(seat);
           }
      }
    else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
-        comp_wl->touch.num_devices--;
-        if (comp_wl->touch.num_devices == 0)
+        seat->touch.num_devices--;
+        if (seat->touch.num_devices == 0)
           {
-             e_comp_wl_input_touch_enabled_set(EINA_FALSE);
+             e_comp_wl_input_touch_enabled_set(seat, EINA_FALSE);
           }
      }
 
index da0c2da0fa63377a027f9d65aaff6558c13e3c56..10ce5fc4de848762d8a695150336171b6b329d4a 100644 (file)
@@ -78,7 +78,7 @@ e_devicemgr_input_pointer_warp(struct wl_client *client, struct wl_resource *res
         return TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_SURFACE;
      }
 
-   if ((!e_config->show_cursor) || (!comp_wl->ptr.enabled))
+   if ((!e_config->show_cursor) || (!e_comp_wl_input_seat_pointer_enabled_get(NULL)))
      {
         DMERR("Pointer is not available");
         if (!e_comp_wl_input_pointer_constraint_activated_get())
index 0a9ac66cf5a72640d28b10944a70feda3b41dec6..e230ce126480733f29514da34d4e39d5ba4fb3ab 100644 (file)
@@ -86,6 +86,12 @@ struct _E_Comp_Data
 static Eina_Bool _e_comp_wl_cursor_timer_control(Evas_Callback_Type type, E_Comp_Wl_Data *comp_wl, E_Client *ec);
 static void      _e_comp_wl_surface_state_serial_update(E_Client *ec, E_Comp_Wl_Surface_State *state);
 
+static void      _e_comp_wl_seat_pointer_send_axis(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                                   uint32_t axis, uint32_t dir, uint32_t timestamp);
+
+static void      _e_comp_wl_seat_touch_send_cancel(E_Comp_Wl_Seat *seat, struct wl_client *wc, E_Client *ec);
+static void      _e_comp_wl_seat_touch_send_frame(E_Comp_Wl_Seat *seat, struct wl_client *wc);
+
 /* local variables */
 typedef struct _E_Comp_Wl_Key_Data
 {
@@ -806,10 +812,7 @@ _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
 static void
 _e_comp_wl_send_touch_cancel(E_Client *ec)
 {
-   Eina_List *l;
-   struct wl_resource *res;
    struct wl_client *wc;
-   E_Comp_Wl_Data *comp_wl;
 
    if (!ec) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
@@ -820,16 +823,7 @@ _e_comp_wl_send_touch_cancel(E_Client *ec)
 
    wc = wl_resource_get_client(surface);
 
-   comp_wl = e_comp_wl_get();
-   EINA_LIST_FOREACH(comp_wl->touch.resources, l, res)
-     {
-        if (wl_resource_get_client(res) != wc) continue;
-        if (!e_comp_wl_input_touch_check(res)) continue;
-
-        ELOGF("Touch", "Cancel name:%20s", ec, e_client_util_name_get(ec));
-
-        wl_touch_send_cancel(res);
-     }
+   _e_comp_wl_seat_touch_send_cancel(NULL, wc, ec);
 }
 
 static void
@@ -1053,11 +1047,9 @@ _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Devic
 static void
 _e_comp_wl_cursor_reload(E_Comp_Wl_Data *comp_wl, E_Client *ec)
 {
-   struct wl_resource *res;
    struct wl_client *wc;
-   Eina_List *l;
    E_Map *map;
-   uint32_t serial;
+
    int cx, cy, px, py;
    E_Pointer *comp_pointer = e_comp_pointer_get();
 
@@ -1088,15 +1080,9 @@ _e_comp_wl_cursor_reload(E_Comp_Wl_Data *comp_wl, E_Client *ec)
    cy = py - ec->client.y;
 
    wc = wl_resource_get_client(surface);
-   serial = wl_display_next_serial(comp_wl->wl.disp);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        if (wl_resource_get_client(res) != wc) continue;
-        wl_pointer_send_enter(res, serial, surface,
-                              wl_fixed_from_int(cx), wl_fixed_from_int(cy));
-        ec->pointer_enter_sent = EINA_TRUE;
-     }
+
+   e_comp_wl_seat_pointer_send_enter(NULL, wc, ec, surface, cx, cy);
+
    wl_signal_emit(&comp_wl->ptr_constraints.surface_mousein_signal, ec);
 }
 
@@ -1346,10 +1332,7 @@ _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj
 {
    E_Client *ec;
    Evas_Event_Mouse_In *ev;
-   struct wl_resource *res;
    struct wl_client *wc;
-   Eina_List *l;
-   uint32_t serial;
    E_Client *prev_ptr_ec;
    E_Comp_Wl_Data *comp_wl;
 
@@ -1382,22 +1365,13 @@ _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj
           return;
      }
 
-   if (!eina_list_count(comp_wl->ptr.resources)) return;
-   wc = wl_resource_get_client(surface);
-   serial = wl_display_next_serial(comp_wl->wl.disp);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        if (wl_resource_get_client(res) != wc) continue;
+   if (e_comp_wl_input_seat_pointer_is_empty(NULL)) return;
 
-        _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
+   wc = wl_resource_get_client(surface);
+   _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
+   e_comp_wl_seat_pointer_send_enter(NULL, wc, ec, surface, ev->canvas.x - ec->client.x, ev->canvas.y - ec->client.y);
 
-        wl_pointer_send_enter(res, serial, surface,
-                              wl_fixed_from_int(ev->canvas.x - ec->client.x),
-                              wl_fixed_from_int(ev->canvas.y - ec->client.y));
-        ec->pointer_enter_sent = EINA_TRUE;
-     }
-     wl_signal_emit(&comp_wl->ptr_constraints.surface_mousein_signal, ec);
+   wl_signal_emit(&comp_wl->ptr_constraints.surface_mousein_signal, ec);
 }
 
 static void
@@ -1405,10 +1379,7 @@ _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob
 {
    E_Client *ec;
    Evas_Event_Mouse_Out *ev;
-   struct wl_resource *res;
    struct wl_client *wc;
-   Eina_List *l;
-   uint32_t serial;
    Eina_Bool inside_check;
    E_Comp_Wl_Data *comp_wl;
    E_Comp *comp;
@@ -1441,58 +1412,27 @@ _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob
           return;
      }
 
-   if (!eina_list_count(comp_wl->ptr.resources)) return;
+   if (e_comp_wl_input_seat_pointer_is_empty(NULL)) return;
 
    wc = wl_resource_get_client(surface);
-   serial = wl_display_next_serial(comp_wl->wl.disp);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        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(comp_wl, ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
+   e_comp_wl_seat_pointer_send_leave(NULL, wc, ec, surface);
 
-        _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_MOUSE, ev->timestamp);
-
-        wl_pointer_send_leave(res, serial, surface);
-        ec->pointer_enter_sent = EINA_FALSE;
-     }
-     wl_signal_emit(&comp_wl->ptr_constraints.surface_mouseout_signal, ec);
+   wl_signal_emit(&comp_wl->ptr_constraints.surface_mouseout_signal, ec);
 }
 
 static void
 _e_comp_wl_surface_send_touch(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, int idx, int canvas_x, int canvas_y, int client_x, int client_y, uint32_t timestamp, Eina_Bool pressed)
 {
-   Eina_List *l;
    struct wl_client *wc;
-   struct wl_resource *res;
    wl_fixed_t x, y;
-   uint32_t serial;
 
    wc = wl_resource_get_client(surface);
-   serial = wl_display_next_serial(comp_wl->wl.disp);
-
-   x = wl_fixed_from_int(canvas_x - client_x);
-   y = wl_fixed_from_int(canvas_y - client_y);
 
-   EINA_LIST_FOREACH(comp_wl->touch.resources, l, res)
-     {
-        if (wl_resource_get_client(res) != wc) continue;
-        if (!e_comp_wl_input_touch_check(res)) continue;
-        TRACE_INPUT_BEGIN(_e_comp_wl_surface_send_touch);
-        if (pressed)
-          {
-             ELOGF("Touch", "Down (id: %d, time: %d, x:%d, y:%d)", NULL, idx, timestamp, canvas_x - client_x, canvas_y - client_y);
-
-             wl_touch_send_down(res, serial, timestamp, surface, idx, x, y); //id 0 for the 1st finger
-          }
-        else
-          {
-             ELOGF("Touch", "Up (id: %d, time: %d, x:%d, y:%d)\n", NULL, idx, timestamp, canvas_x - client_x, canvas_y - client_y);
+   x = canvas_x - client_x;
+   y = canvas_y - client_y;
 
-             wl_touch_send_up(res, serial, timestamp, idx);
-          }
-        TRACE_INPUT_END();
-     }
+   e_comp_wl_seat_touch_send_downup(NULL, wc, surface, idx, x, y, timestamp, pressed);
 }
 
 static void
@@ -1527,27 +1467,6 @@ _e_comp_wl_send_touch(E_Comp_Wl_Data *comp_wl, E_Client *ec, int idx, int canvas
    e_comp_wl_touch_frame_send_ec_set(comp_wl, ec);
 }
 
-EINTERN void
-e_comp_wl_surface_send_touch_move(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, int idx, int canvas_x, int canvas_y, int client_x, int client_y, uint32_t timestamp)
-{
-   Eina_List *l;
-   struct wl_client *wc;
-   struct wl_resource *res;
-   wl_fixed_t x, y;
-
-   wc = wl_resource_get_client(surface);
-
-   x = wl_fixed_from_int(canvas_x - client_x);
-   y = wl_fixed_from_int(canvas_y - client_y);
-
-   EINA_LIST_FOREACH(comp_wl->touch.resources, l, res)
-     {
-        if (wl_resource_get_client(res) != wc) continue;
-        if (!e_comp_wl_input_touch_check(res)) continue;
-        wl_touch_send_motion(res, timestamp, idx, x, y);
-     }
-}
-
 static void
 _e_comp_wl_send_touch_move(E_Comp_Wl_Data *comp_wl, E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_t timestamp)
 {
@@ -1555,58 +1474,19 @@ _e_comp_wl_send_touch_move(E_Comp_Wl_Data *comp_wl, E_Client *ec, int idx, int c
    if (ec->cur_mouse_action) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
    if (_e_comp_wl_check_block_input(ec)) return;
+   int x, y;
+   struct wl_client *wc;
 
    struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
    if (!surface) return;
 
-   e_comp_wl_surface_send_touch_move(comp_wl, surface, idx, canvas_x, canvas_y, ec->client.x, ec->client.y, timestamp);
-
-   e_comp_wl_touch_frame_send_ec_set(comp_wl, ec);
-}
-
-static void
-_e_comp_wl_send_touch_frame(E_Comp_Wl_Data *comp_wl, E_Client *ec)
-{
-   Eina_List *l;
-   struct wl_client *wc;
-   struct wl_resource *res;
-   struct wl_resource *surface;
-
-   if (!ec) return;
-   if (e_object_is_del(E_OBJECT(ec))) return;
-   if (_e_comp_wl_check_block_input(ec)) return;
-   if (!(surface = e_comp_wl_client_surface_get(ec))) return;
-
    wc = wl_resource_get_client(surface);
+   x = canvas_x - ec->client.x;
+   y = canvas_y - ec->client.y;
 
-   EINA_LIST_FOREACH(comp_wl->touch.resources, l, res)
-     {
-        if (wl_resource_get_client(res) != wc) continue;
-        if (!e_comp_wl_input_touch_check(res)) continue;
-        wl_touch_send_frame(res);
-     }
-
-   e_comp_wl_touch_frame_send_ec_set(comp_wl, NULL);
-}
-
-EINTERN void
-e_comp_wl_surface_send_mouse_move(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, int x, int y, int client_x, int client_y, unsigned int timestamp)
-{
-   struct wl_resource *res;
-   struct wl_client *wc;
-   Eina_List *l;
-
-   if (!surface) return;
+   e_comp_wl_seat_touch_send_motion(NULL, wc, idx, x, y, timestamp);
 
-   wc = wl_resource_get_client(surface);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        if (wl_resource_get_client(res) != wc) continue;
-        wl_pointer_send_motion(res, timestamp,
-                               wl_fixed_from_int(x - client_x),
-                               wl_fixed_from_int(y - client_y));
-     }
+   e_comp_wl_touch_frame_send_ec_set(comp_wl, ec);
 }
 
 static void
@@ -1616,7 +1496,14 @@ _e_comp_wl_send_mouse_move(E_Comp_Wl_Data *comp_wl, E_Client *ec, int x, int y,
    if (ec->cur_mouse_action) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
    struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
-   e_comp_wl_surface_send_mouse_move(comp_wl, surface, x, y, ec->client.x, ec->client.y, timestamp);
+   struct wl_client *wc;
+   int sx, sy;
+
+   wc = wl_resource_get_client(surface);
+   sx = x - ec->client.x;
+   sy = y - ec->client.y;
+
+   e_comp_wl_seat_pointer_send_motion(NULL, wc, sx, sy, timestamp);
 }
 
 static void
@@ -1888,14 +1775,11 @@ finish:
 EINTERN void
 e_comp_wl_surface_mouse_wheel_send(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, int direction, int z, int timestamp)
 {
-   struct wl_resource *res;
    struct wl_client *wc;
-   Eina_List *l;
+   uint32_t axis, dir;
 
    if (!surface) return;
 
-   uint32_t axis, dir;
-
    if (direction == 0)
      axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
    else
@@ -1907,13 +1791,7 @@ e_comp_wl_surface_mouse_wheel_send(E_Comp_Wl_Data *comp_wl, struct wl_resource *
      dir = wl_fixed_from_int(z);
 
    wc = wl_resource_get_client(surface);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        if (wl_resource_get_client(res) != wc) continue;
-        ELOGF("Mouse", "Send wheel event (timestamp: %d, axis: %d, dir: %d)", NULL, timestamp, axis, dir);
-        wl_pointer_send_axis(res, timestamp, axis, dir);
-     }
+   _e_comp_wl_seat_pointer_send_axis(NULL, wc, axis, dir, timestamp);
 }
 
 static void
@@ -1941,8 +1819,8 @@ _e_comp_wl_evas_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *
    if (!surface) return;
 
    comp_wl = e_comp_wl_get();
-   if (!eina_list_count(comp_wl->ptr.resources))
-     return;
+
+   if (e_comp_wl_input_seat_pointer_is_empty(NULL)) return;
 
    if (_e_comp_wl_check_cursor_timer_needed(ec))
       {
@@ -2099,7 +1977,18 @@ _e_comp_wl_cb_touch_frame(void *data, int type, void *event)
    E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
 
    E_Client *ec = e_comp_wl_touch_frame_send_ec_get(comp_wl);
-   _e_comp_wl_send_touch_frame(comp_wl, ec);
+   struct wl_client *wc;
+   struct wl_resource *surface;
+
+   if (!(ec = data)) return ECORE_CALLBACK_PASS_ON;
+   if (e_object_is_del(E_OBJECT(ec))) return ECORE_CALLBACK_PASS_ON;
+   if (_e_comp_wl_check_block_input(ec)) return ECORE_CALLBACK_PASS_ON;
+
+   if (!(surface = e_comp_wl_client_surface_get(ec))) return ECORE_CALLBACK_PASS_ON;
+   wc = wl_resource_get_client(surface);
+   _e_comp_wl_seat_touch_send_frame(NULL, wc);
+   e_comp_wl_touch_frame_send_ec_set(comp_wl, NULL);
+
    return ECORE_CALLBACK_PASS_ON;
 }
 
@@ -4252,10 +4141,8 @@ e_comp_wl_key_process(Ecore_Event_Key *ev, E_Device *dev, int type)
 EINTERN void
 e_comp_wl_surface_mouse_button_send(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, uint32_t timestamp, uint32_t button_id, uint32_t state)
 {
-   Eina_List *l;
    struct wl_client *wc;
-   struct wl_resource *res;
-   uint32_t serial, btn;
+   uint32_t btn;
 
    switch (button_id)
      {
@@ -4265,23 +4152,10 @@ e_comp_wl_surface_mouse_button_send(E_Comp_Wl_Data *comp_wl, struct wl_resource
       default: btn = button_id;  break;
      }
 
-   comp_wl = e_comp_wl_get();
    comp_wl->ptr.button = btn;
 
    wc = wl_resource_get_client(surface);
-   serial = wl_display_next_serial(comp_wl->wl.disp);
-
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        if (wl_resource_get_client(res) != wc) continue;
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        TRACE_INPUT_BEGIN(e_comp_wl_surface_mouse_button);
-
-        ELOGF("Mouse", "Button %s (btn: %d, time: %d)", NULL, (state ? "Down" : "Up"), btn, timestamp);
-
-        wl_pointer_send_button(res, serial, timestamp, btn, state);
-        TRACE_INPUT_END();
-     }
+   e_comp_wl_seat_pointer_send_button(NULL, wc, btn, state, timestamp);
 }
 
 EINTERN Eina_Bool
@@ -4299,8 +4173,7 @@ e_comp_wl_evas_handle_mouse_button(E_Comp_Wl_Data *comp_wl, E_Client *ec, uint32
    struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
    if (!surface) return EINA_FALSE;
 
-   if (!eina_list_count(comp_wl->ptr.resources))
-     return EINA_TRUE;
+   if (e_comp_wl_input_seat_pointer_is_empty(NULL)) return EINA_FALSE;
 
    ELOGF("Mouse", "Button %s (btn: %d, time: %d)", ec, (state ? "Down" : "Up"), button_id, timestamp);
 
@@ -5022,7 +4895,6 @@ e_comp_wl_touch_send(E_Client *ec, int idx, int x, int y, Eina_Bool pressed, Eco
    E_Comp_Wl_Data *comp_wl;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
 
    comp_wl = e_comp_wl_get();
    EINA_SAFETY_ON_NULL_RETURN_VAL(comp_wl, EINA_FALSE);
@@ -5064,7 +4936,6 @@ e_comp_wl_touch_update_send(E_Client *ec, int idx, int x, int y, Ecore_Device *d
    E_Comp_Wl_Data *comp_wl;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
 
    comp_wl = e_comp_wl_get();
    EINA_SAFETY_ON_NULL_RETURN_VAL(comp_wl, EINA_FALSE);
@@ -5101,8 +4972,6 @@ EINTERN Eina_Bool
 e_comp_wl_touch_cancel_send(E_Client *ec)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl_get(), EINA_FALSE);
 
    _e_comp_wl_send_touch_cancel(ec);
 
@@ -5117,7 +4986,6 @@ e_comp_wl_mouse_button_send(E_Client *ec, int buttons, Eina_Bool pressed, Ecore_
    E_Comp_Wl_Data *comp_wl;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
 
    comp_wl = e_comp_wl_get();
    EINA_SAFETY_ON_NULL_RETURN_VAL(comp_wl, EINA_FALSE);
@@ -5150,7 +5018,6 @@ e_comp_wl_mouse_move_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_
    E_Comp_Wl_Data *comp_wl;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
 
    comp_wl = e_comp_wl_get();
    EINA_SAFETY_ON_NULL_RETURN_VAL(comp_wl, EINA_FALSE);
@@ -5181,7 +5048,6 @@ e_comp_wl_mouse_wheel_send(E_Client *ec, int direction, int z, Ecore_Device *dev
    E_Comp_Wl_Data *comp_wl;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
 
    comp_wl = e_comp_wl_get();
    EINA_SAFETY_ON_NULL_RETURN_VAL(comp_wl, EINA_FALSE);
@@ -5218,12 +5084,9 @@ e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t
 {
    uint32_t serial;
    struct wl_client *wc;
-   struct wl_resource *res;
-   Eina_List *l;
    E_Comp_Wl_Data *comp_wl;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
 
    struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
    EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
@@ -5232,22 +5095,15 @@ e_comp_wl_mouse_in_send(E_Client *ec, int x, int y, Ecore_Device *dev, uint32_t
    EINA_SAFETY_ON_NULL_RETURN_VAL(comp_wl, EINA_FALSE);
    EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
 
-   if (!eina_list_count(comp_wl->ptr.resources)) return EINA_FALSE;
+   if (e_comp_wl_input_seat_pointer_is_empty(NULL)) return EINA_FALSE;
+
    wc = wl_resource_get_client(surface);
    serial = wl_display_next_serial(comp_wl->wl.disp);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        if (wl_resource_get_client(res) != wc) continue;
 
-        if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
-        else _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_MOUSE, time);
+   if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
+   else _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_MOUSE, time);
 
-        wl_pointer_send_enter(res, serial, surface,
-                              wl_fixed_from_int(x),
-                              wl_fixed_from_int(y));
-        ec->pointer_enter_sent = EINA_TRUE;
-     }
+   e_comp_wl_seat_pointer_send_enter(NULL, wc, ec, surface, x, y);
    wl_signal_emit(&comp_wl->ptr_constraints.surface_mousein_signal, ec);
 
    return EINA_TRUE;
@@ -5258,32 +5114,24 @@ e_comp_wl_mouse_out_send(E_Client *ec, Ecore_Device *dev, uint32_t time)
 {
    uint32_t serial;
    struct wl_client *wc;
-   struct wl_resource *res;
-   Eina_List *l;
    E_Comp_Wl_Data *comp_wl;
 
    comp_wl = e_comp_wl_get();
    EINA_SAFETY_ON_NULL_RETURN_VAL(comp_wl, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
    struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
    EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
    EINA_SAFETY_ON_TRUE_RETURN_VAL(e_object_is_del(E_OBJECT(ec)), EINA_FALSE);
 
-   if (!eina_list_count(comp_wl->ptr.resources)) return EINA_FALSE;
+   if (e_comp_wl_input_seat_pointer_is_empty(NULL)) return EINA_FALSE;
+
    wc = wl_resource_get_client(surface);
    serial = wl_display_next_serial(comp_wl->wl.disp);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        if (wl_resource_get_client(res) != wc) continue;
 
-        if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
-        else _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_MOUSE, time);
+   if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
+   else _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_MOUSE, time);
 
-        wl_pointer_send_leave(res, serial, surface);
-        ec->pointer_enter_sent = EINA_FALSE;
-     }
+   e_comp_wl_seat_pointer_send_leave(NULL, wc, ec, surface);
    wl_signal_emit(&comp_wl->ptr_constraints.surface_mouseout_signal, ec);
 
    return EINA_TRUE;
@@ -5346,10 +5194,7 @@ e_comp_wl_mouse_out_renew(E_Client *ec, int buttons, int x, int y, void *data, E
 EINTERN Eina_Bool
 e_comp_wl_cursor_hide(E_Client *ec)
 {
-   struct wl_resource *res;
    struct wl_client *wc;
-   Eina_List *l;
-   uint32_t serial;
    E_Comp_Wl_Data *comp_wl;
 
    e_pointer_view_set(e_comp_pointer_get(), NULL, 0, 0);
@@ -5368,15 +5213,7 @@ e_comp_wl_cursor_hide(E_Client *ec)
    EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
 
    wc = wl_resource_get_client(surface);
-   serial = wl_display_next_serial(comp_wl->wl.disp);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        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;
-        wl_pointer_send_leave(res, serial, surface);
-        ec->pointer_enter_sent = EINA_FALSE;
-     }
+   e_comp_wl_seat_pointer_send_leave(NULL, wc, ec, surface);
 
    return EINA_TRUE;
 }
@@ -6405,3 +6242,361 @@ e_comp_wl_ptr_ec_get(void)
 
    return comp_wl->ptr.ec;
 }
+
+static void
+_e_comp_wl_seat_touch_send_cancel(E_Comp_Wl_Seat *seat, struct wl_client *wc, E_Client *ec)
+{
+   Eina_List *l, *ll;
+   struct wl_resource *res;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *s;
+
+   if (!seat) goto iterate;
+
+   EINA_LIST_FOREACH(seat->touch.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_touch_check(res)) continue;
+
+        ELOGF("Touch", "Cancel name:%20s", ec, ec ? e_client_util_name_get(ec) : "Unknown");
+
+        wl_touch_send_cancel(res);
+     }
+   return;
+
+iterate:
+   EINA_LIST_FOREACH(comp_wl->seats, l, s)
+     {
+        EINA_LIST_FOREACH(s->touch.resources, ll, res)
+          {
+             if (wl_resource_get_client(res) != wc) continue;
+             if (!e_comp_wl_input_touch_check(res)) continue;
+
+             ELOGF("Touch", "Cancel name:%20s", ec, ec ? e_client_util_name_get(ec) : "Unknown");
+
+             wl_touch_send_cancel(res);
+          }
+     }
+}
+
+static void
+_e_comp_wl_seat_touch_send_frame(E_Comp_Wl_Seat *seat, struct wl_client *wc)
+{
+   Eina_List *l, *ll;
+   struct wl_resource *res;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *s;
+
+   if (!seat) goto iterate;
+
+   EINA_LIST_FOREACH(seat->touch.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_touch_check(res)) continue;
+
+        wl_touch_send_frame(res);
+     }
+   return;
+
+iterate:
+   EINA_LIST_FOREACH(comp_wl->seats, l, s)
+   {
+     EINA_LIST_FOREACH(s->touch.resources, ll, res)
+       {
+           if (wl_resource_get_client(res) != wc) continue;
+           if (!e_comp_wl_input_touch_check(res)) continue;
+           wl_touch_send_frame(res);
+       }
+   }
+}
+
+EINTERN void
+e_comp_wl_seat_touch_send_downup(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                  struct wl_resource *surface, int idx, int x, int y, uint32_t timestamp,
+                                  Eina_Bool pressed)
+{
+   Eina_List *l, *ll;
+   struct wl_resource *res;
+   uint32_t serial;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *s;
+
+   serial = wl_display_next_serial(comp_wl->wl.disp);
+
+   if (!seat) goto iterate;
+
+   EINA_LIST_FOREACH(seat->touch.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_touch_check(res)) continue;
+
+        TRACE_INPUT_BEGIN(e_comp_wl_seat_touch_send_downup);
+        if(pressed)
+          {
+             ELOGF("Touch", "Down (id: %d, time: %d, x:%d, y:%d)", NULL, idx, timestamp, x, y);
+             wl_touch_send_down(res, serial, timestamp, surface, idx, wl_fixed_from_int(x), wl_fixed_from_int(y));
+          }
+        else
+          {
+             ELOGF("Touch", "Up (id: %d, time: %d, x:%d, y:%d)", NULL, idx, timestamp, x, y);
+             wl_touch_send_up(res, serial, timestamp, idx);
+          }
+        TRACE_INPUT_END();
+     }
+   return;
+
+iterate:
+   EINA_LIST_FOREACH(comp_wl->seats, l, s)
+     {
+        EINA_LIST_FOREACH(s->touch.resources, ll, res)
+          {
+             if (wl_resource_get_client(res) != wc) continue;
+             if (!e_comp_wl_input_touch_check(res)) continue;
+
+             TRACE_INPUT_BEGIN(e_comp_wl_seat_touch_send_downup);
+             if (pressed)
+               {
+                  ELOGF("Touch", "Down (id: %d, time: %d, x:%d, y:%d)", NULL, idx, timestamp, x, y);
+                  wl_touch_send_down(res, serial, timestamp, surface, idx, wl_fixed_from_int(x), wl_fixed_from_int(y));
+               }
+             else
+               {
+                  ELOGF("Touch", "Up (id: %d, time: %d, x:%d, y:%d)", NULL, idx, timestamp, x, y);
+                  wl_touch_send_up(res, serial, timestamp, idx);
+               }
+             TRACE_INPUT_END();
+          }
+     }
+}
+
+EINTERN void
+e_comp_wl_seat_touch_send_motion(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                 int idx, int x, int y, uint32_t timestamp)
+{
+   Eina_List *l, *ll;
+   struct wl_resource *res;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *s;
+
+   if (!seat) goto iterate;
+
+   EINA_LIST_FOREACH(seat->touch.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_touch_check(res)) continue;
+
+        wl_touch_send_motion(res, timestamp, idx, wl_fixed_from_int(x), wl_fixed_from_int(y));
+     }
+   return;
+
+iterate:
+   EINA_LIST_FOREACH(comp_wl->seats, l, s)
+     {
+        EINA_LIST_FOREACH(s->touch.resources, ll, res)
+          {
+             if (wl_resource_get_client(res) != wc) continue;
+             if (!e_comp_wl_input_touch_check(res)) continue;
+
+             wl_touch_send_motion(res, timestamp, idx, wl_fixed_from_int(x), wl_fixed_from_int(y));
+          }
+     }
+}
+
+EINTERN void
+e_comp_wl_seat_pointer_send_enter(E_Comp_Wl_Seat *seat, struct wl_client *wc, E_Client *ec,
+                                   struct wl_resource *surface, int x, int y)
+{
+   Eina_List *l, *ll;
+   struct wl_resource *res;
+   uint32_t serial;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *s;
+
+   serial = wl_display_next_serial(comp_wl->wl.disp);
+
+   if (!seat) goto iterate;
+
+   EINA_LIST_FOREACH(seat->ptr.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_pointer_check(res)) continue;
+
+        wl_pointer_send_enter(res, serial, surface,
+                              wl_fixed_from_int(x), wl_fixed_from_int(y));
+
+        if (ec)
+          ec->pointer_enter_sent = EINA_TRUE;
+     }
+   return;
+
+iterate:
+   EINA_LIST_FOREACH(comp_wl->seats, l, s)
+     {
+        EINA_LIST_FOREACH(s->ptr.resources, ll, res)
+          {
+             if (wl_resource_get_client(res) != wc) continue;
+             if (!e_comp_wl_input_pointer_check(res)) continue;
+
+             wl_pointer_send_enter(res, serial, surface,
+                                   wl_fixed_from_int(x), wl_fixed_from_int(y));
+
+             if (ec)
+               ec->pointer_enter_sent = EINA_TRUE;
+          }
+     }
+}
+
+EINTERN void
+e_comp_wl_seat_pointer_send_leave(E_Comp_Wl_Seat *seat, struct wl_client *wc, E_Client *ec,
+                                   struct wl_resource *surface)
+{
+   Eina_List *l, *ll;
+   struct wl_resource *res;
+   uint32_t serial;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *s;
+
+   serial = wl_display_next_serial(comp_wl->wl.disp);
+
+   if (!seat) goto iterate;
+
+   EINA_LIST_FOREACH(seat->ptr.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_pointer_check(res)) continue;
+        if (ec && ec->pointer_enter_sent == EINA_FALSE) continue;
+
+        wl_pointer_send_leave(res, serial, surface);
+
+        if (ec)
+          ec->pointer_enter_sent = EINA_FALSE;
+     }
+   return;
+
+iterate:
+   EINA_LIST_FOREACH(comp_wl->seats, l, s)
+     {
+        EINA_LIST_FOREACH(s->ptr.resources, ll, res)
+          {
+             if (wl_resource_get_client(res) != wc) continue;
+             if (!e_comp_wl_input_pointer_check(res)) continue;
+             if (ec && ec->pointer_enter_sent == EINA_FALSE) continue;
+
+             wl_pointer_send_leave(res, serial, surface);
+
+             if (ec)
+               ec->pointer_enter_sent = EINA_FALSE;
+          }
+     }
+}
+
+EINTERN void
+e_comp_wl_seat_pointer_send_motion(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                   int x, int y, uint32_t timestamp)
+{
+   Eina_List *l, *ll;
+   struct wl_resource *res;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *s;
+
+   if (!seat) goto iterate;
+
+   EINA_LIST_FOREACH(seat->ptr.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_pointer_check(res)) continue;
+
+        wl_pointer_send_motion(res, timestamp,
+                               wl_fixed_from_int(x),
+                               wl_fixed_from_int(y));
+     }
+   return;
+
+iterate:
+   EINA_LIST_FOREACH(comp_wl->seats, l, s)
+     {
+        EINA_LIST_FOREACH(s->ptr.resources, ll, res)
+          {
+             if (wl_resource_get_client(res) != wc) continue;
+             if (!e_comp_wl_input_pointer_check(res)) continue;
+
+             wl_pointer_send_motion(res, timestamp,
+                                    wl_fixed_from_int(x),
+                                    wl_fixed_from_int(y));
+          }
+     }
+}
+
+EINTERN void
+e_comp_wl_seat_pointer_send_button(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                   uint32_t button, uint32_t state, uint32_t timestamp)
+{
+   Eina_List *l, *ll;
+   struct wl_resource *res;
+   uint32_t serial;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *s;
+
+   serial = wl_display_next_serial(comp_wl->wl.disp);
+
+   if (!seat) goto iterate;
+
+   EINA_LIST_FOREACH(seat->ptr.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_pointer_check(res)) continue;
+
+        TRACE_INPUT_BEGIN(e_comp_wl_surface_mouse_button);
+        ELOGF("Mouse", "Button %s (btn: %d, time: %d)", NULL, (state ? "Down" : "Up"), button, timestamp);
+        wl_pointer_send_button(res, serial, timestamp,
+                               button, state);
+        TRACE_INPUT_END();
+     }
+   return;
+
+iterate:
+   EINA_LIST_FOREACH(comp_wl->seats, l, s)
+     {
+        EINA_LIST_FOREACH(s->ptr.resources, ll, res)
+          {
+             if (wl_resource_get_client(res) != wc) continue;
+             if (!e_comp_wl_input_pointer_check(res)) continue;
+
+             wl_pointer_send_button(res, serial, timestamp,
+                                    button, state);
+          }
+     }
+}
+
+static void
+_e_comp_wl_seat_pointer_send_axis(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                  uint32_t axis, uint32_t dir, uint32_t timestamp)
+{
+   Eina_List *l, *ll;
+   struct wl_resource *res;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *s;
+
+   if (!seat) goto iterate;
+
+   EINA_LIST_FOREACH(seat->ptr.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_pointer_check(res)) continue;
+
+        wl_pointer_send_axis(res, timestamp, axis, dir);
+     }
+   return;
+
+iterate:
+   EINA_LIST_FOREACH(comp_wl->seats, l, s)
+     {
+        EINA_LIST_FOREACH(s->ptr.resources, ll, res)
+          {
+             if (wl_resource_get_client(res) != wc) continue;
+             if (!e_comp_wl_input_pointer_check(res)) continue;
+
+             wl_pointer_send_axis(res, timestamp, axis, dir);
+          }
+     }
+}
index 4d7aecf00a96552b1ea141e1e809978b6d5735f8..c36fa8f1f87d58bbc0fc847b4c9c7eac7288219e 100644 (file)
@@ -966,16 +966,15 @@ _e_comp_wl_data_device_drag_finished(E_Drag *drag, E_Dnd_Drop_Type type)
 }
 
 static void
-_e_comp_wl_data_device_cb_drag_start(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, struct wl_resource *source_resource, struct wl_resource *origin_resource, struct wl_resource *icon_resource, uint32_t serial)
+_e_comp_wl_data_device_cb_drag_start(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, struct wl_resource *source_resource, struct wl_resource *origin_resource, struct wl_resource *icon_resource, uint32_t serial)
 {
    E_Comp_Wl_Data *comp_wl;
    E_Comp_Wl_Data_Source *source;
-   Eina_List *l;
-   struct wl_resource *res;
    E_Client *drag_icon_ec = NULL, *ec = NULL;
    E_Client *ec_under_pointer = NULL;
    E_Desk *desk;
    int x, y;
+   struct wl_client *wc;
 
    DBG("Data Device Drag Start");
 
@@ -1013,16 +1012,9 @@ _e_comp_wl_data_device_cb_drag_start(struct wl_client *client, struct wl_resourc
    ec = e_client_from_surface_resource(origin_resource);
    if (ec && ec->pointer_enter_sent)
      {
-        EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-          {
-             if (!e_comp_wl_input_pointer_check(res)) continue;
-             if (wl_resource_get_client(res) != client) continue;
-             if (!ec->comp_data) continue;
-
-             wl_pointer_send_leave(res, serial, e_comp_wl_client_surface_get(ec));
-          }
-
-        ec->pointer_enter_sent = EINA_FALSE;
+        wc = wl_resource_get_client(origin_resource);
+        //TODO: consider multi-seat
+        e_comp_wl_seat_pointer_send_leave(NULL, wc, ec, e_comp_wl_client_surface_get(ec));
      }
 
    evas_pointer_canvas_xy_get(e_comp_evas_get(), &x, &y);
index 407e95d4153915a6315261ff71a8f4b8ef0ec741..0e6e9811b3297b25a5be9f614b34c6950bb33c01 100644 (file)
@@ -80,26 +80,31 @@ static char *_env_e_default_xkb_opts    = NULL;
 static int constraint_last_hint_x = -1;
 static int constraint_last_hint_y = -1;
 
+static Eina_List *event_handlers = NULL;
+
 static Eina_Bool
 _e_comp_wl_input_is_position_inside_constraint_region(E_Comp_Wl_Pointer_Constraint *constraint,
                                                       wl_fixed_t fx,
                                                       wl_fixed_t fy);
 
 static void
-_e_comp_wl_input_update_seat_caps(E_Comp_Wl_Data *comp_wl, struct wl_client *wc)
+_e_comp_wl_input_update_seat_caps(E_Comp_Wl_Seat *seat, struct wl_client *wc)
 {
    Eina_List *l;
    struct wl_resource *res;
    enum wl_seat_capability caps = 0;
 
-   if (comp_wl->ptr.enabled)
+   if (!seat)
+     seat = e_comp_wl_input_seat_get("default");
+
+   if (seat->ptr.enabled)
      caps |= WL_SEAT_CAPABILITY_POINTER;
    if (e_comp_input_key->kbd.enabled)
      caps |= WL_SEAT_CAPABILITY_KEYBOARD;
-   if (comp_wl->touch.enabled)
+   if (seat->touch.enabled)
      caps |= WL_SEAT_CAPABILITY_TOUCH;
 
-   EINA_LIST_FOREACH(comp_wl->seat.resources, l, res)
+   EINA_LIST_FOREACH(seat->resources, l, res)
      {
         /* if a wc is null, send seat capability to all wl_seat resources */
         if (wc && (wl_resource_get_client(res) != wc)) continue;
@@ -165,12 +170,15 @@ _e_comp_wl_input_thread_cursor_set(void *data)
 }
 
 static void
-_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)
+_e_comp_wl_input_pointer_cb_cursor_set(struct wl_client *client, struct wl_resource *resource, uint32_t serial EINA_UNUSED, struct wl_resource *surface_resource, int32_t x, int32_t y)
 {
    E_Client *ec;
    Eina_Bool got_mouse = EINA_FALSE;
    struct wl_resource *surface;
    E_Pointer *comp_pointer = e_comp_pointer_get();
+   E_Comp_Wl_Seat *seat;
+   seat = wl_resource_get_user_data(resource);
+   if (!seat) return;
 
    E_Input_Thread_Request_EClient_Data ec_data;
    memset(&ec_data, 0, sizeof(E_Input_Thread_Request_EClient_Data));
@@ -290,11 +298,15 @@ static const struct wl_touch_interface _e_touch_interface =
 static void
 _e_comp_wl_input_cb_pointer_unbind(struct wl_resource *resource)
 {
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Data *comp_wl;
+   E_Comp_Wl_Seat *seat;
+   seat = wl_resource_get_user_data(resource);
+   if (!seat) return;
 
-   comp_wl->ptr.resources =
-     eina_list_remove(comp_wl->ptr.resources, resource);
+   seat->ptr.resources =
+     eina_list_remove(seat->ptr.resources, resource);
 
+   comp_wl = e_comp_wl_get();
    wl_signal_emit(&comp_wl->ptr_constraints.pointer_destroy_signal, resource);
 }
 
@@ -305,6 +317,9 @@ _e_comp_wl_input_cb_pointer_get(struct wl_client *client, struct wl_resource *re
    struct wl_client *ptr_client = NULL;
    E_Comp_Wl_Client_Data *cdata = NULL;
    E_Comp_Wl_Data *comp_wl;
+   E_Comp_Wl_Seat *seat;
+   seat = wl_resource_get_user_data(resource);
+   if (!seat) return;
 
    comp_wl = e_comp_wl_get();
 
@@ -314,18 +329,18 @@ _e_comp_wl_input_cb_pointer_get(struct wl_client *client, struct wl_resource *re
    if (!res)
      {
         ERR("Could not create pointer on seat %s: %m",
-            comp_wl->seat.name);
+            seat->name);
         wl_client_post_no_memory(client);
         return;
      }
 
-   comp_wl->ptr.resources =
-     eina_list_append(comp_wl->ptr.resources, res);
+   seat->ptr.resources =
+     eina_list_append(seat->ptr.resources, res);
    wl_resource_set_implementation(res, &_e_pointer_interface,
-                                  comp_wl,
+                                  seat,
                                  _e_comp_wl_input_cb_pointer_unbind);
 
-   if ((comp_wl->ptr.num_devices == 1) && comp_wl->ptr.ec && !comp_wl->ptr.ec->pointer_enter_sent && !e_config->use_cursor_timer)
+   if ((seat->ptr.num_devices == 1) && comp_wl->ptr.ec && !comp_wl->ptr.ec->pointer_enter_sent && !e_config->use_cursor_timer)
      {
         cdata = (E_Comp_Wl_Client_Data*)comp_wl->ptr.ec->comp_data;
         if (cdata && cdata->wl_surface)
@@ -507,8 +522,8 @@ _e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *r
                             wl_resource_get_version(resource), id);
    if (!res)
      {
-        ERR("Could not create keyboard on seat %s: %m",
-            comp_wl->seat.name);
+        // ERR("Could not create keyboard on seat %s: %m",
+        //     comp_wl->seat.name);
         wl_client_post_no_memory(client);
         return;
      }
@@ -562,16 +577,21 @@ _e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *r
 static void
 _e_comp_wl_input_cb_touch_unbind(struct wl_resource *resource)
 {
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
-   comp_wl->touch.resources =
-     eina_list_remove(comp_wl->touch.resources, resource);
+   E_Comp_Wl_Seat *seat;
+   seat = wl_resource_get_user_data(resource);
+   if (!seat) return;
+
+   seat->touch.resources =
+     eina_list_remove(seat->touch.resources, resource);
 }
 
 static void
 _e_comp_wl_input_cb_touch_get(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t id EINA_UNUSED)
 {
-    struct wl_resource *res;
-    E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   struct wl_resource *res;
+   E_Comp_Wl_Seat *seat;
+   seat = wl_resource_get_user_data(resource);
+   if (!seat) return;
 
     /* try to create pointer resource */
     res = wl_resource_create(client, &wl_touch_interface,
@@ -579,15 +599,15 @@ _e_comp_wl_input_cb_touch_get(struct wl_client *client EINA_UNUSED, struct wl_re
     if (!res)
       {
          ERR("Could not create touch on seat %s: %m",
-             comp_wl->seat.name);
+             seat->name);
          wl_client_post_no_memory(client);
          return;
       }
 
-    comp_wl->touch.resources =
-     eina_list_append(comp_wl->touch.resources, res);
+    seat->touch.resources =
+     eina_list_append(seat->touch.resources, res);
     wl_resource_set_implementation(res, &_e_touch_interface,
-                                   comp_wl,
+                                   seat,
                                   _e_comp_wl_input_cb_touch_unbind);
 }
 
@@ -602,19 +622,23 @@ static const struct wl_seat_interface _e_seat_interface =
 static void
 _e_comp_wl_input_cb_unbind_seat(struct wl_resource *resource)
 {
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *seat;
+   seat = wl_resource_get_user_data(resource);
+   if (!seat) return;
 
    INF("Unbind seat: %u (client: %p)", wl_resource_get_id(resource), wl_resource_get_client(resource));
 
-   comp_wl->seat.resources =
-     eina_list_remove(comp_wl->seat.resources, resource);
+   seat->resources =
+     eina_list_remove(seat->resources, resource);
 }
 
 static void
-_e_comp_wl_input_cb_bind_seat(struct wl_client *client, void *data EINA_UNUSED, uint32_t version, uint32_t id)
+_e_comp_wl_input_cb_bind_seat(struct wl_client *client, void *data, uint32_t version, uint32_t id)
 {
    struct wl_resource *res;
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *seat;
+
+   if (!(seat = data)) return;
 
    res = wl_resource_create(client, &wl_seat_interface, version, id);
    if (!res)
@@ -625,17 +649,17 @@ _e_comp_wl_input_cb_bind_seat(struct wl_client *client, void *data EINA_UNUSED,
    INF("Bind seat: %u (client: %p)", wl_resource_get_id(res), client);
 
    /* store version of seat interface for reuse in updating capabilities */
-   comp_wl->seat.version = version;
-   comp_wl->seat.resources =
-     eina_list_append(comp_wl->seat.resources, res);
+   seat->version = version;
+   seat->resources =
+     eina_list_append(seat->resources, res);
 
    wl_resource_set_implementation(res, &_e_seat_interface,
-                                  NULL,
+                                  seat,
                                   _e_comp_wl_input_cb_unbind_seat);
 
-   _e_comp_wl_input_update_seat_caps(comp_wl, client);
-   if (comp_wl->seat.version >= WL_SEAT_NAME_SINCE_VERSION)
-     wl_seat_send_name(res, comp_wl->seat.name);
+   _e_comp_wl_input_update_seat_caps(seat, client);
+   if (seat->version >= WL_SEAT_NAME_SINCE_VERSION)
+     wl_seat_send_name(res, seat->name);
 }
 
 static void
@@ -1535,14 +1559,58 @@ err_keymap_string:
    e_comp_input_key->xkb.state = NULL;
 }
 
-EINTERN Eina_Bool
-e_comp_wl_input_init(void)
+static Eina_Bool
+_e_comp_wl_input_seat_init(const char *seat_name)
 {
+   E_Comp_Wl_Seat *seat;
    E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   seat = e_comp_wl_input_seat_get(seat_name);
+   if (seat) return EINA_FALSE;
+
+   if (!(seat = E_NEW(E_Comp_Wl_Seat, 1))) return EINA_FALSE;
 
    /* set default seat name */
-   if (!comp_wl->seat.name)
-     comp_wl->seat.name = "default";
+   if (!seat_name)
+     seat->name = "default";
+   else
+     seat->name = strdup(seat_name);
+
+   /* create the global resource for input seat */
+   seat->global =
+     wl_global_create(comp_wl->wl.disp, &wl_seat_interface, 7,
+                      seat, _e_comp_wl_input_cb_bind_seat);
+   if (!seat->global)
+     {
+        ERR("Could not create global for seat: %m");
+        return EINA_FALSE;
+     }
+   seat->resources = NULL;
+
+   comp_wl->seats = eina_list_append(comp_wl->seats, seat);
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_e_comp_wl_input_cb_input_device_add(void *data, int type, void *event)
+{
+   Ecore_Event_Device_Info *e;
+   if (!(e = (Ecore_Event_Device_Info *)event)) goto end;
+
+   if (e->clas == ECORE_DEVICE_CLASS_SEAT)
+     {
+        ERR("Seat added. name: %s identifier: %s, seatname: %s", e->name, e->identifier, e->seatname);
+        _e_comp_wl_input_seat_init(e->name);
+     }
+
+end:
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+EINTERN Eina_Bool
+e_comp_wl_input_init(void)
+{
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
 
    dont_set_e_input_keymap = e_secure_getenv("NO_E_INPUT_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
    dont_use_xkb_cache = e_secure_getenv("NO_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
@@ -1561,15 +1629,7 @@ e_comp_wl_input_init(void)
    if (e_comp_input_key->kbd.repeat_rate < 0)
      atomic_store(&e_comp_input_key->kbd.repeat_rate, 25);
 
-   /* create the global resource for input seat */
-   comp_wl->seat.global =
-     wl_global_create(comp_wl->wl.disp, &wl_seat_interface, 7,
-                      comp_wl, _e_comp_wl_input_cb_bind_seat);
-   if (!comp_wl->seat.global)
-     {
-        ERR("Could not create global for seat: %m");
-        return EINA_FALSE;
-     }
+   _e_comp_wl_input_seat_init("default");
 
    /* create the global resource for relative pointer */
    comp_wl->relative_ptr.global =
@@ -1619,6 +1679,8 @@ e_comp_wl_input_init(void)
    _env_e_default_xkb_variant = e_util_env_get("E_DEFAULT_XKB_VARIANT");
    _env_e_default_xkb_opts    = e_util_env_get("E_DEFAULT_XKB_OPTIONS");
 
+   E_LIST_HANDLER_PREPEND(event_handlers, ECORE_EVENT_DEVICE_ADD, _e_comp_wl_input_cb_input_device_add, NULL);
+
    return EINA_TRUE;
 }
 
@@ -1642,10 +1704,6 @@ e_comp_wl_input_shutdown(void)
         _surface_commit_hook = NULL;
      }
 
-   /* destroy pointer resources */
-   EINA_LIST_FREE(comp_wl->ptr.resources, res)
-     wl_resource_destroy(res);
-
    /* destroy relative pointer resources */
    EINA_LIST_FREE(comp_wl->relative_ptr.resources, res)
      wl_resource_destroy(res);
@@ -1663,10 +1721,6 @@ e_comp_wl_input_shutdown(void)
      wl_resource_destroy(res);
    e_comp_input_key->kbd.resources = eina_list_free(e_comp_input_key->kbd.resources);
 
-   /* destroy touch resources */
-   EINA_LIST_FREE(comp_wl->touch.resources, res)
-     wl_resource_destroy(res);
-
    /* destroy e_comp_input_key->kbd.keys array */
    wl_array_release(&e_comp_input_key->kbd.keys);
 
@@ -1699,10 +1753,17 @@ e_comp_wl_input_shutdown(void)
      wl_global_destroy(comp_wl->ptr_constraints.global);
    comp_wl->ptr_constraints.global = NULL;
 
-   /* destroy the global seat resource */
-   if (comp_wl->seat.global)
-     wl_global_destroy(comp_wl->seat.global);
-   comp_wl->seat.global = NULL;
+  E_Comp_Wl_Seat *seat;
+  EINA_LIST_FREE(comp_wl->seats, seat)
+    {
+       EINA_LIST_FREE(seat->ptr.resources, res)
+         wl_resource_destroy(res);
+       EINA_LIST_FREE(seat->touch.resources, res)
+         wl_resource_destroy(res);
+       EINA_LIST_FREE(seat->resources, res)
+         wl_resource_destroy(res);
+       wl_global_destroy(seat->global);
+    }
 
    dont_set_e_input_keymap = EINA_FALSE;
    dont_use_xkb_cache = EINA_FALSE;
@@ -1829,18 +1890,12 @@ e_comp_wl_input_keyboard_state_update(uint32_t keycode, Eina_Bool pressed)
 }
 
 EINTERN void
-e_comp_wl_input_pointer_enabled_set(Eina_Bool enabled)
+e_comp_wl_input_pointer_enabled_set(E_Comp_Wl_Seat *seat, Eina_Bool enabled)
 {
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
-   /* check for valid compositor data */
-   if (!comp_wl)
-     {
-        ERR("No compositor data");
-        return;
-     }
+   if (!seat) return;
 
-   comp_wl->ptr.enabled = !!enabled;
-   _e_comp_wl_input_update_seat_caps(comp_wl, NULL);
+   seat->ptr.enabled = !!enabled;
+   _e_comp_wl_input_update_seat_caps(seat, NULL);
 }
 
 static void
@@ -1866,7 +1921,7 @@ e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled)
      }
 
    e_input_backend_thread_safe_call(_e_comp_wl_input_thread_cb_keyboard_enabled_set, &enabled, sizeof(Eina_Bool));
-   _e_comp_wl_input_update_seat_caps(comp_wl, NULL);
+   _e_comp_wl_input_update_seat_caps(NULL, NULL);
 }
 
 E_API Eina_Bool
@@ -2124,42 +2179,31 @@ e_comp_wl_input_keymap_keycode_repeat_set(uint32_t keycode, Eina_Bool enable)
 }
 
 EINTERN void
-e_comp_wl_input_touch_enabled_set(Eina_Bool enabled)
+e_comp_wl_input_touch_enabled_set(E_Comp_Wl_Seat *seat, Eina_Bool enabled)
 {
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
-   /* check for valid compositor data */
-   if (!comp_wl)
-     {
-        ERR("No compositor data");
-        return;
-     }
+   if (!seat) return;
 
-   comp_wl->touch.enabled = !!enabled;
-   _e_comp_wl_input_update_seat_caps(comp_wl, NULL);
+   seat->touch.enabled = !!enabled;
+   _e_comp_wl_input_update_seat_caps(seat, NULL);
 }
 
 EINTERN void
 e_comp_wl_input_seat_caps_set(unsigned int caps)
 {
    Eina_Bool need_update = EINA_FALSE;
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Comp_Wl_Seat *seat;
 
-   /* check for valid compositor data */
-   if (!comp_wl)
-     {
-        ERR("No compositor data");
-        return;
-     }
+   seat = e_comp_wl_input_seat_get("default");
 
    if (caps & E_INPUT_SEAT_POINTER)
-     comp_wl->ptr.enabled = need_update = EINA_TRUE;
+     seat->ptr.enabled = need_update = EINA_TRUE;
    if (caps & E_INPUT_SEAT_KEYBOARD)
      e_comp_input_key->kbd.enabled = need_update = EINA_TRUE;
    if (caps & E_INPUT_SEAT_TOUCH)
-     comp_wl->touch.enabled = need_update = EINA_TRUE;
+     seat->touch.enabled = need_update = EINA_TRUE;
 
    if (need_update)
-     _e_comp_wl_input_update_seat_caps(comp_wl, NULL);
+     _e_comp_wl_input_update_seat_caps(seat, NULL);
 }
 
 EINTERN Eina_Bool
@@ -2420,3 +2464,78 @@ e_comp_wl_input_kbd_resource_list_unlock()
   EINA_SAFETY_ON_NULL_RETURN(e_comp_input_key);
   g_rec_mutex_unlock(&e_comp_input_key->kbd.resources_mutex);
 }
+
+EINTERN E_Comp_Wl_Seat *
+e_comp_wl_input_seat_get(const char *name)
+{
+   Eina_List *l;
+   E_Comp_Wl_Seat *seat;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+
+   EINA_LIST_FOREACH(comp_wl->seats, l, seat)
+     {
+        if (seat->name && !strcmp(seat->name, name))
+          return seat;
+     }
+
+   return NULL;
+}
+
+EINTERN Eina_Bool
+e_comp_wl_input_seat_pointer_is_empty(E_Comp_Wl_Seat *seat)
+{
+   if (!seat) goto iterate;
+
+   if (!eina_list_count(seat->ptr.resources)) return EINA_TRUE;
+
+   return EINA_FALSE;
+
+iterate:
+   Eina_List *l;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   EINA_LIST_FOREACH(comp_wl->seats, l, seat)
+     {
+        if (eina_list_count(seat->ptr.resources))
+          return EINA_FALSE;
+     }
+   return EINA_TRUE;
+}
+
+EINTERN Eina_Bool
+e_comp_wl_input_seat_touch_is_empty(E_Comp_Wl_Seat *seat)
+{
+   if (!seat) goto iterate;
+
+   if (!eina_list_count(seat->ptr.resources)) return EINA_TRUE;
+
+   return EINA_FALSE;
+
+iterate:
+   Eina_List *l;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   EINA_LIST_FOREACH(comp_wl->seats, l, seat)
+     {
+        if (eina_list_count(seat->touch.resources))
+          return EINA_FALSE;
+     }
+   return EINA_TRUE;
+}
+
+EINTERN Eina_Bool
+e_comp_wl_input_seat_pointer_enabled_get(E_Comp_Wl_Seat *seat)
+{
+   if (!seat) goto iterate;
+
+   if (seat->ptr.enabled) return EINA_TRUE;
+
+   return EINA_FALSE;
+
+iterate:
+   Eina_List *l;
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   EINA_LIST_FOREACH(comp_wl->seats, l, seat)
+     {
+        if (seat->ptr.enabled) return EINA_TRUE;
+     }
+   return EINA_FALSE;
+}
index a47c2767dd25148da6e879bf28f0e41f72f8fc10..2135b6dba2e1101c2019f84be7fcaf1c140676df 100644 (file)
@@ -11,10 +11,10 @@ EINTERN void      e_comp_wl_input_seat_caps_set(unsigned int caps);
 EINTERN Eina_Bool e_comp_wl_input_relative_pointer_check(struct wl_resource *res);
 
 EINTERN Eina_Bool e_comp_wl_input_pointer_check(struct wl_resource *res);
-EINTERN void e_comp_wl_input_pointer_enabled_set(Eina_Bool enabled);
+EINTERN void e_comp_wl_input_pointer_enabled_set(E_Comp_Wl_Seat *seat, Eina_Bool enabled);
 
 EINTERN Eina_Bool e_comp_wl_input_touch_check(struct wl_resource *res);
-EINTERN void      e_comp_wl_input_touch_enabled_set(Eina_Bool enabled);
+EINTERN void      e_comp_wl_input_touch_enabled_set(E_Comp_Wl_Seat *seat, Eina_Bool enabled);
 
 EINTERN Eina_Bool e_comp_wl_input_keyboard_check(struct wl_resource *res);
 EINTERN Eina_Bool e_comp_wl_input_keyboard_modifiers_serialize(void);
@@ -32,4 +32,10 @@ EINTERN const char        *e_comp_wl_input_keymap_default_options_get(void);
 EINTERN void               e_comp_wl_input_keymap_keycode_repeat_set(uint32_t keycode, Eina_Bool enable);
 
 EINTERN void e_comp_wl_input_keymap_init(void);
+
+EINTERN E_Comp_Wl_Seat *e_comp_wl_input_seat_get(const char *name);
+EINTERN Eina_Bool       e_comp_wl_input_seat_pointer_is_empty(E_Comp_Wl_Seat *seat);
+EINTERN Eina_Bool       e_comp_wl_input_seat_touch_is_empty(E_Comp_Wl_Seat *seat);
+EINTERN Eina_Bool       e_comp_wl_input_seat_pointer_enabled_get(E_Comp_Wl_Seat *seat);
+
 #endif
index 68490c0e2078fe98a11d38cd5bffb123b7a569a4..8442eaeaac0c4d4b2c56d2cd03d30324479ea36b 100644 (file)
@@ -142,12 +142,10 @@ _e_comp_wl_device_input_thread_send_event_device(E_Input_Thread_Client *iec, E_D
 }
 
 static void
-_e_comp_wl_input_thread_send_mouse_in(E_Input_Thread_Client *iec, int x, int y, int client_x, int client_y, int timestamp)
+_e_comp_wl_input_thread_send_mouse_in(E_Comp_Wl_Seat *seat, E_Input_Thread_Client *iec, int x, int y, int client_x, int client_y, int timestamp)
 {
-   struct wl_resource *res;
    struct wl_client *wc;
-   Eina_List *l;
-   uint32_t serial;
+   struct wl_resource *surface;
    E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
 
    comp_wl->ptr.x = wl_fixed_from_int(x);
@@ -155,76 +153,52 @@ _e_comp_wl_input_thread_send_mouse_in(E_Input_Thread_Client *iec, int x, int y,
 
    if (!iec) return;
 
-   struct wl_resource *surface = e_input_thread_client_wl_resource_get(iec);
+   surface = e_input_thread_client_wl_resource_get(iec);
    if (!surface) return;
 
    ELOGF("Mouse", "In  (time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
          NULL, timestamp, x, y, x, y,
          e_input_thread_client_util_name_get(iec));
 
-   if (!eina_list_count(comp_wl->ptr.resources)) return;
-   wc = wl_resource_get_client(surface);
-   serial = wl_display_next_serial(comp_wl->wl.disp);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        if (wl_resource_get_client(res) != wc) continue;
-
-        ELOGF("Mouse", "call wl_pointer_send_enter", NULL);
+   if (e_comp_wl_input_seat_pointer_is_empty(NULL)) return;
 
-        wl_pointer_send_enter(res, serial, surface,
-                              wl_fixed_from_int(x - client_x),
-                              wl_fixed_from_int(y - client_y));
-
-        e_input_thread_client_pointer_enter_sent_set(iec, EINA_TRUE);
-     }
+   wc = wl_resource_get_client(surface);
+   e_comp_wl_seat_pointer_send_enter(seat, wc, NULL, surface, x - client_x, y - client_y);
+   e_input_thread_client_pointer_enter_sent_set(iec, EINA_TRUE);
 }
 
 static void
-_e_comp_wl_input_thread_send_mouse_out(E_Input_Thread_Client *iec, int timestamp)
+_e_comp_wl_input_thread_send_mouse_out(E_Comp_Wl_Seat *seat, E_Input_Thread_Client *iec, int timestamp)
 {
-   struct wl_resource *res;
    struct wl_client *wc;
-   Eina_List *l;
-   uint32_t serial;
-   E_Comp_Wl_Data *comp_wl;
+   struct wl_resource *surface;
 
    if (!iec) return;
 
-   struct wl_resource *surface = e_input_thread_client_wl_resource_get(iec);
+   surface = e_input_thread_client_wl_resource_get(iec);
    if (!surface) return;
 
    ELOGF("Mouse", "Out (time: %d, name:%20s)",
          NULL, timestamp,
          e_input_thread_client_util_name_get(iec));
 
-   comp_wl = e_comp_wl_get();
-   if (!eina_list_count(comp_wl->ptr.resources)) return;
+   if (e_comp_wl_input_seat_pointer_is_empty(NULL)) return;
 
    wc = wl_resource_get_client(surface);
-   serial = wl_display_next_serial(comp_wl->wl.disp);
-   EINA_LIST_FOREACH(comp_wl->ptr.resources, l, res)
-     {
-        if (!e_comp_wl_input_pointer_check(res)) continue;
-        if (wl_resource_get_client(res) != wc) continue;
-        if (e_input_thread_client_pointer_enter_sent_get(iec) == EINA_FALSE) continue;
-
-        wl_pointer_send_leave(res, serial, surface);
-
-        e_input_thread_client_pointer_enter_sent_set(iec, EINA_FALSE);
-     }
+   e_comp_wl_seat_pointer_send_leave(seat, wc, NULL, surface);
+   e_input_thread_client_pointer_enter_sent_set(iec, EINA_FALSE);
 }
 
 static void
-_e_comp_wl_input_thread_check_mouse_out(E_Input_Thread_Client *hit_iec, int timestamp)
+_e_comp_wl_input_thread_check_mouse_out(E_Comp_Wl_Seat *seat, E_Input_Thread_Client *hit_iec, int timestamp)
 {
    E_Input_Thread_Client *iec = NULL;
    for (iec = e_input_thread_client_top_get(); iec; iec = e_input_thread_client_below_get(iec))
      {
-        if (e_input_thread_client_mouse_in_get(iec) && iec != hit_iec)
+        if (e_input_thread_client_zone_id_get(iec) == 0 && e_input_thread_client_mouse_in_get(iec) && iec != hit_iec)
           {
              // send leave
-             _e_comp_wl_input_thread_send_mouse_out(iec, timestamp);
+             _e_comp_wl_input_thread_send_mouse_out(seat, iec, timestamp);
              e_input_thread_client_mouse_in_set(iec, EINA_FALSE);
              break;
           }
@@ -238,10 +212,13 @@ _e_comp_wl_cb_mouse_move_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED, voi
    E_Input_Thread_Client *iec;
    E_Comp_Config *comp_conf;
    E_Device *dev = NULL;
-   const char *dev_name;
+   const char *dev_name, *seat_name;
    Ecore_Device_Class dev_class;
    int client_x = 0, client_y = 0;
    E_Comp_Wl_Data *comp_wl;
+   struct wl_resource *surface;
+   struct wl_client *wc;
+   E_Comp_Wl_Seat *seat;
 
    comp_wl = e_comp_wl_get();
    comp_wl->ptr.x = wl_fixed_from_int(ev->x);
@@ -251,11 +228,15 @@ _e_comp_wl_cb_mouse_move_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED, voi
 
    if (!e_input_pointer_thread_mode_get()) return ECORE_CALLBACK_RENEW;
 
+   comp_conf = e_comp_config_get();
+
    iec = _e_comp_wl_input_thread_client_under_pointer(ev->x, ev->y);
+   if (comp_conf && comp_conf->input_log_enable)
+     ELOGF("Mouse", "Move. cursor under pointer iec: %p", NULL, iec);
    if (!iec)
      return ECORE_CALLBACK_RENEW;
 
-   struct wl_resource *surface = e_input_thread_client_wl_resource_get(iec);
+   surface = e_input_thread_client_wl_resource_get(iec);
    if (!surface)
      {
         ELOGF("Mouse", "Move. surface NULL", NULL);
@@ -265,12 +246,13 @@ _e_comp_wl_cb_mouse_move_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED, voi
    dev = (E_Device *)ev->dev;
    dev_name = e_device_name_get(dev);
    dev_class = e_device_class_get(dev);
+   seat_name = e_device_seatname_get(dev);
+   seat = e_comp_wl_input_seat_get(seat_name);
 
-   comp_conf = e_comp_config_get();
    if (comp_conf && comp_conf->input_log_enable)
-     ELOGF("Mouse", "Move (time: %d, output(%d, %d), name:%20s) (dev:%s, device class:%d)",
+     ELOGF("Mouse", "Move (time: %d, x:%d, y:%d), (name:%20s) (dev:%s, class:%d, seat:%s)",
            NULL, ev->timestamp, ev->x, ev->y,
-           e_input_thread_client_util_name_get(iec), dev_name, dev_class);
+           e_input_thread_client_util_name_get(iec), dev_name, dev_class, seat_name);
 
    if (e_input_backend_mouse_printing_needed())
      e_input_backend_mouse_timestamp_append(ev->timestamp);
@@ -278,21 +260,19 @@ _e_comp_wl_cb_mouse_move_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED, voi
    e_input_thread_client_geometry_get(iec, &client_x, &client_y, NULL, NULL);
 
    // send mouse-out event
-   _e_comp_wl_input_thread_check_mouse_out(iec, ev->timestamp);
+   _e_comp_wl_input_thread_check_mouse_out(seat, iec, ev->timestamp);
 
-   if (!e_input_thread_client_mouse_in_get(iec))
+   if (e_input_thread_client_mouse_in_get(iec) && !e_input_thread_client_mouse_in_get(iec))
      {
         e_input_thread_client_mouse_in_set(iec, EINA_TRUE);
 
         // send mouse-in event
-        _e_comp_wl_input_thread_send_mouse_in(iec, ev->x, ev->y, client_x, client_y, ev->timestamp);
+        _e_comp_wl_input_thread_send_mouse_in(seat, iec, ev->x, ev->y, client_x, client_y, ev->timestamp);
      }
 
-   // send mouse move event
-   e_comp_wl_surface_send_mouse_move(comp_wl, surface, ev->x, ev->y, client_x, client_y, ev->timestamp);
-
    e_input_thread_client_geometry_get(iec, &client_x, &client_y, NULL, NULL);
 
+   // send mouse move event
    if (dev && (dev_class == ECORE_DEVICE_CLASS_TOUCH))
      {
         if (!comp_wl->drag_client)
@@ -301,7 +281,8 @@ _e_comp_wl_cb_mouse_move_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED, voi
                {
                   _e_comp_wl_device_input_thread_send_event_device(iec, dev, ev->timestamp);
 
-                  e_comp_wl_surface_send_touch_move(comp_wl, surface, 0, ev->x, ev->y, client_x, client_y, ev->timestamp);
+                  wc = wl_resource_get_client(surface);
+                  e_comp_wl_seat_touch_send_motion(seat, wc, 0, ev->x - client_x, ev->y - client_y, ev->timestamp);
                }
           }
 
@@ -313,7 +294,8 @@ _e_comp_wl_cb_mouse_move_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED, voi
           {
              _e_comp_wl_device_input_thread_send_event_device(iec, dev, ev->timestamp);
 
-             e_comp_wl_surface_send_mouse_move(comp_wl, surface, ev->x, ev->y, client_x, client_y, ev->timestamp);
+             wc = wl_resource_get_client(surface);
+             e_comp_wl_seat_pointer_send_motion(seat, wc, ev->x - client_x, ev->y - client_y, ev->timestamp);
           }
 
         e_pointer_mouse_move(e_comp_pointer_get(), ev->x, ev->y);
@@ -323,23 +305,41 @@ err:
    return ECORE_CALLBACK_RENEW;
 }
 
+static uint32_t
+_e_comp_wl_input_thread_button_convert(uint32_t button_id)
+{
+   uint32_t btn;
+   switch (button_id)
+    {
+     case 1:  btn = BTN_LEFT;   break;
+     case 2:  btn = BTN_MIDDLE; break;
+     case 3:  btn = BTN_RIGHT;  break;
+     default: btn = button_id;  break;
+    }
+   return btn;
+}
+
 static Eina_Bool
 _e_comp_wl_cb_mouse_button_down_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED, void *event)
 {
    Ecore_Event_Mouse_Button *ev = event;
    E_Device *dev = NULL;
-   const char *dev_name = NULL;;
-   Ecore_Device_Class device_class;
+   const char *dev_name = NULL, *seat_name;
+   Ecore_Device_Class dev_class;
    E_Input_Thread_Client *iec = NULL;
    int client_x = 0, client_y = 0;
    struct wl_resource *surface = NULL;
    E_Comp_Wl_Data *comp_wl;
+   struct wl_client *wc;
+   E_Comp_Wl_Seat *seat;
+   uint32_t btn;
 
-   ELOGF("Mouse", "E Event Mouse Down (time: %d, x:%d y:%d), fixed(%d, %d)", NULL, ev->timestamp, ev->x, ev->y, wl_fixed_from_int(ev->x), wl_fixed_from_int(ev->y));
+   ELOGF("Mouse", "E Event Mouse Down (time: %d, x:%d y:%d)", NULL, ev->timestamp, ev->x, ev->y);
 
    if (!e_input_pointer_thread_mode_get()) return ECORE_CALLBACK_RENEW;
 
    iec = _e_comp_wl_input_thread_client_under_pointer(ev->x, ev->y);
+   ELOGF("Mouse", "Down. cursor under pointer iec: %p", NULL, iec);
    if (!iec)
      return ECORE_CALLBACK_RENEW;
 
@@ -354,12 +354,13 @@ _e_comp_wl_cb_mouse_button_down_thread_mode(void *d EINA_UNUSED, int t EINA_UNUS
    // send device data
    dev = (E_Device *)ev->dev;
    dev_name = e_device_name_get(dev);
+   dev_class = e_device_class_get(dev);
+   seat_name = e_device_seatname_get(dev);
+   seat = e_comp_wl_input_seat_get(seat_name);
 
-   device_class = e_device_class_get(dev);
-
-   ELOGF("Mouse", "Down (button: %d, time: %d, x:%d, y:%d, fixed_x: %d, fixed_y: %d) (dev:%s)",
-         NULL, ev->buttons, ev->timestamp, ev->x, ev->y, wl_fixed_from_int(ev->x), wl_fixed_from_int(ev->y),
-         dev_name);
+   ELOGF("Mouse", "Down (button: %d, time: %d, x:%d, y:%d) (name:%20s) (dev:%s, class:%d, seat:%s)",
+         NULL, ev->buttons, ev->timestamp, ev->x, ev->y,
+         e_input_thread_client_util_name_get(iec), dev_name, dev_class, seat_name);
 
    if (e_input_backend_mouse_printing_needed())
      e_input_backend_mouse_timestamp_append(ev->timestamp);
@@ -369,13 +370,15 @@ _e_comp_wl_cb_mouse_button_down_thread_mode(void *d EINA_UNUSED, int t EINA_UNUS
    _e_comp_wl_device_input_thread_send_event_device(iec, dev, ev->timestamp);
 
    comp_wl = e_comp_wl_get();
-   if (dev && device_class == ECORE_DEVICE_CLASS_TOUCH)
+   if (dev && dev_class == ECORE_DEVICE_CLASS_TOUCH)
      {
         if (dev_name)
-          e_comp_wl_surface_device_renew_axis(dev_name, device_class,
+          e_comp_wl_surface_device_renew_axis(dev_name, dev_class,
                                               surface, 0, ev->x, ev->y, ev->multi.pressure, ev->multi.angle);
 
-        e_comp_wl_surface_handle_mouse_button_to_touch(comp_wl, surface, ev->timestamp, ev->x, ev->y, client_x, client_y, EINA_TRUE);
+        comp_wl->ptr.button = BTN_LEFT;
+        wc = wl_resource_get_client(surface);
+        e_comp_wl_seat_touch_send_downup(seat, wc, surface, 0, ev->x - client_x, ev->y - client_y, ev->timestamp, EINA_TRUE);
 
         e_pointer_touch_move(e_comp_pointer_get(), ev->x, ev->y);
 
@@ -383,8 +386,10 @@ _e_comp_wl_cb_mouse_button_down_thread_mode(void *d EINA_UNUSED, int t EINA_UNUS
      }
    else
      {
-        ELOGF("Mouse", "button(%d)", NULL, ev->buttons);
-        e_comp_wl_surface_mouse_button_send(comp_wl, surface, ev->timestamp, ev->buttons, WL_POINTER_BUTTON_STATE_PRESSED);
+        btn = _e_comp_wl_input_thread_button_convert(ev->buttons);
+        comp_wl->ptr.button = btn;
+        wc = wl_resource_get_client(surface);
+        e_comp_wl_seat_pointer_send_button(seat, wc, btn, WL_POINTER_BUTTON_STATE_PRESSED, ev->timestamp);
 
         e_pointer_mouse_move(e_comp_pointer_get(), ev->x, ev->y);
      }
@@ -400,27 +405,33 @@ _e_comp_wl_cb_mouse_button_up_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED
 {
    Ecore_Event_Mouse_Button *ev = event;
    E_Device *dev = NULL;
-   const char *dev_name = NULL;
-   Ecore_Device_Class device_class;
+   const char *dev_name = NULL, *seat_name;
+   Ecore_Device_Class dev_class;
    E_Input_Thread_Client *iec = NULL;
    struct wl_resource *surface;
    int client_x = 0, client_y = 0;
    E_Comp_Wl_Data *comp_wl;
+   struct wl_client *wc;
+   E_Comp_Wl_Seat *seat;
+   uint32_t btn;
 
    if (!need_send_released)
      {
         need_send_motion = EINA_TRUE;
      }
 
+   ELOGF("Mouse", "E Event Mouse Up (time: %d, x:%d y:%d)", NULL, ev->timestamp, ev->x, ev->y);
+
+   if (!e_input_pointer_thread_mode_get()) return ECORE_CALLBACK_RENEW;
+
    dev = (E_Device *)ev->dev;
    dev_name = e_device_name_get(dev);
-   device_class = e_device_class_get(dev);
-
-   ELOGF("Mouse", "Up (button: %d, time: %d, x:%d, y:%d) (dev:%s)",
-         NULL, ev->buttons, ev->timestamp, ev->x, ev->y, dev_name);
+   dev_class = e_device_class_get(dev);
+   seat_name = e_device_seatname_get(dev);
+   seat = e_comp_wl_input_seat_get(seat_name);
 
    comp_wl = e_comp_wl_get();
-   if (dev && (device_class == EVAS_DEVICE_CLASS_TOUCH))
+   if (dev && (dev_class == ECORE_DEVICE_CLASS_TOUCH))
      {
         comp_wl->touch.pressed &= ~(1 << 0);
 
@@ -442,22 +453,31 @@ _e_comp_wl_cb_mouse_button_up_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED
         goto err;
      }
 
+   ELOGF("Mouse", "Up (button: %d, time: %d, x:%d, y:%d) (name:%20s) (dev:%s, class:%d, seat:%s)",
+         NULL, ev->buttons, ev->timestamp, ev->x, ev->y,
+         e_input_thread_client_util_name_get(iec), dev_name, dev_class, seat_name);
+
    if (e_input_backend_mouse_printing_needed())
      e_input_backend_mouse_timestamp_append(ev->timestamp);
 
    e_input_thread_client_geometry_get(iec, &client_x, &client_y, NULL, NULL);
 
-   if (dev && (device_class == ECORE_DEVICE_CLASS_TOUCH))
+   if (dev && (dev_class == ECORE_DEVICE_CLASS_TOUCH))
      {
         if (dev_name)
-          e_comp_wl_surface_device_handle_axes(dev_name, device_class,
+          e_comp_wl_surface_device_handle_axes(dev_name, dev_class,
                                                surface, 0, ev->x, ev->y, ev->multi.pressure, ev->multi.angle);
-        e_comp_wl_surface_handle_mouse_button_to_touch(comp_wl, surface, ev->timestamp, ev->x, ev->y, client_x, client_y, EINA_FALSE);
+        comp_wl->ptr.button = BTN_LEFT;
+        wc = wl_resource_get_client(surface);
+        e_comp_wl_seat_touch_send_downup(seat, wc, surface, 0, ev->x - client_x, ev->y - client_y, ev->timestamp, EINA_FALSE);
      }
    else
      {
-        e_comp_wl_surface_mouse_button_send(comp_wl, surface, ev->timestamp, ev->buttons,
-                                            WL_POINTER_BUTTON_STATE_RELEASED);
+        btn = _e_comp_wl_input_thread_button_convert(ev->buttons);
+        comp_wl->ptr.button = btn;
+        wc = wl_resource_get_client(surface);
+        e_comp_wl_seat_pointer_send_button(seat, wc, btn, WL_POINTER_BUTTON_STATE_RELEASED, ev->timestamp);
+
      }
 
    need_send_released = EINA_FALSE;
@@ -486,8 +506,8 @@ _e_comp_wl_cb_mouse_wheel_thread_mode(void *d EINA_UNUSED, int t EINA_UNUSED, vo
      }
 
    comp_wl = e_comp_wl_get();
-   if (!eina_list_count(comp_wl->ptr.resources))
-     return ECORE_CALLBACK_RENEW;
+
+   if (e_comp_wl_input_seat_pointer_is_empty(NULL)) return ECORE_CALLBACK_RENEW;
 
    if (e_input_backend_mouse_printing_needed())
      e_input_backend_mouse_timestamp_append(ev->timestamp);
index cb39c2a4ec25a851d20aa5ee0e1c09e68559dddb..4a6e5348dc6bbc7d0e485e13c10b4dda694cfcea 100644 (file)
@@ -105,15 +105,27 @@ EINTERN void      e_comp_wl_move_resize_shutdown(void);
 
 EINTERN void      e_comp_wl_trace_serial_debug(Eina_Bool on);
 
-EINTERN void      e_comp_wl_surface_send_mouse_move(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, int x, int y, int client_x, int client_y, unsigned int timestamp);
 EINTERN void      e_comp_wl_surface_mouse_button_send(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, uint32_t timestamp, uint32_t button_id, uint32_t state);
 EINTERN void      e_comp_wl_surface_mouse_wheel_send(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, int direction, int z, int timestamp);
 EINTERN void      e_comp_wl_surface_device_renew_axis(const char *dev_name, Evas_Device_Class dev_class, struct wl_resource *surface, unsigned int idx, double radius_x, double radius_y, double pressure, double angle);
 EINTERN void      e_comp_wl_surface_device_handle_axes(const char *dev_name, Ecore_Device_Class dev_class, struct wl_resource *surface, unsigned int idx, double radius_x, double radius_y, double pressure, double angle);
 EINTERN void      e_comp_wl_surface_handle_mouse_button_to_touch(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, uint32_t timestamp, int canvas_x, int canvas_y, int client_x, int client_y, Eina_Bool flag);
-EINTERN void      e_comp_wl_surface_send_touch_move(E_Comp_Wl_Data *comp_wl, struct wl_resource *surface, int idx, int canvas_x, int canvas_y, int client_x, int client_y, uint32_t timestamp);
 
 EINTERN E_Devicemgr_Input_Device *e_comp_wl_device_last_device_get(Ecore_Device_Class dev_class);
 EINTERN void      e_comp_wl_device_last_device_set(Ecore_Device_Class dev_class, E_Devicemgr_Input_Device *device);
 
+EINTERN void      e_comp_wl_seat_touch_send_motion(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                                   int idx, int x, int y, uint32_t timestamp);
+EINTERN void      e_comp_wl_seat_touch_send_downup(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                                   struct wl_resource *surface, int idx, int x, int y, uint32_t timestamp,
+                                                   Eina_Bool pressed);
+
+EINTERN void      e_comp_wl_seat_pointer_send_motion(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                                     int x, int y, unsigned int timestamp);
+EINTERN void      e_comp_wl_seat_pointer_send_enter(E_Comp_Wl_Seat *seat, struct wl_client *wc, E_Client *ec,
+                                                    struct wl_resource *surface, int x, int y);
+EINTERN void      e_comp_wl_seat_pointer_send_leave(E_Comp_Wl_Seat *seat, struct wl_client *wc, E_Client *ec,
+                                                    struct wl_resource *surface);
+EINTERN void      e_comp_wl_seat_pointer_send_button(E_Comp_Wl_Seat *seat, struct wl_client *wc,
+                                                     uint32_t button, uint32_t state, uint32_t timestamp);
 #endif
index 69175b1320966d22ea1316efd86647f2f8160023..05f86484f1944fa43537f9cae525deac47ae3e88 100644 (file)
@@ -2,6 +2,7 @@
 #include "e_devicemgr_intern.h"
 #include "e_input_intern.h"
 #include "e_comp_wl_intern.h"
+#include "e_comp_wl_input_intern.h"
 #include "e_client_intern.h"
 #include "e_privilege_intern.h"
 #include "e_security.h"
@@ -176,13 +177,20 @@ e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev)
    E_Tizen_Devicemgr_User_Data *device_user_data;
    struct wl_array axes;
    E_Comp_Wl_Data *comp_wl;
+   E_Comp_Wl_Seat *seat;
+
+   seat = e_comp_wl_input_seat_get(dev->seat_name);
+   if (!seat)
+     {
+        DMERR("Could not find seat by seat_name(%s)", dev->seat_name);
+        return;
+     }
 
-   /* TODO: find the seat corresponding to event */
    comp_wl = e_comp_wl_get();
    serial = wl_display_next_serial(comp_wl->wl.disp);
    wl_array_init(&axes);
 
-   EINA_LIST_FOREACH(comp_wl->seat.resources, l, seat_res)
+   EINA_LIST_FOREACH(seat->resources, l, seat_res)
      {
         wc = wl_resource_get_client(seat_res);
 
@@ -328,16 +336,21 @@ e_devicemgr_wl_touch_max_count_send(int slot, struct wl_resource *res, struct wl
      }
    else
      {
-        EINA_LIST_FOREACH(comp_wl->seat.resources, l, seat_resource)
+        E_Comp_Wl_Seat *seat;
+        Eina_List *lll;
+        EINA_LIST_FOREACH(comp_wl->seats, lll, seat)
           {
-             wc = wl_resource_get_client(seat_resource);
-
-             EINA_LIST_FOREACH(g_tizen_devicemgr->mgr_resources, ll, dev_mgr_resource)
+             EINA_LIST_FOREACH(seat->resources, l, seat_resource)
                {
-                  if (!dev_mgr_resource) continue;
-                  if (wl_resource_get_client(dev_mgr_resource) != wc) continue;
-                  if (wl_resource_get_version(dev_mgr_resource) < 4) continue;
-                  tizen_input_device_manager_send_max_touch_count(dev_mgr_resource, serial, slot, seat_resource);
+                  wc = wl_resource_get_client(seat_resource);
+
+                  EINA_LIST_FOREACH(g_tizen_devicemgr->mgr_resources, ll, dev_mgr_resource)
+                    {
+                       if (!dev_mgr_resource) continue;
+                       if (wl_resource_get_client(dev_mgr_resource) != wc) continue;
+                       if (wl_resource_get_version(dev_mgr_resource) < 4) continue;
+                       tizen_input_device_manager_send_max_touch_count(dev_mgr_resource, serial, slot, seat_resource);
+                    }
                }
           }
      }
@@ -736,63 +749,74 @@ _e_devicemgr_wl_cb_bind(struct wl_client *client, void *data, uint32_t version,
    g_tizen_devicemgr->mgr_resources = eina_list_append(g_tizen_devicemgr->mgr_resources, res);
 
    comp_wl = e_comp_wl_get();
-   EINA_LIST_FOREACH(comp_wl->seat.resources, l, seat_res)
+   E_Comp_Wl_Seat *seat;
+   Eina_List *lll;
+   EINA_LIST_FOREACH(comp_wl->seats, lll, seat)
      {
-        if (wl_resource_get_client(seat_res) != client) continue;
-
-        wl_array_init(&axes);
-        serial = wl_display_next_serial(comp_wl->wl.disp);
-
-        if (e_devicemgr->max_touch_count > 0)
+        EINA_LIST_FOREACH(seat->resources, l, seat_res)
           {
-             e_devicemgr_wl_touch_max_count_send(e_devicemgr->max_touch_count, res, seat_res);
-          }
+             if (wl_resource_get_client(seat_res) != client) continue;
 
-        g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
-        EINA_LIST_FOREACH(e_devicemgr->device_list, ll, dev)
-          {
-             device_res = wl_resource_create(client, &tizen_input_device_interface, 1, 0);
-             if (!device_res)
+             wl_array_init(&axes);
+             serial = wl_display_next_serial(comp_wl->wl.disp);
+
+             if (e_devicemgr->max_touch_count > 0)
                {
-                  DMERR("Could not create tizen_input_device resource: %m");
-                  wl_client_post_no_memory(client);
-                  g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
-                  return;
+                  e_devicemgr_wl_touch_max_count_send(e_devicemgr->max_touch_count, res, seat_res);
                }
 
-             device_user_data = E_NEW(E_Tizen_Devicemgr_User_Data, 1);
-             if (!device_user_data)
+             g_rec_mutex_lock(&e_devicemgr->device_list_mutex);
+             EINA_LIST_FOREACH(e_devicemgr->device_list, ll, dev)
                {
-                  DMERR("Failed to allocate memory for input device user data\n");
-                  wl_client_post_no_memory(client);
-                  wl_resource_destroy(device_res);
-                  g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
-                  return;
+                  seat = e_comp_wl_input_seat_get(dev->seat_name);
+                  if (!seat)
+                    {
+                      DMWRN("Could not find seat by seat_name(%s)", dev->seat_name);
+                      continue;
+                    }
+                  device_res = wl_resource_create(client, &tizen_input_device_interface, 1, 0);
+                  if (!device_res)
+                    {
+                       DMERR("Could not create tizen_input_device resource: %m");
+                       wl_client_post_no_memory(client);
+                       g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
+                       return;
+                    }
+
+                  device_user_data = E_NEW(E_Tizen_Devicemgr_User_Data, 1);
+                  if (!device_user_data)
+                    {
+                       DMERR("Failed to allocate memory for input device user data\n");
+                       wl_client_post_no_memory(client);
+                       wl_resource_destroy(device_res);
+                       g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
+                       return;
+                    }
+
+                  wl_resource_set_implementation(device_res, &_e_devicemgr_wl_device_interface, device_user_data,
+                                                 _e_devicemgr_wl_device_cb_unbind);
+
+                  device_user_data->dev = dev;
+                  device_user_data->resource = device_res;
+
+                  device_user_data->seat_res = seat_res;
+                  device_user_data->seat_destroy_listener.notify =
+                    _e_devicemgr_wl_device_cb_seat_destroy;
+                  wl_resource_add_destroy_listener(seat_res, &device_user_data->seat_destroy_listener);
+
+                  device_user_data->mgr_res = res;
+                  device_user_data->manager_destroy_listener.notify =
+                    _e_devicemgr_wl_device_cb_manager_destroy;
+                  wl_resource_add_destroy_listener(res, &device_user_data->manager_destroy_listener);
+
+                  dev->resources = eina_list_append(dev->resources, device_res);
+
+                  tizen_input_device_manager_send_device_add(res, serial, dev->identifier, device_res, seat_res);
+                  tizen_input_device_send_device_info(device_res, dev->name, dev->clas, dev->subclas, &axes);
                }
-
-             wl_resource_set_implementation(device_res, &_e_devicemgr_wl_device_interface, device_user_data,
-                                            _e_devicemgr_wl_device_cb_unbind);
-
-             device_user_data->dev = dev;
-             device_user_data->resource = device_res;
-
-             device_user_data->seat_res = seat_res;
-             device_user_data->seat_destroy_listener.notify =
-               _e_devicemgr_wl_device_cb_seat_destroy;
-             wl_resource_add_destroy_listener(seat_res, &device_user_data->seat_destroy_listener);
-
-             device_user_data->mgr_res = res;
-             device_user_data->manager_destroy_listener.notify =
-               _e_devicemgr_wl_device_cb_manager_destroy;
-             wl_resource_add_destroy_listener(res, &device_user_data->manager_destroy_listener);
-
-             dev->resources = eina_list_append(dev->resources, device_res);
-
-             tizen_input_device_manager_send_device_add(res, serial, dev->identifier, device_res, seat_res);
-             tizen_input_device_send_device_info(device_res, dev->name, dev->clas, dev->subclas, &axes);
-          }
-        g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
-     }
+             g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
+        }
+   }
 }
 
 E_Tizen_Devicemgr *
index 881c3c7bea8cf09dc823ceb7ef4274b45bda453e..2b9d4ce5447e046359db950deacf353326ef7389 100644 (file)
@@ -1,6 +1,7 @@
 #include "e_pointer_intern.h"
 #include "e_input_device_intern.h"
 #include "e_comp_wl_intern.h"
+#include "e_comp_wl_input_intern.h"
 #include "e_client_intern.h"
 #include "e_comp_canvas.h"
 #include "e_comp_wl_intern.h"
@@ -458,12 +459,11 @@ EINTERN void
 e_pointer_view_set(E_Pointer *ptr, E_View_Client *view_client, int x, int y)
 {
    Eina_Bool need_call_hide = EINA_FALSE;
-   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
 
    EINA_SAFETY_ON_NULL_RETURN(ptr);
 
    /* don't show cursor if in hidden mode */
-   if ((!e_config->show_cursor) || (!comp_wl->ptr.enabled))
+   if ((!e_config->show_cursor) || (!e_comp_wl_input_seat_pointer_enabled_get(NULL)))
      {
         if (ptr->view_client && _e_pointer_view_hide(ptr, ptr->view_client))
           _e_pointer_hook_call(E_POINTER_HOOK_HIDE, ptr);
index 6fd094bdcdadff68e4e9986424c29e5837b15f26..56785378841ad8800ccd9a1a8e50395275313824 100644 (file)
@@ -446,22 +446,27 @@ _volume_content_region_set(E_Policy_Angle_Map angle_map, Eina_Tiler *tiler)
 static struct wl_resource *
 _volume_wl_touch_resource_get(void)
 {
-   Eina_List *l;
+   Eina_List *l, *ll;
    struct wl_client *wc;
    struct wl_resource *res;
    E_Comp_Wl_Data *comp_wl;
+   E_Comp_Wl_Seat *seat;
+
    E_Comp_Wl_Client_Data *volume_cdata = e_client_cdata_get(_volume_ec);
 
    if (_volume_wl_touch) goto end;
 
    wc = wl_resource_get_client(volume_cdata->surface);
    comp_wl = e_comp_wl_get();
-   EINA_LIST_FOREACH(comp_wl->touch.resources, l, res)
+   EINA_LIST_FOREACH(comp_wl->seats, l, seat)
      {
-        if (wl_resource_get_client(res) != wc) continue;
+        EINA_LIST_FOREACH(seat->touch.resources, ll, res)
+          {
+             if (wl_resource_get_client(res) != wc) continue;
 
-        _volume_wl_touch = res;
-        goto end;
+             _volume_wl_touch = res;
+             goto end;
+          }
      }
 
 end:
index 3bd565b8436c0a56f12d11ad880bfad5c6051c96..ebbc8d9d1264a3c743416fd71d5c772c0f301816 100644 (file)
@@ -59,6 +59,7 @@ typedef struct _E_Comp_Wl_Data E_Comp_Wl_Data;
 typedef struct _E_Comp_Wl_Output E_Comp_Wl_Output;
 typedef struct _E_Comp_Wl_Intercept_Hook E_Comp_Wl_Intercept_Hook;
 typedef struct _E_Comp_Wl_Pointer_Constraint E_Comp_Wl_Pointer_Constraint;
+typedef struct _E_Comp_Wl_Seat E_Comp_Wl_Seat;
 
 typedef enum _E_Comp_Wl_Buffer_Type
 {
@@ -227,14 +228,14 @@ struct _E_Comp_Wl_Data
 
    struct
      {
-        Eina_List *resources;
+        E_DEPRECATED Eina_List *resources;
         wl_fixed_t x, y;
         wl_fixed_t grab_x, grab_y;
         uint32_t button;
         Ecore_Timer *hide_tmr;
         E_Client *ec;
-        Eina_Bool enabled : 1;
-        unsigned int num_devices;
+        E_DEPRECATED Eina_Bool enabled : 1;
+        E_DEPRECATED unsigned int num_devices;
      } ptr;
 
    struct
@@ -261,9 +262,9 @@ struct _E_Comp_Wl_Data
 
    struct
      {
-        Eina_List *resources;
-        Eina_Bool enabled : 1;
-        unsigned int num_devices;
+         Eina_List *resources;
+         E_DEPRECATED Eina_Bool enabled : 1;
+         E_DEPRECATED unsigned int num_devices;
         unsigned int pressed;
         E_Client *faked_ec;
         E_Client *frame_ec;
@@ -281,7 +282,8 @@ struct _E_Comp_Wl_Data
              struct wl_global *global;
              struct wl_resource *resource;
           } im;
-     } seat;
+     } E_DEPRECATED seat;
+   Eina_List *seats;
 
    struct
      {
@@ -532,6 +534,27 @@ struct _E_Comp_Wl_Output
    void *data;
 };
 
+struct _E_Comp_Wl_Seat
+{
+   struct wl_global *global;
+   Eina_List *resources;
+   uint32_t version;
+   char *name;
+   struct
+     {
+        Eina_List *resources;
+        Eina_Bool enabled : 1;
+        unsigned int num_devices;
+     } ptr;
+
+   struct
+     {
+        Eina_List *resources;
+        Eina_Bool enabled : 1;
+        unsigned int num_devices;
+     } touch;
+};
+
 struct _E_Comp_Wl_Hook
 {
    EINA_INLIST;