ecore_wl: unset last_device when last_device is removed 70/85270/3
authorDuna Oh <duna.oh@samsung.com>
Wed, 24 Aug 2016 10:00:31 +0000 (19:00 +0900)
committerDuna Oh <duna.oh@samsung.com>
Wed, 24 Aug 2016 23:04:07 +0000 (08:04 +0900)
Change-Id: I04fea32ac170f37a5d795e6ec26ae3010424914a
Signed-off-by: Duna Oh <duna.oh@samsung.com>
src/lib/ecore_wayland/ecore_wl_input.c

index e27c60e..ba75925 100644 (file)
@@ -2166,6 +2166,57 @@ _ecore_wl_input_device_info_broadcast(const char *name, const char *identifier,
    eina_iterator_free(itr);
 }
 
+static void
+_ecore_wl_input_device_last_device_set(Ecore_Wl_Input_Device *dev)
+{
+   Ecore_Wl_Input *input = _ecore_wl_disp->input;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   if (!input) return;
+
+   switch(dev->clas)
+     {
+      case ECORE_DEVICE_CLASS_MOUSE:
+         input->last_device_ptr = dev;
+         break;
+      case ECORE_DEVICE_CLASS_KEYBOARD:
+         input->last_device_kbd = dev;
+         break;
+      case ECORE_DEVICE_CLASS_TOUCH:
+         input->last_device_touch = dev;
+         break;
+      default:
+         break;
+     }
+}
+
+static void
+_ecore_wl_input_device_last_device_unset(Ecore_Wl_Input_Device *dev)
+{
+   Ecore_Wl_Input *input = _ecore_wl_disp->input;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   if (!input) return;
+
+   switch(dev->clas)
+     {
+      case ECORE_DEVICE_CLASS_MOUSE:
+         if (input->last_device_ptr == dev)
+           input->last_device_ptr = NULL;
+         break;
+      case ECORE_DEVICE_CLASS_KEYBOARD:
+         if (input->last_device_kbd == dev)
+           input->last_device_kbd = NULL;
+         break;
+      case ECORE_DEVICE_CLASS_TOUCH:
+         if (input->last_device_touch == dev)
+           input->last_device_touch = NULL;
+         break;
+      default:
+         break;
+     }
+}
+
 void
 _ecore_wl_input_devices_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win)
 {
@@ -2235,6 +2286,8 @@ _ecore_wl_input_device_manager_cb_device_remove(void *data EINA_UNUSED, struct t
           {
              _ecore_wl_input_device_info_broadcast(dev->name, dev->identifier, dev->clas, EINA_FALSE);
 
+             _ecore_wl_input_device_last_device_unset(dev);
+
              if (dev->tz_device) tizen_input_device_release(dev->tz_device);
              if (dev->name) eina_stringshare_del(dev->name);
              if (dev->identifier) eina_stringshare_del(dev->identifier);
@@ -2274,30 +2327,6 @@ _ecore_wl_input_device_cb_device_info(void *data, struct tizen_input_device *tiz
 }
 
 static void
-_ecore_wl_input_device_last_device_set(Ecore_Wl_Input_Device *dev)
-{
-   Ecore_Wl_Input *input = _ecore_wl_disp->input;
-
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-   if (!input) return;
-
-   switch(dev->clas)
-     {
-      case ECORE_DEVICE_CLASS_MOUSE:
-         input->last_device_ptr = dev;
-         break;
-      case ECORE_DEVICE_CLASS_KEYBOARD:
-         input->last_device_kbd = dev;
-         break;
-      case ECORE_DEVICE_CLASS_TOUCH:
-         input->last_device_touch = dev;
-         break;
-      default:
-         break;
-     }
-}
-
-static void
 _ecore_wl_input_device_cb_event_device(void *data, struct tizen_input_device *tizen_input_device EINA_UNUSED, unsigned int serial EINA_UNUSED, const char *name EINA_UNUSED, uint32_t time EINA_UNUSED)
 {
    Ecore_Wl_Input *input = _ecore_wl_disp->input;