ecore/evas_device: update device info if subclas is changed 07/189407/4
authorJengHyun Kang <jhyuni.kang@samsung.com>
Mon, 17 Sep 2018 10:58:58 +0000 (19:58 +0900)
committerJeongHyun Kang <jhyuni.kang@samsung.com>
Tue, 18 Sep 2018 05:47:51 +0000 (05:47 +0000)
Change-Id: I25412cb72df663aab605b41e21b5fb29c5480acd

src/lib/ecore_input/Ecore_Input.h
src/lib/ecore_input/ecore_input.c
src/lib/ecore_input_evas/ecore_input_evas.c
src/lib/ecore_wl2/ecore_wl2_input.c

index 03cc4f1..9fc979f 100644 (file)
@@ -66,6 +66,9 @@ extern "C" {
    EAPI extern int ECORE_EVENT_DEVICE_ADD;
    EAPI extern int ECORE_EVENT_DEVICE_DEL;
    //
+   // TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+   EAPI extern int ECORE_EVENT_DEVICE_SUBCLASS_UPDATE;
+   //
 
 #define ECORE_EVENT_MODIFIER_SHIFT      0x0001
 #define ECORE_EVENT_MODIFIER_CTRL       0x0002
@@ -100,6 +103,9 @@ extern "C" {
    // TIZEN_ONLY(20171206): add dummy functions for ecore_device API
    typedef struct _Ecore_Event_Device_Info  Ecore_Event_Device_Info;
    //
+   // TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+   typedef struct _Ecore_Event_Device_Update Ecore_Event_Device_Update;
+   //
 
    /**
     * @typedef Ecore_Event_Modifier
@@ -161,6 +167,13 @@ extern "C" {
         Ecore_Device_Subclass subclas;
      };
    //
+   // TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+   struct _Ecore_Event_Device_Update
+     {
+        Ecore_Window window;
+        Ecore_Device *dev;
+     };
+   //
 
    /**
     * @struct _Ecore_Event_Joystic_Button
index d581760..8382eab 100644 (file)
@@ -31,6 +31,9 @@ EAPI int ECORE_EVENT_JOYSTICK = 0;
 // TIZEN_ONLY(20171109): support a tizen_input_device_manager interface
 EAPI int ECORE_EVENT_DETENT_ROTATE = 0;
 //
+// TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+EAPI int ECORE_EVENT_DEVICE_SUBCLASS_UPDATE = 0;
+//
 
 
 static int _ecore_event_init_count = 0;
@@ -72,6 +75,9 @@ ecore_event_init(void)
    ECORE_EVENT_DEVICE_ADD = ecore_event_type_new();
    ECORE_EVENT_DEVICE_DEL = ecore_event_type_new();
    //
+   // TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+   ECORE_EVENT_DEVICE_SUBCLASS_UPDATE = ecore_event_type_new();
+   //
 
    //TIZEN_ONLY(20170307) Remove warning message
    #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -105,7 +111,10 @@ ecore_event_shutdown(void)
                           //
                           // TIZEN_ONLY(20180118): support a Ecore_Device
                           ECORE_EVENT_DEVICE_ADD,
-                          ECORE_EVENT_DEVICE_DEL
+                          ECORE_EVENT_DEVICE_DEL,
+                          //
+                          // TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+                          ECORE_EVENT_DEVICE_SUBCLASS_UPDATE
                           //
                           );
    //TIZEN_ONLY(20170307) Remove warning message
index e9d3bda..ce02fc2 100644 (file)
@@ -61,7 +61,7 @@ struct _Ecore_Input_Last
 };
 
 static int _ecore_event_evas_init_count = 0;
-static Ecore_Event_Handler *ecore_event_evas_handlers[10];
+static Ecore_Event_Handler *ecore_event_evas_handlers[11];
 static Eina_Hash *_window_hash = NULL;
 
 static Eina_List *_last_events = NULL;
@@ -999,6 +999,55 @@ ecore_event_evas_axis_update(void *data EINA_UNUSED, int type EINA_UNUSED, void
    return ECORE_CALLBACK_PASS_ON;
 }
 
+// TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+static void
+_ecore_event_evas_device_update(Evas *e, const char *name EINA_UNUSED, const char *identifier, Ecore_Device_Class clas, Ecore_Device_Subclass subclas)
+{
+   const Eina_List *dev_list = NULL;
+   const Eina_List *l;
+   Evas_Device *edev = NULL;
+   char *edev_identifier;
+
+   dev_list = evas_device_list(e, NULL);
+   if (dev_list)
+     {
+        EINA_LIST_FOREACH(dev_list, l, edev)
+          {
+             edev_identifier = (char *)evas_device_description_get(edev);
+             if (!edev_identifier) continue;
+             if ((evas_device_class_get(edev) == (Evas_Device_Class)clas) &&
+                 _ecore_event_evas_strcmp(edev_identifier, identifier))
+               {
+                  evas_device_subclass_set(edev, (Evas_Device_Subclass)subclas);
+                  break;
+               }
+          }
+     }
+}
+
+
+EAPI Eina_Bool
+ecore_event_evas_device_update(void *data EINA_UNUSED, int type, void *event)
+{
+   Ecore_Event_Device_Update *e = (Ecore_Event_Device_Update *)event;
+   Ecore_Input_Window *lookup;
+
+   lookup = _ecore_event_window_match(e->window);
+   if (!lookup) return ECORE_CALLBACK_PASS_ON;
+
+   if (type == ECORE_EVENT_DEVICE_SUBCLASS_UPDATE)
+     {
+        _ecore_event_evas_device_update(lookup->evas,
+                                        ecore_device_name_get(e->dev),
+                                        ecore_device_identifier_get(e->dev),
+                                        ecore_device_class_get(e->dev),
+                                        ecore_device_subclass_get(e->dev));
+     }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+//
+
 EAPI int
 ecore_event_evas_init(void)
 {
@@ -1053,6 +1102,11 @@ ecore_event_evas_init(void)
    ecore_event_evas_handlers[9] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL,
                                                           ecore_event_evas_mouse_button_cancel,
                                                           NULL);
+   // TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+   ecore_event_evas_handlers[10] = ecore_event_handler_add(ECORE_EVENT_DEVICE_SUBCLASS_UPDATE,
+                                                          ecore_event_evas_device_update,
+                                                          NULL);
+   //
 
    _window_hash = eina_hash_pointer_new(free);
 
index 25fe712..c5c9348 100644 (file)
@@ -3105,6 +3105,52 @@ _ecore_wl2_input_device_info_send(Ecore_Window win_id, const char *name,  const
      ecore_event_add(ECORE_EVENT_DEVICE_DEL, e, _ecore_wl2_input_device_info_free, NULL);
 }
 
+// TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+static void
+_ecore_wl2_input_device_update_send(Ecore_Window win, Ecore_Device *dev)
+{
+   Ecore_Event_Device_Update *ev;
+
+   ev = (Ecore_Event_Device_Update *)calloc(sizeof(Ecore_Event_Device_Update), 1);
+   EINA_SAFETY_ON_NULL_RETURN(ev);
+
+   ev->window = win;
+   ev->dev = dev;
+   ecore_event_add(ECORE_EVENT_DEVICE_SUBCLASS_UPDATE, ev, NULL, NULL);
+}
+
+
+static void
+_ecore_wl2_input_device_ecore_device_update(Ecore_Device *dev, Ecore_Device_Subclass subclas)
+{
+   Eina_Hash *windows;
+   Eina_Iterator *itr;
+   Ecore_Wl2_Window *win = NULL;
+   void *data;
+   Eina_Bool has_win = EINA_FALSE;
+
+   ecore_device_subclass_set(dev, subclas);
+
+   windows = _ecore_wl2_window_hash_get();
+   if (windows)
+     {
+        itr = eina_hash_iterator_data_new(windows);
+        while (eina_iterator_next(itr, &data))
+          {
+             win = data;
+             has_win = EINA_TRUE;
+             _ecore_wl2_input_device_update_send(win->id, dev);
+          }
+
+        eina_iterator_free(itr);
+     }
+   if (!has_win)
+     {
+        _ecore_wl2_input_device_update_send((uintptr_t)NULL, dev);
+     }
+}
+//
+
 static Eina_Bool
 _ecore_wl2_input_device_ecore_device_add(Ecore_Wl2_Tizen_Input_Device *dev)
 {
@@ -3119,7 +3165,12 @@ _ecore_wl2_input_device_ecore_device_add(Ecore_Wl2_Tizen_Input_Device *dev)
         ecdev_name = ecore_device_identifier_get(ecdev);
         if (!ecdev_name) continue;
         if ((ecore_device_class_get(ecdev) == dev->clas) && (!strcmp(ecdev_name, dev->identifier)))
-          return EINA_FALSE;
+          {
+             // TIZEN_ONLY(20180917): ecore/evas_device: update device info if subclas is changed
+             _ecore_wl2_input_device_ecore_device_update(ecdev, dev->subclas);
+             //
+             return EINA_FALSE;
+          }
      }
 
    ecdev = ecore_device_add();