Bug Fix 1 : Enable split.sub invisible when tap shortcut key
[apps/agl-service-windowmanager.git] / src / app.cpp
index 0c89804..0976a19 100644 (file)
@@ -1112,46 +1112,56 @@ WMError App::visibilityChange(const WMAction &action)
 WMError App::changeCurrentState(unsigned req_num)
 {
     HMI_SEQ_DEBUG(req_num, "Change current layout status");
-    bool found = false;
-    auto actions = g_app_list.getActions(req_num, &found);
-    if(!found)
+    bool trigger_found = false, action_found = false;
+    auto trigger = g_app_list.getRequest(req_num, &trigger_found);
+    auto actions = g_app_list.getActions(req_num, &action_found);
+    //auto client = g_app_list.lookUpClient(trigger.appid);
+    //auto pCurState = *this->layers.get_layout_state((int)client->surfaceID(trigger.role));
+    //pCurState = state;
+    if (!trigger_found || !action_found)
     {
         HMI_SEQ_ERROR(req_num, "Action not found");
         return WMError::LAYOUT_CHANGE_FAIL;
     }
 
-    struct LayoutState state;
-    std::vector<std::string> areas;
-    bool state_change = false;
+    // Layout state reset
+    struct LayoutState reset_state{-1, -1};
+    HMI_SEQ_DEBUG(req_num."Reset layout state");
+    for (const auto &action : actions)
+    {
+        auto client = g_app_list.lookUpClient(trigger.appid);
+        auto pCurState = *this->layers.get_layout_state((int)client->surfaceID(trigger.role));
+        *pCurState = reset_state;
+    }
 
     for(const auto &action : actions)
     {
+        auto client = g_app_list.lookUpClient(action.appid);
+        auto pLayerCurState = *this->layers.get_layout_state((int)client->surfaceID(trigger.role));
+        int surface = -1;
         if(action.visible != TaskVisible::INVISIBLE)
+        {
+            surface = (int)client->surfaceID(action.role);
+        }
+        if (action.visible != TaskVisible::INVISIBLE)
         {
             // visible == true -> layout changes
-            areas.push_back(action.area);
-            auto client = g_app_list.lookUpClient(action.appid);
             if(action.area == "normal.full" || action.area == "split.main")
             {
-                state.main = (int)client->surfaceID(action.role);
+                pLayerCurState->main = surface;
             }
             else if(action.role == "split.sub")
             {
-                state.sub = (int)client->surfaceID(action.role);
+                pLayerCurState->sub = surface;
+            }
+            else
+            {
+                // normalfull
+                pLayerCurState->main = surface;
             }
-            state_change = true;
         }
     }
 
-    if(state_change)
-    {
-        auto trigger = g_app_list.getRequest(req_num, &found);
-        auto client = g_app_list.lookUpClient(trigger.appid);
-        auto pCurState = *this->layers.get_layout_state((int)client->surfaceID(trigger.role));
-        struct LayoutState &curState = *pCurState;
-        curState = state;
-    }
-
     return WMError::SUCCESS;
 }