diff --git a/examples/workspaces.cpp b/examples/workspaces.cpp index acde6fa..174914c 100644 --- a/examples/workspaces.cpp +++ b/examples/workspaces.cpp @@ -30,17 +30,17 @@ void dump_tree_container(const i3ipc::container_t& c, std::string& prefix) { int main() { i3ipc::connection conn; for (auto& w : conn.get_workspaces()) { - std::cout << '#' << std::hex << w.num << std::dec - << "\n\tName: " << w.name - << "\n\tVisible: " << w.visible - << "\n\tFocused: " << w.focused - << "\n\tUrgent: " << w.urgent + std::cout << '#' << std::hex << w->num << std::dec + << "\n\tName: " << w->name + << "\n\tVisible: " << w->visible + << "\n\tFocused: " << w->focused + << "\n\tUrgent: " << w->urgent << "\n\tRect: " - << "\n\t\tX: " << w.rect.x - << "\n\t\tY: " << w.rect.y - << "\n\t\tWidth: " << w.rect.width - << "\n\t\tHeight: " << w.rect.height - << "\n\tOutput: " << w.output + << "\n\t\tX: " << w->rect.x + << "\n\t\tY: " << w->rect.y + << "\n\t\tWidth: " << w->rect.width + << "\n\t\tHeight: " << w->rect.height + << "\n\tOutput: " << w->output << std::endl; } std::string prefix_buf; diff --git a/include/i3ipc++/ipc.hpp b/include/i3ipc++/ipc.hpp index 50c535e..ab8eb91 100644 --- a/include/i3ipc++/ipc.hpp +++ b/include/i3ipc++/ipc.hpp @@ -182,13 +182,13 @@ public: * Request a list of workspaces * @return List of workspaces */ - std::vector get_workspaces() const; + std::vector< std::shared_ptr > get_workspaces() const; /** * Request a list of outputs * @return List of outputs */ - std::vector get_outputs() const; + std::vector< std::shared_ptr > get_outputs() const; /** * Request a version of i3 diff --git a/src/ipc.cpp b/src/ipc.cpp index db19ede..e4409f5 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -113,7 +113,7 @@ static std::shared_ptr parse_container_from_json(const Json::Value #undef i3IPC_TYPE_STR } -static workspace_t parse_workspace_from_json(const Json::Value& value) { +static std::shared_ptr parse_workspace_from_json(const Json::Value& value) { Json::Value num = value["num"]; Json::Value name = value["name"]; Json::Value visible = value["visible"]; @@ -122,29 +122,29 @@ static workspace_t parse_workspace_from_json(const Json::Value& value) { Json::Value rect = value["rect"]; Json::Value output = value["output"]; - return { - .num = num.asInt(), - .name = name.asString(), - .visible = visible.asBool(), - .focused = focused.asBool(), - .urgent = urgent.asBool(), - .rect = parse_rect_from_json(rect), - .output = output.asString(), - }; + std::shared_ptr p; + p->num = num.asInt(); + p->name = name.asString(); + p->visible = visible.asBool(); + p->focused = focused.asBool(); + p->urgent = urgent.asBool(); + p->rect = parse_rect_from_json(rect); + p->output = output.asString(); + return p; } -static output_t parse_output_from_json(const Json::Value& value) { +static std::shared_ptr parse_output_from_json(const Json::Value& value) { Json::Value name = value["name"]; Json::Value active = value["active"]; Json::Value current_workspace = value["current_workspace"]; Json::Value rect = value["rect"]; - return { - .name = name.asString(), - .active = active.asBool(), - .current_workspace = (current_workspace.isNull() ? std::string() : current_workspace.asString()), - .rect = parse_rect_from_json(rect), - }; + std::shared_ptr p; + p->name = name.asString(); + p->active = active.asBool(); + p->current_workspace = (current_workspace.isNull() ? std::string() : current_workspace.asString()); + p->rect = parse_rect_from_json(rect); + return p; } @@ -332,14 +332,14 @@ std::shared_ptr connection::get_tree() const { } -std::vector connection::get_outputs() const { +std::vector< std::shared_ptr > connection::get_outputs() const { #define i3IPC_TYPE_STR "GET_OUTPUTS" auto buf = i3_msg(m_main_socket, ClientMessageType::GET_OUTPUTS); Json::Value root; IPC_JSON_READ(root) IPC_JSON_ASSERT_TYPE_ARRAY(root, "root") - std::vector outputs; + std::vector< std::shared_ptr > outputs; for (auto w : root) { outputs.push_back(parse_output_from_json(w)); @@ -350,14 +350,14 @@ std::vector connection::get_outputs() const { } -std::vector connection::get_workspaces() const { +std::vector< std::shared_ptr > connection::get_workspaces() const { #define i3IPC_TYPE_STR "GET_WORKSPACES" auto buf = i3_msg(m_main_socket, ClientMessageType::GET_WORKSPACES); Json::Value root; IPC_JSON_READ(root) IPC_JSON_ASSERT_TYPE_ARRAY(root, "root") - std::vector workspaces; + std::vector< std::shared_ptr > workspaces; for (auto w : root) { workspaces.push_back(parse_workspace_from_json(w));