Compare commits

...

3 Commits

Author SHA1 Message Date
German Lashevich
ae5a2c345d Fix build issues
- `std::copy_n` requires to #include <algorithm>
- `std::optional` requires C++17 or newer
2022-06-27 21:17:21 +02:00
Francesco Galizzi
eaa8a3ff3f Solve issue #35 2022-06-27 21:17:21 +02:00
a66f24888f Handle "move" workspace event 2021-12-04 13:40:29 +01:00
4 changed files with 11 additions and 7 deletions

View File

@@ -57,7 +57,7 @@ target_link_libraries(i3ipc++
) )
target_compile_options(i3ipc++ target_compile_options(i3ipc++
PRIVATE -std=c++11 -Wall -Wextra -Wno-unused-parameter PRIVATE -std=c++17 -Wall -Wextra -Wno-unused-parameter
) )
target_compile_definitions(i3ipc++ target_compile_definitions(i3ipc++

View File

@@ -30,8 +30,8 @@ std::string get_socketpath();
* Primitive of rectangle * Primitive of rectangle
*/ */
struct rect_t { struct rect_t {
uint32_t x; ///< Position on X axis int32_t x; ///< Position on X axis
uint32_t y; ///< Position on Y axis int32_t y; ///< Position on Y axis
uint32_t width; ///< Width of rectangle uint32_t width; ///< Width of rectangle
uint32_t height; ///< Height of rectangle uint32_t height; ///< Height of rectangle
}; };
@@ -95,6 +95,7 @@ enum class WorkspaceEventType : char {
RENAME = 'r', ///< Renamed RENAME = 'r', ///< Renamed
RELOAD = 'l', ///< Reloaded RELOAD = 'l', ///< Reloaded
RESTORED = 's', ///< Restored RESTORED = 's', ///< Restored
MOVE = 'm', ///< Moved (to output)
}; };
/** /**

View File

@@ -8,6 +8,7 @@ extern "C" {
#include <errno.h> #include <errno.h>
} }
#include <algorithm>
#include <cstring> #include <cstring>
#include <ios> #include <ios>
@@ -30,7 +31,7 @@ errno_error::errno_error(const std::string& msg) : ipc_error(format_errno(msg))
static const std::string g_i3_ipc_magic = "i3-ipc"; static const std::string g_i3_ipc_magic = "i3-ipc";
buf_t::buf_t(uint32_t payload_size) : buf_t::buf_t(uint32_t payload_size) :
data(sizeof(header_t) + payload_size, 0), data(sizeof(header_t) + payload_size, 0),
header(reinterpret_cast<header_t*>(data.data())), header(reinterpret_cast<header_t*>(data.data())),
payload(reinterpret_cast<char*>(data.data() + sizeof(header_t))) payload(reinterpret_cast<char*>(data.data() + sizeof(header_t)))
@@ -54,7 +55,7 @@ int32_t i3_connect(const std::string& socket_path) {
} }
(void)fcntl(sockfd, F_SETFD, FD_CLOEXEC); // What for? (void)fcntl(sockfd, F_SETFD, FD_CLOEXEC); // What for?
struct sockaddr_un addr; struct sockaddr_un addr;
memset(&addr, 0, sizeof(struct sockaddr_un)); memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_LOCAL; addr.sun_family = AF_LOCAL;

View File

@@ -45,8 +45,8 @@ std::vector<std::ostream*> g_logging_err_outs = {
inline rect_t parse_rect_from_json(const Json::Value& value) { inline rect_t parse_rect_from_json(const Json::Value& value) {
return { return {
.x = value["x"].asUInt(), .x = value["x"].asInt(),
.y = value["y"].asUInt(), .y = value["y"].asInt(),
.width = value["width"].asUInt(), .width = value["width"].asUInt(),
.height = value["height"].asUInt(), .height = value["height"].asUInt(),
}; };
@@ -355,6 +355,8 @@ connection::connection(const std::string& socket_path) : m_main_socket(i3_conne
ev.type = WorkspaceEventType::RELOAD; ev.type = WorkspaceEventType::RELOAD;
} else if (change == "restored") { } else if (change == "restored") {
ev.type = WorkspaceEventType::RESTORED; ev.type = WorkspaceEventType::RESTORED;
} else if(change == "move") {
ev.type = WorkspaceEventType::MOVE;
} else { } else {
I3IPC_WARN("Unknown workspace event type " << change) I3IPC_WARN("Unknown workspace event type " << change)
break; break;