summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
2c99771)
* Also make use of optional's operator* where appropriate.
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
}
char const *App::activate_surface(char const *drawing_name) {
}
char const *App::activate_surface(char const *drawing_name) {
+ 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";
}
return "Surface already active";
}
// XXX: input focus missing!!1
// Make it visible, no (or little effect) if already visible
// 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) {
//// Set all others invisible
//for (auto &i : this->controller->surfaces) {
//}
if (this->state.main == -1) {
//}
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 {
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.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->surface_set_layout_split(this->state.main,
- this->state.sub = surface_id);
+ this->state.sub = *surface_id);
this->activate(this->state.sub);
}
} else {
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->deactivate(this->state.main);
- this->activate(surface_id);
+ this->activate(*surface_id);
this->deactivate(this->state.sub);
this->deactivate(this->state.sub);
- this->state.main = surface_id;
+ this->state.main = *surface_id;
this->state.sub = -1;
this->state.s = LayoutState::Single;
}
this->state.sub = -1;
this->state.s = LayoutState::Single;
}
}
char const *App::deactivate_surface(char const *drawing_name) {
}
char const *App::deactivate_surface(char const *drawing_name) {
+ 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 {
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) {
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->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);
- }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;
this->surface_set_layout_full(this->state.main);
this->state.sub = -1;
this->state.s = LayoutState::Single;
return Err<int>("Surface already present");
}
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 =
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 =
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 =
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 =
// ID allocation and proxy methods for lookup
struct id_allocator id_alloc;
// ID allocation and proxy methods for lookup
struct id_allocator id_alloc;
- optional<unsigned> lookup_id(char const *name) {
+ optional<int> lookup_id(char const *name) {
return this->id_alloc.lookup(std::string(name));
}
return this->id_alloc.lookup(std::string(name));
}
- optional<std::string> lookup_name(unsigned id) {
+ optional<std::string> lookup_name(int id) {
return this->id_alloc.lookup(id);
}
return this->id_alloc.lookup(id);
}
void emit_invisible(char const *label);
void emit_visible(char const *label);
void emit_invisible(char const *label);
void emit_visible(char const *label);
- void activate(unsigned id);
- void deactivate(unsigned id);
+ void activate(int id);
+ void deactivate(int id);
- bool can_split(unsigned new_id);
+ bool can_split(int new_id);
using json = nlohmann::json;
using storage_type = std::set<struct 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 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
// 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();
}
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;
}
this->surfaces[surface_id] = layer_id;
}