diff options
author | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-09-12 11:29:32 +0200 |
---|---|---|
committer | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-09-12 11:29:32 +0200 |
commit | f4607b245556213eba320bb5e82262acf7967955 (patch) | |
tree | 7d0dd2b853965706964073e09cd9be2eb737aceb | |
parent | 7a14533d1a270bb7a57be16dce31235604d71e0b (diff) |
App: special-case (de)activation for main_surface
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
-rw-r--r-- | src/app.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/app.cpp b/src/app.cpp index 040e0b0..7673ba9 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -379,6 +379,7 @@ void App::surface_set_layout_split(uint32_t surface_id, uint32_t sub_surface_id) } char const *App::activate_surface(char const *drawing_name) { + ST(); auto const &surface_id = this->lookup_id(drawing_name); if (!surface_id) { @@ -393,6 +394,22 @@ char const *App::activate_surface(char const *drawing_name) { return "Surface already active"; } + // Special case main_surface + if (*surface_id == this->layers.main_surface) { + for (auto const &s: this->controller->surfaces) { + if (s.second->id != *surface_id) { + this->deactivate(s.second->id); + } + } + this->activate(*surface_id); + this->state.main = this->state.sub = -1; + this->state.s = LayoutState::Single; + // commit changes + this->controller->commit_changes(); + this->display->flush(); + return nullptr; + } + // This should involve a policy check, but as we do not (yet) have // such a thing, we will just switch to this surface. // XXX: input focus missing!!1 @@ -449,6 +466,7 @@ char const *App::activate_surface(char const *drawing_name) { } char const *App::deactivate_surface(char const *drawing_name) { + ST(); auto const &surface_id = this->lookup_id(drawing_name); if (!surface_id) { @@ -463,6 +481,11 @@ char const *App::deactivate_surface(char const *drawing_name) { return "No surface active"; } + if (*surface_id == this->layers.main_surface) { + logdebug("Refusing to deactivate main_surface %d", *surface_id); + return nullptr; + } + if (this->state.main == *surface_id) { if (this->state.sub != -1) { this->emit_syncdraw(this->lookup_name(this->state.sub)->c_str()); @@ -505,9 +528,10 @@ char const *App::deactivate_surface(char const *drawing_name) { // | .__/|_| \___/_/\_\_|\___|\__,_| |_____| \_/ \___|_| |_|\__|___/ // |_| void App::surface_created(uint32_t surface_id) { - logdebug("surface_id is %u", surface_id); + auto layer_id = this->layers.get_layer_id(surface_id); + logdebug("surface_id is %u, layer_id is %u", surface_id, layer_id ? *layer_id : -1u); - this->controller->layers[this->layers.get_layer_id(surface_id).value()] + this->controller->layers[*layer_id] ->add_surface(this->controller->surfaces[surface_id].get()); // activate the main_surface right away @@ -560,7 +584,7 @@ result<int> App::request_surface(char const *drawing_name) { if (!rname) { // name does not exist yet, allocate surface id... auto id = int(this->id_alloc.generate_id(drawing_name)); - this->layers.add_surface(id, lid.value()); + this->layers.add_surface(id, *lid); // XXX: we set the main_surface[_name] here and now, // not sure if we want this, but it worked so far. |