Skip to content

Commit 029d22a

Browse files
committed
Did the merge work?
2 parents 439740a + c2e29dc commit 029d22a

File tree

8 files changed

+382
-135
lines changed

8 files changed

+382
-135
lines changed

CHANGELOG

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
0.2.1
2+
+ Added example of event handling
3+
* Fixed SIGSEGV in parse_*_from_json functions
4+
5+
0.2.0
6+
+ Implemented GET_TREE (i3ipc::connection::get_tree())
7+
8+
~ Shipping all available payload with workspace and window events (issue #2)
9+
~ i3ipc::I3Connection renamed to i3ipc::connection
10+
11+
~ Internal refreactoring
12+
13+
* Fixing failed build: Parts of a struct were initialised in wrong order, C99-style designated initialisers did not prevent this from causing an error [mox]
14+
* Minor documentation and code fixies

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ include_directories(
2929
)
3030

3131
link_directories(
32-
${SIBCPP_LIBRARY_DIRS}
32+
${SIGCPP_LIBRARY_DIRS}
3333
3rd/jsoncpp/src/lib_json/
3434
)
3535

@@ -42,6 +42,7 @@ add_library(i3ipc++_static STATIC ${SRC})
4242

4343
set(I3IPCpp_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR})
4444
set(I3IPCpp_INCLUDE_DIRS
45+
${SIGCPP_INCLUDE_DIRS}
4546
3rd/auss/include
4647
${CMAKE_CURRENT_SOURCE_DIR}/include/
4748
)

examples/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
1515

1616
add_executable(workspaces workspaces.cpp)
1717
target_link_libraries(workspaces ${I3IPCpp_LIBRARIES})
18+
19+
add_executable(events events.cpp)
20+
target_link_libraries(events ${I3IPCpp_LIBRARIES})

examples/events.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <iostream>
2+
3+
#include <i3ipc++/ipc.hpp>
4+
5+
6+
int main() {
7+
i3ipc::connection conn;
8+
conn.subscribe(i3ipc::ET_WORKSPACE | i3ipc::ET_WINDOW);
9+
10+
conn.signal_workspace_event.connect([](const i3ipc::workspace_event_t& ev) {
11+
std::cout << "workspace_event: " << (char)ev.type << std::endl;
12+
});
13+
conn.signal_window_event.connect([](const i3ipc::window_event_t& ev) {
14+
std::cout << "window_event: " << (char)ev.type << std::endl;
15+
});
16+
17+
// Don't forget this:
18+
conn.prepare_to_event_handling();
19+
20+
while (true) {
21+
conn.handle_event();
22+
}
23+
24+
return 0;
25+
}

examples/workspaces.cpp

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,49 @@
22

33
#include <i3ipc++/ipc.hpp>
44

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+
530
int main() {
6-
i3ipc::I3Connection conn;
31+
i3ipc::connection conn;
732
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
1338
<< "\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
1944
<< std::endl;
2045
}
46+
std::string prefix_buf;
47+
dump_tree_container(*conn.get_tree(), prefix_buf);
48+
2149
return 0;
2250
}

include/i3ipc++/ipc-util.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ namespace i3ipc {
2323
*/
2424
struct header_t {
2525
/* 6 = strlen(I3_IPC_MAGIC) */
26-
char magic[6]; /**< Magic string @see I3_IPC_MAGIC */
27-
uint32_t size; /**< Size of payload */
28-
uint32_t type; /**< Message type */
26+
char magic[6]; ///< Magic string @see I3_IPC_MAGIC
27+
uint32_t size; ///< Size of payload
28+
uint32_t type; ///< Message type
2929
} __attribute__ ((packed));
3030

3131

@@ -84,8 +84,8 @@ enum class ReplyType : uint32_t {
8484
* @brief i3 IPC message buffer
8585
*/
8686
struct buf_t {
87-
uint32_t size; /**< @brief Size of whole buffer */
88-
uint8_t* data; /**< @brief Pointer to the message */
87+
uint32_t size; ///< @brief Size of whole buffer
88+
uint8_t* data; ///< @brief Pointer to the message
8989

9090
/**
9191
* @brief i3 IPC message header

0 commit comments

Comments
 (0)