diff options
author | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-09-05 15:04:59 +0200 |
---|---|---|
committer | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-09-05 15:05:06 +0200 |
commit | a0aeb123e0163301a5498c148ef1882d48a8d179 (patch) | |
tree | 4849ae2f59ed369d8e723950042d3490b8e788f8 | |
parent | 61a7017f78cc08ce8744f4d2fba40a70f02e1bda (diff) |
App: emit visibility events
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
-rw-r--r-- | src/app.cpp | 22 | ||||
-rw-r--r-- | src/app.hpp | 2 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/app.cpp b/src/app.cpp index f76ebbd..2bb74b4 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -386,9 +386,9 @@ char const *App::activate_surface(char const *drawing_name) { // Set all others invisible for (auto &i : this->controller->surfaces) { auto &si = this->controller->sprops[i.second->id]; - if (si.visibility != 0 && + if (si.id != s->id && si.visibility != 0 && int(si.id) != this->layers.main_surface) { - this->deactivate(i.second->id); + this->deactivate(si.id); } } this->activate(s->id); @@ -463,6 +463,14 @@ void App::emit_visible(char const *label, bool is_visible) { this->api.send_event(is_visible ? "visible" : "invisible", label); } +void App::emit_invisible(char const *label) { + return emit_visible(label, 0); +} + +void App::emit_visible(char const *label) { + return emit_visible(label, 1); +} + result<int> App::request_surface(char const *drawing_name) { auto lid = this->layers.get_layer_id(std::string(drawing_name)); if (!lid) { @@ -494,16 +502,18 @@ result<int> App::request_surface(char const *drawing_name) { void App::activate(unsigned id) { 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()); + char const *label = this->lookup_name(id).value_or("unknown-name").c_str(); + this->emit_activated(label); + this->emit_visible(label); } } void App::deactivate(unsigned id) { 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()); + char const *label = this->lookup_name(id).value_or("unknown-name").c_str(); + this->emit_deactivated(label); + this->emit_invisible(label); } } diff --git a/src/app.hpp b/src/app.hpp index fa26e39..d1fc912 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -154,6 +154,8 @@ struct App { void emit_syncdraw(char const *label); void emit_flushdraw(char const *label); void emit_visible(char const *label, bool is_visible); + void emit_invisible(char const *label); + void emit_visible(char const *label); void activate(unsigned id); void deactivate(unsigned id); |