aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-12 11:29:20 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-12 11:29:20 +0200
commit2089b5b1ba2f04f037be1ef897bf79790bf501e2 (patch)
treec8501c5cf0c9cb28741e39ee518477360175a6cb /src
parentcc06687c8043b93b08202c6c90e588d9b1897c31 (diff)
WIP split layouts, reading config, defining data layout.
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src')
-rw-r--r--src/app.cpp16
-rw-r--r--src/app.hpp15
-rw-r--r--src/layers.cpp32
-rw-r--r--src/layers.hpp8
4 files changed, 65 insertions, 6 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 1c7382d..7f0bcbb 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -517,6 +517,22 @@ void App::deactivate(unsigned id) {
}
}
+bool App::can_split(unsigned new_id) {
+ if (this->state.state == LayoutState::LayoutSingle) {
+ 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();
+
+ if (new_id_layer != current_id_layer) {
+ return false;
+ }
+
+ std::string const &new_id_str = this->lookup_name(new_id).value();
+ std::string const &cur_id_str = this->lookup_name(this->state.main).value();
+
+
+ }
+}
+
// _ _ _ _ _
// ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __ | |__ ___ ___ | | _____
// / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|| '_ \ / _ \ / _ \| |/ / __|
diff --git a/src/app.hpp b/src/app.hpp
index d1fc912..37122ef 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -98,6 +98,17 @@ struct id_allocator {
}
};
+struct LayoutState {
+ enum States {
+ LayoutSingle,
+ LayoutSplit,
+ };
+
+ enum States state;
+ int main;
+ int sub;
+};
+
struct App {
struct binding_api api;
struct controller_hooks chooks;
@@ -122,6 +133,8 @@ struct App {
return this->id_alloc.lookup(id);
}
+ struct LayoutState state;
+
explicit App(wl::display *d);
~App();
@@ -159,6 +172,8 @@ struct App {
void activate(unsigned id);
void deactivate(unsigned id);
+
+ bool can_split(unsigned new_id);
};
} // namespace wm
diff --git a/src/layers.cpp b/src/layers.cpp
index c814c22..b931870 100644
--- a/src/layers.cpp
+++ b/src/layers.cpp
@@ -42,6 +42,29 @@ layer::layer(nlohmann::json const &j) {
jr["width"], jr["height"], jr["x"], jr["y"],
};
}
+ auto split_layouts = j.find("split_layouts");
+ if (split_layouts != j.end()) {
+ auto &sls = j["split_layouts"];
+ this->layouts.reserve(sls.size());
+ std::transform(std::cbegin(sls), std::cend(sls),
+ std::back_inserter(this->layouts), [](json const &sl) {
+ struct split_layout l {};
+ l.name = sl["name"];
+ l.main_match = sl["main_match"];
+ l.sub_match = sl["sub_match"];
+ l.prio = sl.value<int>("priority", 0);
+ logdebug(
+ "Added split_layout \"%s\" (main: \"%s\") (sub: "
+ "\"%s\") (prio: %d)",
+ l.name.c_str(), l.main_match.c_str(),
+ l.sub_match.c_str(), l.prio);
+ return l;
+ });
+ std::sort(std::begin(this->layouts), std::end(this->layouts),
+ [](struct split_layout const &a, struct split_layout const &b) {
+ return a.prio < b.prio;
+ });
+ }
}
struct result<struct layer_map> to_layer_map(nlohmann::json const &j) {
@@ -179,12 +202,9 @@ json layer::to_json() const {
}
return {
- {"id_min", this->id_min},
- {"id_max", this->id_max},
- {"name", this->name},
- {"role", this->role},
- {"layer_id", this->layer_id},
- {"area", r},
+ {"id_min", this->id_min}, {"id_max", this->id_max},
+ {"name", this->name}, {"role", this->role},
+ {"layer_id", this->layer_id}, {"area", r},
};
}
diff --git a/src/layers.hpp b/src/layers.hpp
index af1638a..924457f 100644
--- a/src/layers.hpp
+++ b/src/layers.hpp
@@ -26,6 +26,13 @@
namespace wm {
+struct split_layout {
+ std::string name;
+ std::string main_match;
+ std::string sub_match;
+ int prio;
+};
+
struct layer {
using json = nlohmann::json;
@@ -47,6 +54,7 @@ struct layer {
// put on this layer.
std::string role;
// XXX perhaps a zorder is needed here?
+ std::vector<struct split_layout> layouts;
explicit layer(nlohmann::json const &j);