Retrieve id and runid from response
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Mon, 30 Jul 2018 12:19:09 +0000 (21:19 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Tue, 31 Jul 2018 02:14:33 +0000 (11:14 +0900)
Change-Id: Ic4b8847c38fc7c6bdbd5975033287ee34a66e8ed
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
src/window_manager.cpp

index bba7531..0eebbff 100644 (file)
@@ -716,18 +716,34 @@ void WindowManager::surface_properties(unsigned surface_id, unsigned pid)
     json_object *response;
     afb_service_call_sync("afm-main", "runners", nullptr, &response);
 
-    // pick up appid from pid from application manager
-    std::string appid;
+    // retrieve appid from pid from application manager
+    std::string appid = "";
     if(response == nullptr)
     {
         HMI_ERROR("wm", "No runners");
     }
     else
     {
+        // check appid then add it to the client
         HMI_INFO("wm", "Runners:%s", json_object_get_string(response));
+        int size = json_object_array_length(response);
+        for(int i = 0; i < size; i++)
+        {
+            json_object *j = json_object_array_get_idx(response, i);
+            const char* id = jh::getStringFromJson(j, "id");
+            int runid      = jh::getIntFromJson(j, "runid");
+            if(id && (runid > 0))
+            {
+                if(runid == pid)
+                {
+                    appid = id;
+                    break;
+                }
+            }
+        }
     }
+    json_object_put(response);
 
-    // check appid then add it to the client
     g_app_list.addFloatingSurface(appid, surface_id, pid);
 }