App: only activate/deactivate if necessary
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 5 Sep 2017 10:10:40 +0000 (12:10 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 5 Sep 2017 10:13:31 +0000 (12:13 +0200)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/app.cpp

index a59adba..26dc5f6 100644 (file)
@@ -491,13 +491,19 @@ result<int> App::request_surface(char const *drawing_name) {
 }
 
 void App::activate(unsigned id) {
-   this->controller->surfaces[id]->set_visibility(1);
-   this->emit_activated(this->lookup_name(id).value_or("unknown-name").c_str());
+   if (this->controller->sprops[id].visibility == 0) {
+      this->controller->surfaces[id]->set_visibility(1);
+      this->emit_activated(
+              this->lookup_name(id).value_or("unknown-name").c_str());
+   }
 }
 
 void App::deactivate(unsigned id) {
-   this->controller->surfaces[id]->set_visibility(0);
-   this->emit_deactivated(this->lookup_name(id).value_or("unknown-name").c_str());
+   if (this->controller->sprops[id].visibility != 0) {
+      this->controller->surfaces[id]->set_visibility(0);
+      this->emit_deactivated(
+              this->lookup_name(id).value_or("unknown-name").c_str());
+   }
 }
 
 //  _     _           _ _                            _   _                 _