diff options
-rw-r--r-- | layers.json | 25 | ||||
-rw-r--r-- | src/app.cpp | 16 | ||||
-rw-r--r-- | src/app.hpp | 15 | ||||
-rw-r--r-- | src/layers.cpp | 32 | ||||
-rw-r--r-- | src/layers.hpp | 8 |
5 files changed, 89 insertions, 7 deletions
diff --git a/layers.json b/layers.json index b5f0782..d452971 100644 --- a/layers.json +++ b/layers.json @@ -25,7 +25,30 @@ "name": "apps", "layer_id": 1001, "area": { "type": "rect", "rect": { "x": 0, "y": 100, "width": -1, "height": -201 } }, - "comment": "Range of IDs that will always be placed on layer 1001, negative rect values are interpreted as output_size.dimension - $value" + "comment": "Range of IDs that will always be placed on layer 1001, negative rect values are interpreted as output_size.dimension - $value", + + "split_layouts": [ + { + "name": "Media Player", + "main_match": "^App MPlayer Main$", + "sub_match": "^App MPlayer Sub", + "priority": 500, + "comment": "All Media Player sub surfaces can be put in a sub layout with the Media Player" + }, + { + "name": "Playlist", + "main_match": "", + "sub_match": "^App MPlayer Sub Playlist$", + "priority": 100, + "comment": "Always allow the media player playlist to be displayed as sub surface" + }, + { + "name": "Map", + "main_match": "^App Navi Map", + "sub_match": "^App Navi Guidance", + "priority": 1000 + } + ] }, { "type": "range", 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); |