Fix: update activate_surface usage missing an arg sandbox/claneys/hmi-framework
authorRomain Forlot <romain.forlot@iot.bzh>
Mon, 27 Nov 2017 17:45:11 +0000 (18:45 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Tue, 28 Nov 2017 11:16:37 +0000 (12:16 +0100)
Change-Id: I9835b07c3567f01038f3e20a3d5ff012e1ffcbc6
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
src/app.cpp

index ddb2182..b562b9d 100644 (file)
@@ -596,37 +596,33 @@ void App::api_ping() { this->dispatch_pending_events(); }
 void App::surface_created(uint32_t surface_id) {
    auto layer_id = this->layers.get_layer_id(surface_id);
    if (!layer_id) {
-      HMI_DEBUG("wm", "Newly created surface %d is not associated with any layer! Must be a XDG apps",
-               surface_id);
+      HMI_DEBUG("wm", "Newly created surface %d from a XDG apps. Main surface: %s",
+         surface_id, this->layers.main_surface_name.c_str());
       layer_id = this->layers.get_layer_id(XDG_DRAWING_NAME);
       if(!layer_id)
       {
           HMI_DEBUG("wm", "No role found for that XDG App");
           return;
       }
-
+      this->id_alloc.id2name[surface_id] = XDG_DRAWING_NAME;
+      this->id_alloc.name2id[XDG_DRAWING_NAME] = surface_id;
       this->layers.add_surface(surface_id, *layer_id);
-      // set the main_surface[_name] here and now
-      if (this->layers.main_surface_name.empty()) {
-        this->layers.main_surface_name == XDG_DRAWING_NAME;
-        this->layers.main_surface = surface_id;
-        HMI_DEBUG("wm", "Set main_surface id to %u", surface_id);
-      }
    }
 
-   HMI_DEBUG("wm", "surface_id is %u, layer_id is %u", surface_id, *layer_id);
+   HMI_DEBUG("wm", "surface_id is %u, layer_id is %u, drawing name is: %s",
+    surface_id,
+    *layer_id,
+    this->lookup_name(surface_id).value_or("unknown-name").c_str());
 
    this->controller->layers[*layer_id]->add_surface(
       this->controller->surfaces[surface_id].get());
 
-    if(this->layers.main_surface_name == XDG_DRAWING_NAME) {
-    // 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());
-        }
+    if(this->lookup_name(surface_id).value_or("unknown-name") == XDG_DRAWING_NAME) {
+        HMI_DEBUG("wm", "Activating surface id: %d, name: %s", surface_id, this->lookup_name(surface_id).value_or("unknown-name").c_str());
+        this->activate(surface_id);
+        this->api_activate_surface(
+            this->lookup_name(surface_id).value_or("unknown-name").c_str(),
+            kNameLayoutNormal);
     }
 }