|
2 | 2 |
|
3 | 3 | #include <i3ipc++/ipc.hpp> |
4 | 4 |
|
| 5 | + |
| 6 | +void dump_tree_container(const i3ipc::container_t& c, std::string& prefix) { |
| 7 | + std::cout << prefix << "ID: " << c.id << " (i3's; X11's - " << c.xwindow_id << ")" << std::endl; |
| 8 | + prefix.push_back('\t'); |
| 9 | + std::cout << prefix << "name = \"" << c.name << "\"" << std::endl; |
| 10 | + std::cout << prefix << "type = \"" << c.type << "\"" << std::endl; |
| 11 | + std::cout << prefix << "border = \"" << c.border_raw << "\"" << std::endl; |
| 12 | + std::cout << prefix << "current_border_width = " << c.current_border_width << std::endl; |
| 13 | + std::cout << prefix << "layout = \"" << c.layout_raw << "\"" << std::endl; |
| 14 | + std::cout << prefix << "percent = " << c.percent << std::endl; |
| 15 | + if (c.urgent) { |
| 16 | + std::cout << prefix << "urgent" << std::endl; |
| 17 | + } |
| 18 | + if (c.focused) { |
| 19 | + std::cout << prefix << "focused" << std::endl; |
| 20 | + } |
| 21 | + prefix.push_back('\t'); |
| 22 | + for (auto& n : c.nodes) { |
| 23 | + dump_tree_container(*n, prefix); |
| 24 | + } |
| 25 | + prefix.pop_back(); |
| 26 | + prefix.pop_back(); |
| 27 | +} |
| 28 | + |
| 29 | + |
5 | 30 | int main() { |
6 | | - i3ipc::I3Connection conn; |
| 31 | + i3ipc::connection conn; |
7 | 32 | for (auto& w : conn.get_workspaces()) { |
8 | | - std::cout << '#' << std::hex << w.num << std::dec |
9 | | - << "\n\tName: " << w.name |
10 | | - << "\n\tVisible: " << w.visible |
11 | | - << "\n\tFocused: " << w.focused |
12 | | - << "\n\tUrgent: " << w.urgent |
| 33 | + std::cout << '#' << std::hex << w->num << std::dec |
| 34 | + << "\n\tName: " << w->name |
| 35 | + << "\n\tVisible: " << w->visible |
| 36 | + << "\n\tFocused: " << w->focused |
| 37 | + << "\n\tUrgent: " << w->urgent |
13 | 38 | << "\n\tRect: " |
14 | | - << "\n\t\tX: " << w.rect.x |
15 | | - << "\n\t\tY: " << w.rect.y |
16 | | - << "\n\t\tWidth: " << w.rect.width |
17 | | - << "\n\t\tHeight: " << w.rect.height |
18 | | - << "\n\tOutput: " << w.output |
| 39 | + << "\n\t\tX: " << w->rect.x |
| 40 | + << "\n\t\tY: " << w->rect.y |
| 41 | + << "\n\t\tWidth: " << w->rect.width |
| 42 | + << "\n\t\tHeight: " << w->rect.height |
| 43 | + << "\n\tOutput: " << w->output |
19 | 44 | << std::endl; |
20 | 45 | } |
| 46 | + std::string prefix_buf; |
| 47 | + dump_tree_container(*conn.get_tree(), prefix_buf); |
| 48 | + |
21 | 49 | return 0; |
22 | 50 | } |
0 commit comments