}
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";
}
// 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) {
//}
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) {
+ if (this->state.main != *surface_id) {
this->surface_set_layout_split(this->state.main,
- this->state.sub = surface_id);
+ this->state.sub = *surface_id);
this->activate(this->state.sub);
}
} 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;
}
}
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;
return Err<int>("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 =
}
}
-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 =
}
}
-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 =
using json = nlohmann::json;
using storage_type = std::set<struct layer>;
- using layers_type = std::vector<unsigned int>;
+ using layers_type = std::vector<uint32_t>;
using role_to_layer_map = std::vector<std::pair<std::string, int>>;
- using addsurf_layer_map = std::map<unsigned, unsigned>;
+ using addsurf_layer_map = std::map<int, int>;
// XXX: we also will need a layer_id to layer map, perhaps
// make this the primary map, and the surface_id->layer a
return this->layers.size();
}
- void add_surface(unsigned surface_id, unsigned layer_id) {
+ void add_surface(int surface_id, int layer_id) {
this->surfaces[surface_id] = layer_id;
}