Inherit workspace informat
This commit is contained in:
@@ -22,6 +22,9 @@ void dump_tree_container(const i3ipc::container_t& c, std::string& prefix) {
|
||||
std::cout << prefix << "current_border_width = " << c.current_border_width << std::endl;
|
||||
std::cout << prefix << "layout = \"" << c.layout_raw << "\"" << std::endl;
|
||||
std::cout << prefix << "percent = " << c.percent << std::endl;
|
||||
if (c.workspace.has_value()) {
|
||||
std::cout << prefix << "current_workspace = " << c.workspace.value() << std::endl;
|
||||
}
|
||||
if (c.urgent) {
|
||||
std::cout << prefix << "urgent" << std::endl;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -198,11 +199,14 @@ struct container_t {
|
||||
rect_t geometry; ///< The original geometry the window specified when i3 mapped it. Used when switching a window to floating mode, for example
|
||||
bool urgent;
|
||||
bool focused;
|
||||
std::optional<std::string> workspace;
|
||||
|
||||
window_properties_t window_properties; /// X11 window properties
|
||||
|
||||
std::list< std::shared_ptr<container_t> > nodes;
|
||||
std::list< std::shared_ptr<container_t> > floating_nodes;
|
||||
|
||||
std::map<std::string, std::string> map;
|
||||
};
|
||||
|
||||
|
||||
|
||||
26
src/ipc.cpp
26
src/ipc.cpp
@@ -73,7 +73,7 @@ window_properties_t parse_window_props_from_json(const Json::Value& value) {
|
||||
}
|
||||
|
||||
|
||||
static std::shared_ptr<container_t> parse_container_from_json(const Json::Value& o) {
|
||||
static std::shared_ptr<container_t> parse_container_from_json(const Json::Value& o, std::optional<std::string> workspace_name = std::nullopt) {
|
||||
#define i3IPC_TYPE_STR "PARSE CONTAINER FROM JSON"
|
||||
if (o.isNull())
|
||||
return std::shared_ptr<container_t>();
|
||||
@@ -128,11 +128,31 @@ static std::shared_ptr<container_t> parse_container_from_json(const Json::Value
|
||||
I3IPC_WARN("Got a unknown \"layout\" property: \"" << layout << "\". Perhaps its neccessary to update i3ipc++. If you are using latest, note maintainer about this")
|
||||
}
|
||||
|
||||
for (auto& member : o.getMemberNames()) {
|
||||
std::string value;
|
||||
try {
|
||||
value = o[member].asString();
|
||||
} catch(const std::exception&) {
|
||||
// Just collect what we can
|
||||
continue;
|
||||
}
|
||||
|
||||
container->map[member] = value;
|
||||
}
|
||||
|
||||
if (Json::Value value{o["name"]}; container->type == "workspace" && !value.isNull()) {
|
||||
container->workspace = value.asString();
|
||||
} else {
|
||||
// Inherit workspace if any
|
||||
container->workspace = workspace_name;
|
||||
}
|
||||
|
||||
|
||||
Json::Value nodes = o["nodes"];
|
||||
if (!nodes.isNull()) {
|
||||
IPC_JSON_ASSERT_TYPE_ARRAY(nodes, "nodes")
|
||||
for (Json::ArrayIndex i = 0; i < nodes.size(); i++) {
|
||||
container->nodes.push_back(parse_container_from_json(nodes[i]));
|
||||
container->nodes.push_back(parse_container_from_json(nodes[i], container->workspace));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +160,7 @@ static std::shared_ptr<container_t> parse_container_from_json(const Json::Value
|
||||
if (!floating_nodes.isNull()) {
|
||||
IPC_JSON_ASSERT_TYPE_ARRAY(floating_nodes, "floating_nodes")
|
||||
for (Json::ArrayIndex i = 0; i < floating_nodes.size(); i++) {
|
||||
container->floating_nodes.push_back(parse_container_from_json(floating_nodes[i]));
|
||||
container->floating_nodes.push_back(parse_container_from_json(floating_nodes[i], container->workspace));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user