bdilly pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=d7b1a5dfebfee95e77c4c4f2037755b75b7be908

commit d7b1a5dfebfee95e77c4c4f2037755b75b7be908
Author: Bruno Dilly <[email protected]>
Date:   Tue Oct 4 15:19:51 2016 -0300

    ecore_wl2: add ecore event for seat name change
    
    And handle it on ecore_evas/wayland, properly
    setting the evas device names.
---
 src/lib/ecore_wl2/Ecore_Wl2.h                      |  7 +++++
 src/lib/ecore_wl2/ecore_wl2.c                      |  3 ++
 src/lib/ecore_wl2/ecore_wl2_input.c                | 29 +++++++++++++++++---
 src/lib/ecore_wl2/ecore_wl2_private.h              |  1 +
 .../engines/wayland/ecore_evas_wayland_common.c    | 32 +++++++++++++++++++++-
 5 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index 30fb5d9..19c9965 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -139,6 +139,12 @@ typedef struct _Ecore_Wl2_Event_Data_Source_Send
    int fd;
 } Ecore_Wl2_Event_Data_Source_Send;
 
+typedef struct _Ecore_Wl2_Event_Seat_Name
+{
+   Eina_Stringshare *name;
+   unsigned int id;
+} Ecore_Wl2_Event_Seat_Name;
+
 typedef enum
 {
    ECORE_WL2_SELECTION_CNP,
@@ -203,6 +209,7 @@ EAPI extern int ECORE_WL2_EVENT_DATA_SOURCE_SEND; /** 
@since 1.17 */
 EAPI extern int ECORE_WL2_EVENT_WINDOW_CONFIGURE; /** @since 1.17 */
 EAPI extern int ECORE_WL2_EVENT_SYNC_DONE; /** @since 1.17 */
 EAPI extern int ECORE_WL2_EVENT_OFFER_DATA_READY; /** @since 1.19 */
+EAPI extern int ECORE_WL2_EVENT_SEAT_NAME_CHANGED; /** @since 1.19 */
 /**
  * @file
  * @brief Ecore functions for dealing with the Wayland display protocol
diff --git a/src/lib/ecore_wl2/ecore_wl2.c b/src/lib/ecore_wl2/ecore_wl2.c
index 397f8e3..ceb6dce 100644
--- a/src/lib/ecore_wl2/ecore_wl2.c
+++ b/src/lib/ecore_wl2/ecore_wl2.c
@@ -31,6 +31,7 @@ EAPI int ECORE_WL2_EVENT_DATA_SOURCE_SEND = 0;
 EAPI int ECORE_WL2_EVENT_WINDOW_CONFIGURE = 0;
 EAPI int ECORE_WL2_EVENT_SYNC_DONE = 0;
 EAPI int ECORE_WL2_EVENT_OFFER_DATA_READY = 0;
+EAPI int ECORE_WL2_EVENT_SEAT_NAME_CHANGED = 0;
 
 EAPI int _ecore_wl2_event_window_www = -1;
 EAPI int _ecore_wl2_event_window_www_drag = -1;
@@ -89,6 +90,7 @@ ecore_wl2_init(void)
         ECORE_WL2_EVENT_WINDOW_CONFIGURE = ecore_event_type_new();
         ECORE_WL2_EVENT_SYNC_DONE = ecore_event_type_new();
         ECORE_WL2_EVENT_OFFER_DATA_READY = ecore_event_type_new();
+        ECORE_WL2_EVENT_SEAT_NAME_CHANGED = ecore_event_type_new();
         _ecore_wl2_event_window_www = ecore_event_type_new();
         _ecore_wl2_event_window_www_drag = ecore_event_type_new();
      }
@@ -140,6 +142,7 @@ ecore_wl2_shutdown(void)
    ECORE_WL2_EVENT_WINDOW_CONFIGURE = 0;
    ECORE_WL2_EVENT_SYNC_DONE = 0;
    ECORE_WL2_EVENT_OFFER_DATA_READY = 0;
+   ECORE_WL2_EVENT_SEAT_NAME_CHANGED = 0;
 
    /* shutdown Ecore_Event */
    ecore_event_shutdown();
diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c 
b/src/lib/ecore_wl2/ecore_wl2_input.c
index b89e3e1..36013fb 100644
--- a/src/lib/ecore_wl2/ecore_wl2_input.c
+++ b/src/lib/ecore_wl2/ecore_wl2_input.c
@@ -1188,11 +1188,31 @@ _seat_cb_capabilities(void *data, struct wl_seat *seat, 
enum wl_seat_capability
 }
 
 static void
-_seat_cb_name(void *data EINA_UNUSED, struct wl_seat *seat EINA_UNUSED, const 
char *name EINA_UNUSED)
+_cb_seat_event_free(void *data EINA_UNUSED, void *event)
 {
-   /* NB: No-Op as we don't care about seat name right now.
-    *
-    * This will likely change as we hash out remaining multi-seat issues */
+   Ecore_Wl2_Event_Seat_Name *ev;
+
+   ev = event;
+   eina_stringshare_del(ev->name);
+   free(ev);
+}
+
+static void
+_seat_cb_name(void *data, struct wl_seat *seat EINA_UNUSED, const char *name)
+{
+   Ecore_Wl2_Event_Seat_Name *ev;
+   Ecore_Wl2_Input *input;
+
+   input = data;
+
+   ev = calloc(1, sizeof(Ecore_Wl2_Event_Seat_Name));
+   EINA_SAFETY_ON_NULL_RETURN(ev);
+
+   ev->id = input->id;
+   ev->name = eina_stringshare_add(name);
+
+   ecore_event_add(ECORE_WL2_EVENT_SEAT_NAME_CHANGED, ev,
+                   _cb_seat_event_free, NULL);
 }
 
 static const struct wl_seat_listener _seat_listener =
@@ -1241,6 +1261,7 @@ _ecore_wl2_input_add(Ecore_Wl2_Display *display, unsigned 
int id, unsigned int v
    input = calloc(1, sizeof(Ecore_Wl2_Input));
    if (!input) return;
 
+   input->id = id;
    input->display = display;
    input->seat_version = version;
    input->repeat.rate = 0.025;
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h 
b/src/lib/ecore_wl2/ecore_wl2_private.h
index ab619aa..30f9d88 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -405,6 +405,7 @@ struct _Ecore_Wl2_Input
    Ecore_Wl2_Offer *drag, *selection;
 
    unsigned int seat_version;
+   unsigned int id;
 };
 
 typedef struct Ecore_Wl2_Event_Window_WWW
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c 
b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
index d420fb4..980531c 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
@@ -44,7 +44,7 @@ EVAS_SMART_SUBCLASS_NEW(_smart_frame_type, 
_ecore_evas_wl_frame,
 
 /* local variables */
 static int _ecore_evas_wl_init_count = 0;
-static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[10];
+static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[11];
 
 static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location);
 
@@ -535,6 +535,33 @@ _ecore_evas_wl_common_cb_global_removed(void *d 
EINA_UNUSED, int t EINA_UNUSED,
    return ECORE_CALLBACK_PASS_ON;
 }
 
+static Eina_Bool
+_ecore_evas_wl_common_cb_seat_name_changed(void *d EINA_UNUSED, int t 
EINA_UNUSED, void *event)
+{
+   Ecore_Wl2_Event_Seat_Name *ev = event;
+   Ecore_Evas *ee;
+   Eina_List *l, *ll;
+
+   EINA_LIST_FOREACH(ee_list, l, ee)
+     {
+        Ecore_Evas_Engine_Wl_Data *wdata;
+        EE_Wl_Device *device;
+
+        wdata = ee->engine.data;
+
+        EINA_LIST_FOREACH(wdata->devices_list, ll, device)
+          {
+             if (device->id == ev->id)
+               {
+                  evas_device_name_set(device->seat, ev->name);
+                  break;
+               }
+          }
+     }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 int
 _ecore_evas_wl_common_init(void)
 {
@@ -573,6 +600,9 @@ _ecore_evas_wl_common_init(void)
    _ecore_evas_wl_event_hdls[9] =
      ecore_event_handler_add(ECORE_WL2_EVENT_GLOBAL_REMOVED,
                              _ecore_evas_wl_common_cb_global_removed, NULL);
+   _ecore_evas_wl_event_hdls[10] =
+     ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_NAME_CHANGED,
+                             _ecore_evas_wl_common_cb_seat_name_changed, NULL);
 
    ecore_event_evas_init();
 

-- 


Reply via email to