App: remove last_active logic
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 5 Sep 2017 09:52:37 +0000 (11:52 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 5 Sep 2017 10:13:30 +0000 (12:13 +0200)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/app.cpp
src/app.hpp

index 527fe01..3e28a5f 100644 (file)
@@ -128,8 +128,7 @@ App::App(wl::display *d)
      config(),
      layouts(),
      layers(),
-     id_alloc{},
-     last_active() {
+     id_alloc{} {
    assert(g_app == nullptr);
    g_app = this;
 
@@ -401,11 +400,6 @@ char const *App::activate_surface(char const *drawing_name) {
    this->controller->commit_changes();
    this->display->flush();
 
-   // Current active surface is the first in last_active
-   this->last_active.push_front(s->id);
-   /// // XXX: I am not sure I even need 5 elements...
-   /// this->last_active.resize(std::min(int(this->last_active.size()), 5));
-
    this->emit_activated(drawing_name);
 
    // no error
@@ -428,33 +422,10 @@ char const *App::deactivate_surface(char const *drawing_name) {
       return "Cannot deactivate main_surface";
    }
 
-   if (this->last_active.empty()) {
-      return "Cannot deactivate surface (not active)";
-   }
-
-   // XXX: should an active surface not alsways be front() or
-   // front+1() of last_active?!
 
-   // XXX: Should I really be able to deactivate a surface that is not
-   // front() of last_active?
-   auto is = std::find(this->last_active.begin(),
-                       this->last_active.end(),
-                       surface_id);
-
-   if (is == this->last_active.end()) {
-      return "Cannot deactivate surface (not active)";
-   }
 
    this->emit_deactivated(drawing_name);
 
-   this->last_active.erase(is);
-
-   if (! this->last_active.empty()) {
-      // Should be active already, shouldn't it?
-      this->activate_surface(this->lookup_name(this->last_active.front()).value_or("unknown-name").c_str());
-   } else {
-      this->activate_surface(this->layers.main_surface_name.c_str());
-   }
 
    return nullptr;
 }
@@ -479,13 +450,6 @@ void App::surface_removed(uint32_t surface_id) {
    logdebug("surface_id is %u", surface_id);
 
    this->id_alloc.remove_id(surface_id);
-
-   // Also remove from last_active, if found
-   auto i = std::find(this->last_active.begin(),
-                      this->last_active.end(), surface_id);
-   if (i != this->last_active.end()) {
-      this->last_active.erase(i);
-   }
 }
 
 void App::emit_activated(char const *label) {
index 79498c2..3e3a56e 100644 (file)
@@ -122,8 +122,6 @@ struct App {
       return this->id_alloc.lookup(id);
    }
 
-   std::deque<unsigned> last_active;
-
    explicit App(wl::display *d);
    ~App();