Bug Fix: Window Manager doesn't react after killing app process
[apps/agl-service-windowmanager-2017.git] / src / app.cpp
index 4076f85..f09f6f5 100644 (file)
  * limitations under the License.
  */
 
-#include "app.hpp"
-#include "json_helper.hpp"
-#include "layers.hpp"
-#include "layout.hpp"
-#include "util.hpp"
-#include "wayland_ivi_wm.hpp"
-
-#include <cstdio>
-#include <memory>
-
-#include <cassert>
-
-#include <json-c/json.h>
-
-#include <algorithm>
-#include <csignal>
 #include <fstream>
-#include <json.hpp>
 #include <regex>
-#include <thread>
+
+#include "app.hpp"
+#include "../include/json.hpp"
+
 
 namespace wm {
 
@@ -103,17 +89,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();
@@ -736,36 +731,11 @@ 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());
-   }*/
 }
 
 void App::surface_removed(uint32_t surface_id)
 {
     HMI_DEBUG("wm", "surface_id is %u", surface_id);
-
-    // We cannot normally deactivate the main_surface, so be explicit
-    // about it:
-    if (int(surface_id) == this->layers.main_surface)
-    {
-        this->deactivate_main_surface();
-    }
-    else
-    {
-        auto drawing_name = this->lookup_name(surface_id);
-        if (drawing_name)
-        {
-            this->api_deactivate_surface(drawing_name->c_str(), [](const char *) {});
-        }
-    }
-
-    this->id_alloc.remove_id(surface_id);
-    this->layers.remove_surface(surface_id);
 }
 
 void App::emit_activated(char const *label)
@@ -1030,12 +1000,6 @@ void App::deactivate(int id)
     }
 }
 
-void App::deactivate_main_surface()
-{
-    this->layers.main_surface = -1;
-    this->api_deactivate_surface(this->layers.main_surface_name.c_str(), [](const char *) {});
-}
-
 bool App::can_split(struct LayoutState const &state, int new_id)
 {
     if (state.main != -1 && state.main != new_id)
@@ -1086,10 +1050,7 @@ 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);
-    }
+    apply(new_layout);
 }
 
 /**