summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-12 11:29:29 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-12 11:29:29 +0200
commit2c9977101d257edd62b2fb2fa7fabb541efc6698 (patch)
tree8571ccccfdda89829247894f03d51c61eeda8caa /src
parent1b4362e9a8ece16e37fc6327ad175475a56a6fe5 (diff)
app/layout: fix split layout from and to transitions
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src')
-rw-r--r--src/app.cpp127
-rw-r--r--src/app.hpp19
-rw-r--r--src/layout.hpp33
3 files changed, 71 insertions, 108 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 9b8f1fd..a6dd99c 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -228,6 +228,7 @@ int App::init_layers() {
namespace {
+#ifdef WE_LIKE_NOT_TO_USE_THIS
// This can fix the HomeScreen...
void redraw_fix(App *app, std::unique_ptr<genivi::surface> &s, int x, int y,
int w, int h) {
@@ -251,6 +252,7 @@ void redraw_fix(App *app, std::unique_ptr<genivi::surface> &s, int x, int y,
app->display->roundtrip();
}
}
+#endif
} // namespace
@@ -298,12 +300,6 @@ void App::surface_set_layout_full(uint32_t surface_id) {
// set destination to the display rectangle
s->set_destination_rectangle(x, y, w, h);
- s->set_visibility(0);
- s->set_opacity(256);
-
- this->controller->commit_changes();
- this->display->roundtrip();
-
//redraw_fix(this, s, x, y, w, h);
logdebug("Surface %u now with rect { %d, %d, %d, %d }",
@@ -339,7 +335,7 @@ void App::surface_set_layout_split(uint32_t surface_id, uint32_t sub_surface_id)
this->state.main = surface_id;
this->state.sub = sub_surface_id;
- this->state.state = LayoutState::LayoutSplit;
+ this->state.s = LayoutState::Split;
// less-than-0 values refer to MAX + 1 - $VALUE
// e.g. MAX is either screen width or height
@@ -369,9 +365,6 @@ void App::surface_set_layout_split(uint32_t surface_id, uint32_t sub_surface_id)
// set destination to the display rectangle
s->set_destination_rectangle(x, y, w, h);
- s->set_visibility(1);
- s->set_opacity(256);
-
// configure surface to wxh dimensions
ss->set_configuration(w, h);
// set source reactangle, even if we should not need to set it.
@@ -379,12 +372,6 @@ void App::surface_set_layout_split(uint32_t surface_id, uint32_t sub_surface_id)
// set destination to the display rectangle
ss->set_destination_rectangle(x+x_off, y+y_off, w, h);
- ss->set_visibility(1);
- ss->set_opacity(256);
-
- this->controller->commit_changes();
- this->display->roundtrip();
-
//redraw_fix(this, s, x, y, w, h);
//redraw_fix(this, ss, x+x_off, y+y_off, w, h);
@@ -416,46 +403,50 @@ char const *App::activate_surface(char const *drawing_name) {
// such a thing, we will just switch to this surface.
// XXX: input focus missing!!1
- if (this->state != LayoutState{}) {
- switch (this->state.state) {
- case LayoutState::LayoutSingle:
- if (this->can_split(surface_id)) {
- this->surface_set_layout_split(this->state.main, surface_id);
- return nullptr;
- }
- break;
-
- case LayoutState::LayoutSplit:
- if (this->can_split(surface_id)) {
- this->deactivate(this->state.sub);
- this->surface_set_layout_split(this->state.main, surface_id);
- }
-
- case LayoutState::LayoutNone:
- break;
- }
- }
-
// Make it visible, no (or little effect) if already visible
auto &s = this->controller->surfaces[surface_id];
- // Set all others invisible
- for (auto &i : this->controller->surfaces) {
- auto &si = this->controller->sprops[i.second->id];
- if (si.id != s->id && si.visibility != 0 &&
- int(si.id) != this->layers.main_surface) {
- this->deactivate(si.id);
+ //// Set all others invisible
+ //for (auto &i : this->controller->surfaces) {
+ // auto &si = this->controller->sprops[i.second->id];
+ // if (si.id != s->id && si.visibility != 0 &&
+ // int(si.id) != this->layers.main_surface) {
+ // this->deactivate(si.id);
+ // }
+ //}
+
+ if (this->state.main == -1) {
+ 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);
+
+ 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);
+ }
+ } else {
+ this->surface_set_layout_full(surface_id);
+ this->deactivate(this->state.main);
+ this->activate(surface_id);
+ this->deactivate(this->state.sub);
+ this->state.main = surface_id;
+ this->state.sub = -1;
+ this->state.s = LayoutState::Single;
+ }
}
}
- this->activate(s->id);
// commit changes
this->controller->commit_changes();
this->display->flush();
- this->state.main = surface_id;
- this->state.state = LayoutState::LayoutSingle;
-
// no error
return nullptr;
}
@@ -476,41 +467,30 @@ char const *App::deactivate_surface(char const *drawing_name) {
return "Cannot deactivate main_surface";
}
- switch (this->state.state) {
- case LayoutState::LayoutSplit:
- if (surface_id == this->state.main) {
+ if (this->state.main == -1) {
+ return "No surface active";
+ } else {
+ if (this->state.main == surface_id) {
+ if (this->state.sub != -1) {
this->deactivate(surface_id);
- this->surface_set_layout_full(this->state.main);
-
- this->deactivate(this->state.sub);
this->surface_set_layout_full(this->state.sub);
-
- this->state.main = -1;
+ this->state.main = this->state.sub;
this->state.sub = -1;
- this->state.state = LayoutState::LayoutSingle;
- } else if (surface_id == this->state.sub) {
+ this->state.s = LayoutState::Single;
+ } else {
this->deactivate(surface_id);
- this->surface_set_layout_full(this->state.sub);
- this->surface_set_layout_full(this->state.main);
-
- // XXX send syndraw events....
-
- this->state.sub = -1;
- this->state.state = LayoutState::LayoutSingle;
+ this->state.main = -1;
}
- break;
-
- case LayoutState::LayoutSingle:
+ }else if (this->state.sub == surface_id) {
this->deactivate(surface_id);
- this->state.main = -1;
+ this->surface_set_layout_full(this->state.main);
this->state.sub = -1;
- break;
-
- case LayoutState::LayoutNone:
- break;
+ this->state.s = LayoutState::Single;
+ } else {
+ return "Surface is not active";
+ }
}
-
this->controller->commit_changes();
this->display->flush();
@@ -619,7 +599,7 @@ void App::deactivate(unsigned id) {
}
bool App::can_split(unsigned new_id) {
- if (this->state.state == LayoutState::LayoutSingle) {
+ 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 =
this->layers.get_layer_id(this->state.main).value();
@@ -649,6 +629,7 @@ bool App::can_split(unsigned new_id) {
logdebug("%d sub_match '%s'", new_id_layer, i->sub_match.c_str());
auto res = std::regex(i->sub_match);
if (std::regex_match(new_id_str, res)) {
+ logdebug("layout matched!");
return true;
}
}
diff --git a/src/app.hpp b/src/app.hpp
index c4c0a81..c8ea01b 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -102,25 +102,6 @@ struct id_allocator {
}
};
-struct LayoutState {
- enum States {
- LayoutNone, // Not useful...
- LayoutSingle,
- LayoutSplit,
- };
-
- enum States state{LayoutSingle};
- int main{-1};
- int sub{-1};
-
- bool operator==(const LayoutState &b) const {
- return state == b.state && main == b.main && sub == b.sub;
- }
- bool operator!=(const LayoutState &b) const {
- return !(*this == b);
- }
-};
-
struct App {
struct binding_api api;
struct controller_hooks chooks;
diff --git a/src/layout.hpp b/src/layout.hpp
index 33a503d..85ac30e 100644
--- a/src/layout.hpp
+++ b/src/layout.hpp
@@ -25,24 +25,25 @@
namespace wm {
-// Areas and layouts are defined to have a name, let's just keep it this way,
-// we will not copy them around anyway.
-struct area {
- std::string name;
- genivi::rect rect;
- uint32_t layer; // i.e. zorder?
+struct LayoutState {
+ enum States {
+ Single,
+ Split,
+ };
+
+ enum States s{Single};
+ int main{-1};
+ int sub{-1};
+
+ bool operator==(const LayoutState &b) const {
+ return s == b.s && main == b.main && sub == b.sub;
+ }
+
+ bool operator!=(const LayoutState &b) const {
+ return !(*this == b);
+ }
};
-struct layout {
- static constexpr unsigned MAX_N_AREAS = 2;
-
- std::string name;
- uint32_t n_areas;
- struct area areas[MAX_N_AREAS];
-};
-
-typedef std::vector<struct layout> layouts_type;
-
} // namespace wm
#endif // TMCAGLWM_LAYOUT_HPP