Remove config source
[apps/agl-service-windowmanager.git] / src / app.cpp
index ba64671..8ff0c17 100644 (file)
@@ -160,17 +160,26 @@ App::App(wl::display *d)
       display{d},
       controller{},
       outputs(),
-      config(),
       layers(),
       id_alloc{},
-      pending_events(false),
-      policy{}
+      pending_events(false)
 {
+    char const *path_layers_json = getenv("AFM_APP_INSTALL_DIR");
+    std::string path;
+    if (!path_layers_json)
+    {
+        HMI_ERROR("wm", "AFM_APP_INSTALL_DIR is not defined");
+        path = std::string(path_layers_json);
+    }
+    else
+    {
+        path = std::string(path_layers_json) + std::string("/etc/layers.json");
+    }
+
     try
     {
         {
-            auto l = load_layer_map(
-                this->config.get_string("layers.json").value().c_str());
+            auto l = load_layer_map(path.c_str());
             if (l.is_ok())
             {
                 this->layers = l.unwrap();
@@ -422,105 +431,6 @@ void App::stopTimer()
     }
 }
 
-WMError App::lm_release(const struct WMAction &action)
-{
-    //auto const &surface_id = this->lookup_id(drawing_name);
-    WMError ret = WMError::LAYOUT_CHANGE_FAIL;
-    unsigned req_num = g_app_list.currentRequestNumber();
-    auto const &surface_id = this->lookup_id(action.role.c_str());
-    if (!surface_id)
-    {
-        HMI_SEQ_ERROR(req_num, "Surface does not exist");
-        return ret;
-    }
-
-    if (*surface_id == this->layers.main_surface)
-    {
-        HMI_SEQ_ERROR(req_num, "Cannot deactivate main_surface");
-        return ret;
-    }
-
-    auto o_state = *this->layers.get_layout_state(*surface_id);
-
-    if (o_state == nullptr)
-    {
-        HMI_SEQ_ERROR(req_num, "Could not find layer for surface");
-        return ret;
-    }
-
-    struct LayoutState &state = *o_state;
-
-    if (state.main == -1)
-    {
-        HMI_SEQ_ERROR(req_num, "No surface active");
-        return ret;
-    }
-
-    // Check against main_surface, main_surface_name is the configuration item.
-    if (*surface_id == this->layers.main_surface)
-    {
-        HMI_SEQ_DEBUG(req_num, "Refusing to deactivate main_surface %d", *surface_id);
-        //reply(nullptr);
-        return WMError::SUCCESS;
-    }
-    if ((state.main == *surface_id) && (state.sub == *surface_id))
-    {
-        HMI_SEQ_ERROR(req_num, "Surface is not active");
-        return ret;
-    }
-
-    if (state.main == *surface_id)
-    {
-        if (state.sub != -1)
-        {
-            this->try_layout(
-                state, LayoutState{state.sub, -1}, [&](LayoutState const &nl) {
-                    std::string sub = std::move(*this->lookup_name(state.sub));
-
-                    this->deactivate(*surface_id);
-                    this->surface_set_layout(state.sub);
-                    state = nl;
-
-                    this->layout_commit();
-                    std::string str_area =
-                        std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
-                    compositor::rect area_rect = this->area_info[state.sub];
-                    this->emit_syncdraw(sub.c_str(), str_area.c_str(),
-                                        area_rect.x, area_rect.y, area_rect.w, area_rect.h);
-                    this->enqueue_flushdraw(state.sub);
-                });
-        }
-        else
-        {
-            this->try_layout(state, LayoutState{-1, -1}, [&](LayoutState const &nl) {
-                this->deactivate(*surface_id);
-                state = nl;
-                this->layout_commit();
-            });
-        }
-    }
-    else if (state.sub == *surface_id)
-    {
-        this->try_layout(
-            state, LayoutState{state.main, -1}, [&](LayoutState const &nl) {
-                std::string main = std::move(*this->lookup_name(state.main));
-
-                this->deactivate(*surface_id);
-                this->surface_set_layout(state.main);
-                state = nl;
-
-                this->layout_commit();
-                std::string str_area =
-                    std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
-                compositor::rect area_rect = this->area_info[state.main];
-                this->emit_syncdraw(main.c_str(), str_area.c_str(),
-                            area_rect.x, area_rect.y, area_rect.w, area_rect.h);
-                this->enqueue_flushdraw(state.main);
-            });
-    }
-    return WMError::SUCCESS;
-}
-
 WMError App::doTransition(unsigned req_num)
 {
     HMI_SEQ_DEBUG(req_num, "check policy");
@@ -748,15 +658,6 @@ WMError App::setInvisibleTask(const std::string &role, bool split)
     if (state.main == -1)
     {
         HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
-        //state = LayoutState{*surface_id};
-        /* this->try_layout(
-            state, LayoutState{*surface_id}, [&](LayoutState const &nl) {
-                HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
-                //this->surface_set_layout(*surface_id);
-                state = nl;
-
-                //compositor::rect area_rect = this->area_info[*surface_id];
-            }); */
     }
     else
     {
@@ -996,29 +897,6 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name,
     }
 }
 
-void App::enqueue_flushdraw(int surface_id)
-{
-    this->check_flushdraw(surface_id);
-    HMI_DEBUG("wm", "Enqueuing EndDraw for surface_id %d", surface_id);
-    this->pending_end_draw.push_back(surface_id);
-}
-
-void App::check_flushdraw(int surface_id)
-{
-    auto i = std::find(std::begin(this->pending_end_draw),
-                       std::end(this->pending_end_draw), surface_id);
-    if (i != std::end(this->pending_end_draw))
-    {
-        auto n = this->lookup_name(surface_id);
-        HMI_ERROR("wm", "Application %s (%d) has pending EndDraw call(s)!",
-                  n ? n->c_str() : "unknown-name", surface_id);
-        std::swap(this->pending_end_draw[std::distance(
-                      std::begin(this->pending_end_draw), i)],
-                  this->pending_end_draw.back());
-        this->pending_end_draw.resize(this->pending_end_draw.size() - 1);
-    }
-}
-
 WMError App::doEndDraw(unsigned req_num)
 {
     // get actions
@@ -1308,19 +1186,6 @@ void App::surface_created(uint32_t surface_id)
 
     this->controller->layers[*layer_id]->add_surface(surface_id);
     this->layout_commit();
-    // activate the main_surface right away
-    /*if (surface_id == static_cast<unsigned>(this->layers.main_surface)) {
-      HMI_DEBUG("wm", "Activating main_surface (%d)", surface_id);
-
-      this->api_activate_surface(
-         this->lookup_name(surface_id).value_or("unknown-name").c_str());
-   }*/
-
-    // search pid from surfaceID
-
-    // pick up appid from pid from application manager
-
-    // check appid then add it to the client
 }
 
 void App::surface_removed(uint32_t surface_id)
@@ -1652,16 +1517,6 @@ bool App::can_split(struct LayoutState const &state, int new_id)
     return false;
 }
 
-void App::try_layout(struct LayoutState & /*state*/,
-                     struct LayoutState const &new_layout,
-                     std::function<void(LayoutState const &nl)> apply)
-{
-    if (this->policy.layout_is_valid(new_layout))
-    {
-        apply(new_layout);
-    }
-}
-
 /**
  * controller_hooks
  */