device: check seat resource when send device_remove 54/88954/1
authorDuna Oh <duna.oh@samsung.com>
Wed, 21 Sep 2016 07:46:14 +0000 (16:46 +0900)
committerDuna Oh <duna.oh@samsung.com>
Wed, 21 Sep 2016 07:46:38 +0000 (16:46 +0900)
Signed-off-by: Duna Oh <duna.oh@samsung.com>
Change-Id: Ie71a51283e98427fb1f68d7f85683e5934b96f91

src/e_devicemgr_device.c
src/e_devicemgr_device.h

index d93f9be7cd99d7e406b3fa068be5066496af2802..c4de8d13ce7e701f0d0cb954cc572f8a3bbbaecd 100644 (file)
@@ -143,6 +143,8 @@ _e_devicemgr_del_device(const char *name, const char *identifier, const char *se
                   if (!device_user_data) continue;
                   if (device_user_data->dev_mgr_res != dev_mgr_res)
                     continue;
+                  if (device_user_data->seat_res != seat_res)
+                    continue;
 
                   tizen_input_device_manager_send_device_remove(dev_mgr_res, serial, dev->identifier, res, seat_res);
                }
@@ -156,6 +158,7 @@ _e_devicemgr_del_device(const char *name, const char *identifier, const char *se
           {
              device_user_data->dev = NULL;
              device_user_data->dev_mgr_res = NULL;
+             device_user_data->seat_res = NULL;
              E_FREE(device_user_data);
           }
 
@@ -183,6 +186,7 @@ _e_devicemgr_device_cb_device_unbind(struct wl_resource *resource)
 
    device_user_data->dev = NULL;
    device_user_data->dev_mgr_res = NULL;
+   device_user_data->seat_res = NULL;
    E_FREE(device_user_data);
 
    if (!dev) return;
@@ -255,6 +259,7 @@ _e_devicemgr_add_device(const char *name, const char *identifier, const char *se
                }
              device_user_data->dev = dev;
              device_user_data->dev_mgr_res = dev_mgr_res;
+             device_user_data->seat_res = seat_res;
 
              dev->resources = eina_list_append(dev->resources, res);
              wl_resource_set_implementation(res, &_e_devicemgr_device_interface, device_user_data,
@@ -1226,41 +1231,38 @@ _e_devicemgr_device_mgr_cb_bind(struct wl_client *client, void *data, uint32_t v
                                  _e_devicemgr_device_mgr_cb_unbind);
 
    EINA_LIST_FOREACH(e_comp_wl->seat.resources, l, seat_res)
-     if (wl_resource_get_client(seat_res) == client) break;
-
-   if (!seat_res)
      {
-        DMERR("Could not find seat resource bound to the tizen_input_device_manager");
-        return;
-     }
+        if (wl_resource_get_client(seat_res) != client) continue;
 
-   wl_array_init(&axes);
-   serial = wl_display_next_serial(e_comp_wl->wl.disp);
+        wl_array_init(&axes);
+        serial = wl_display_next_serial(e_comp_wl->wl.disp);
 
-   EINA_LIST_FOREACH(e_comp_wl->input_device_manager.device_list, l, dev)
-     {
-        device_res = wl_resource_create(client, &tizen_input_device_interface, 1, 0);
-        if (!device_res)
-          {
-             DMERR("Could not create tizen_input_device resource: %m");
-             return;
-          }
-        device_user_data = E_NEW(e_devicemgr_input_device_user_data, 1);
-        if (!device_user_data)
+        EINA_LIST_FOREACH(e_comp_wl->input_device_manager.device_list, l, dev)
           {
-             DMERR("Failed to allocate memory for input device user data\n");
-             return;
-          }
-        device_user_data->dev = dev;
-        device_user_data->dev_mgr_res = res;
+             device_res = wl_resource_create(client, &tizen_input_device_interface, 1, 0);
+             if (!device_res)
+               {
+                  DMERR("Could not create tizen_input_device resource: %m");
+                  return;
+               }
+             device_user_data = E_NEW(e_devicemgr_input_device_user_data, 1);
+             if (!device_user_data)
+               {
+                  DMERR("Failed to allocate memory for input device user data\n");
+                  return;
+               }
+             device_user_data->dev = dev;
+             device_user_data->dev_mgr_res = res;
+             device_user_data->seat_res = seat_res;
 
-        dev->resources = eina_list_append(dev->resources, device_res);
+             dev->resources = eina_list_append(dev->resources, device_res);
 
-        wl_resource_set_implementation(device_res, &_e_devicemgr_device_interface, device_user_data,
-                                      _e_devicemgr_device_cb_device_unbind);
+             wl_resource_set_implementation(device_res, &_e_devicemgr_device_interface, device_user_data,
+                                            _e_devicemgr_device_cb_device_unbind);
 
-        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, TIZEN_INPUT_DEVICE_SUBCLAS_NONE, &axes);
+             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, TIZEN_INPUT_DEVICE_SUBCLAS_NONE, &axes);
+          }
      }
 }
 
@@ -1338,6 +1340,7 @@ e_devicemgr_device_fini(void)
                {
                   device_user_data->dev = NULL;
                   device_user_data->dev_mgr_res = NULL;
+                  device_user_data->seat_res = NULL;
                   E_FREE(device_user_data);
                }
 
index 5017198985fd3776ed4bfc189045e75b694a9b4b..a7972f1339fdfc546a9e437246503e690bec8582 100644 (file)
@@ -45,6 +45,7 @@ struct _e_devicemgr_input_device_user_data
 {
    E_Comp_Wl_Input_Device *dev;
    struct wl_resource *dev_mgr_res;
+   struct wl_resource *seat_res;
 };
 
 struct _e_devicemgr_input_devmgr_data