+char const *App::deactivate_surface(uint32_t surface_id) {
+ if (surface_id == this->layers.main_surface) {
+ 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->last_active.erase(is);
+
+ if (! this->last_active.empty()) {
+ // Should be active already, shouldn't it?
+ this->activate_surface(this->last_active.front());
+ } else {
+ this->activate_surface(this->layers.main_surface);
+ }
+
+ return nullptr;
+}
+