X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fapp.cpp;h=6ab58a46d81e54493bd4871ff6f5823f3295e84e;hb=b1a7670336d3d5f6f70285e766475a3415c13d12;hp=a6dd99c358f4cec3ff5e630c33638ff030e10bc8;hpb=2c9977101d257edd62b2fb2fa7fabb541efc6698;p=staging%2Fwindowmanager.git diff --git a/src/app.cpp b/src/app.cpp index a6dd99c..6ab58a4 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -380,22 +380,17 @@ void App::surface_set_layout_split(uint32_t surface_id, uint32_t sub_surface_id) } char const *App::activate_surface(char const *drawing_name) { - int surface_id = -1; + auto const &surface_id = this->lookup_id(drawing_name); - { - auto oid = this->lookup_id(drawing_name); - if (oid) { - surface_id = oid.value(); - } else { - return "Surface does not exist"; - } + if (!surface_id) { + return "Surface does not exist"; } - if (!this->controller->surface_exists(surface_id)) { - return "Surface does not exist"; + if (!this->controller->surface_exists(*surface_id)) { + return "Surface does not exist in controller!"; } - if (this->state.main == surface_id || this->state.sub == surface_id) { + if (this->state.main == *surface_id || this->state.sub == *surface_id) { return "Surface already active"; } @@ -404,7 +399,7 @@ char const *App::activate_surface(char const *drawing_name) { // XXX: input focus missing!!1 // Make it visible, no (or little effect) if already visible - auto &s = this->controller->surfaces[surface_id]; + auto &s = this->controller->surfaces[*surface_id]; //// Set all others invisible //for (auto &i : this->controller->surfaces) { @@ -416,27 +411,27 @@ char const *App::activate_surface(char const *drawing_name) { //} if (this->state.main == -1) { - this->surface_set_layout_full(surface_id); - this->activate(surface_id); - this->state.main = surface_id; + this->surface_set_layout_full(*surface_id); + this->activate(*surface_id); + this->state.main = *surface_id; this->state.sub = -1; this->state.s = LayoutState::Single; } else { - bool can_split = this->can_split(surface_id); + bool can_split = this->can_split(*surface_id); if (this->state.sub == -1) { if (can_split) { - if (this->state.main != surface_id) { - this->surface_set_layout_split(this->state.main, - this->state.sub = surface_id); - this->activate(this->state.sub); + if (this->state.main != *surface_id) { + this->surface_set_layout_split(this->state.main, *surface_id); + this->activate(*surface_id); + this->state.sub = *surface_id; } } else { - this->surface_set_layout_full(surface_id); + this->surface_set_layout_full(*surface_id); this->deactivate(this->state.main); - this->activate(surface_id); + this->activate(*surface_id); this->deactivate(this->state.sub); - this->state.main = surface_id; + this->state.main = *surface_id; this->state.sub = -1; this->state.s = LayoutState::Single; } @@ -452,37 +447,32 @@ char const *App::activate_surface(char const *drawing_name) { } char const *App::deactivate_surface(char const *drawing_name) { - int surface_id = -1; + auto const &surface_id = this->lookup_id(drawing_name); - { - auto oid = this->lookup_id(drawing_name); - if (oid) { - surface_id = oid.value(); - } else { - return "Surface does not exist"; - } + if (!surface_id) { + return "Surface does not exist"; } - if (surface_id == this->layers.main_surface) { + if (*surface_id == this->layers.main_surface) { return "Cannot deactivate main_surface"; } if (this->state.main == -1) { return "No surface active"; } else { - if (this->state.main == surface_id) { + if (this->state.main == *surface_id) { if (this->state.sub != -1) { - this->deactivate(surface_id); + this->deactivate(*surface_id); this->surface_set_layout_full(this->state.sub); this->state.main = this->state.sub; this->state.sub = -1; this->state.s = LayoutState::Single; } else { - this->deactivate(surface_id); + this->deactivate(*surface_id); this->state.main = -1; } - }else if (this->state.sub == surface_id) { - this->deactivate(surface_id); + }else if (this->state.sub == *surface_id) { + this->deactivate(*surface_id); this->surface_set_layout_full(this->state.main); this->state.sub = -1; this->state.s = LayoutState::Single; @@ -578,7 +568,7 @@ result App::request_surface(char const *drawing_name) { return Err("Surface already present"); } -void App::activate(unsigned id) { +void App::activate(int id) { if (this->controller->sprops[id].visibility == 0) { this->controller->surfaces[id]->set_visibility(1); char const *label = @@ -588,7 +578,7 @@ void App::activate(unsigned id) { } } -void App::deactivate(unsigned id) { +void App::deactivate(int id) { if (this->controller->sprops[id].visibility != 0) { this->controller->surfaces[id]->set_visibility(0); char const *label = @@ -598,7 +588,7 @@ void App::deactivate(unsigned id) { } } -bool App::can_split(unsigned new_id) { +bool App::can_split(int new_id) { if (this->state.main != -1 && this->state.main != new_id) { auto new_id_layer = this->layers.get_layer_id(new_id).value(); auto current_id_layer =