X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fapp.cpp;h=713fd1ef3dd88ebf4d6499ec100c87938b5474b4;hb=04c862b9957ea86959bd533cb1ac497ddb52759d;hp=5791f21c2a199e3e11dae1afc47f308853efb011;hpb=ccd8c4d8957c4a561ae1d2d9a53525fe2a4e4329;p=staging%2Fwindowmanager.git diff --git a/src/app.cpp b/src/app.cpp index 5791f21..713fd1e 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -319,6 +319,36 @@ void App::surface_set_layout(uint32_t surface_id) { surface_id, layer_id, x, y, w, h); } +char const *App::activate_surface(uint32_t surface_id) { + if (! this->controller->surface_exists(surface_id)) { + return "Surface does not exist"; + } + + // This shouild 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 + + // Make it visible, no (or little effect) if already visible + auto &s = this->controller->surfaces[surface_id]; + s->set_visibility(1); + + // Set all others invisible + for (auto &i: this->controller->surfaces) { + auto &si = this->controller->sprops[i.second->id]; + // XXX: filtering out homescreen ID ... set this in a known place!!1 + if (si.visibility == 1 && si.id != s->id && int(si.id) != this->layers.main_surface) { + i.second->set_visibility(0); + } + } + + // commit changes + this->controller->commit_changes(); + this->display->flush(); + + // no error + return nullptr; +} + void App::add_task(char const *name, std::function &&f) { this->pending.emplace_back(std::make_pair(name, f)); } @@ -400,6 +430,15 @@ binding_api::result_type binding_api::debug_terminate() { return Ok(json_object_new_object()); } +binding_api::result_type binding_api::demo_activate_surface( + uint32_t surfaceid) { + char const *e = this->app->activate_surface(surfaceid); + if (e) { + return Err(e); + } + return Ok(json_object_new_object()); +} + // _ _ _ _ _ // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __ | |__ ___ ___ | | _____ // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|| '_ \ / _ \ / _ \| |/ / __|