Compare commits
13 Commits
fabs
...
add-wsmove
| Author | SHA1 | Date | |
|---|---|---|---|
| a7ae06060a | |||
|
|
f8d5903f42 | ||
|
|
50ae7287c2 | ||
|
|
9e294ff8c3 | ||
|
|
aa131bd08d | ||
|
|
58e316c65b | ||
|
|
3bac0dd37d | ||
|
|
1bf594d1f2 | ||
|
|
ee4ce3ddc5 | ||
|
|
7c2f465cbb | ||
|
|
2caac6e083 | ||
|
|
83f4e80175 | ||
|
|
bd71b09d9b |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,4 +1,8 @@
|
|||||||
build
|
build/
|
||||||
doc
|
doc/
|
||||||
*.sublime-workspace
|
*.sublime-workspace
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
.ccls*
|
||||||
|
*.o
|
||||||
|
compile_commands.*
|
||||||
|
|||||||
@@ -1,15 +1,23 @@
|
|||||||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
|
||||||
project(i3ipc++)
|
project(i3ipc++)
|
||||||
|
|
||||||
string(TIMESTAMP I3IPCppBUILD_DATETIME "%Y-%m-%d %H:%M:%S")
|
|
||||||
|
|
||||||
option(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
|
option(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
|
||||||
option(I3IPCpp_BUILD_EXAMPLES "Build example executables" OFF)
|
option(I3IPCpp_BUILD_EXAMPLES "Build example executables" OFF)
|
||||||
|
|
||||||
find_package(PkgConfig)
|
|
||||||
pkg_check_modules(SIGCPP REQUIRED sigc++-2.0)
|
|
||||||
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
|
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SRC src/*.cpp)
|
||||||
|
add_library(i3ipc++ ${SRC})
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
|
||||||
|
pkg_check_modules(SIGCPP sigc++-3.0)
|
||||||
|
if(SIGCPP_FOUND)
|
||||||
|
target_compile_definitions(i3ipc++
|
||||||
|
PUBLIC I3CPP_IPC_SIGCPP3=${SIGCPP_FOUND}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
pkg_check_modules(SIGCPP REQUIRED sigc++-2.0)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(I3IPCpp_INCLUDE_DIRS
|
set(I3IPCpp_INCLUDE_DIRS
|
||||||
${SIGCPP_INCLUDE_DIRS}
|
${SIGCPP_INCLUDE_DIRS}
|
||||||
@@ -33,8 +41,6 @@ set(I3IPCpp_LIBRARIES
|
|||||||
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -DDEBUG")
|
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -DDEBUG")
|
||||||
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||||
|
|
||||||
file(GLOB_RECURSE SRC src/*.cpp)
|
|
||||||
add_library(i3ipc++ ${SRC})
|
|
||||||
|
|
||||||
target_include_directories(i3ipc++
|
target_include_directories(i3ipc++
|
||||||
PUBLIC
|
PUBLIC
|
||||||
@@ -57,11 +63,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++
|
|
||||||
PRIVATE I3IPC_BUILD_DATETIME="${I3IPCppBUILD_DATETIME}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ An implementation of i3 IPC in C++11.
|
|||||||
* C++11 compiler
|
* C++11 compiler
|
||||||
* sigc++ 2.0
|
* sigc++ 2.0
|
||||||
* jsoncpp
|
* jsoncpp
|
||||||
|
* i3 (for i3/ipc.h)
|
||||||
|
|
||||||
## Using
|
## Using
|
||||||
Yet the only way of using is to add this repo as a submodule
|
Yet the only way of using is to add this repo as a submodule
|
||||||
|
|||||||
@@ -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)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -369,14 +370,21 @@ public:
|
|||||||
* Disconnect the event socket
|
* Disconnect the event socket
|
||||||
*/
|
*/
|
||||||
void disconnect_event_socket();
|
void disconnect_event_socket();
|
||||||
|
#ifdef I3CPP_IPC_SIGCPP3
|
||||||
sigc::signal<void, const workspace_event_t&> signal_workspace_event; ///< Workspace event signal
|
sigc::signal<void(const workspace_event_t&)> signal_workspace_event; ///< Workspace event signal
|
||||||
|
sigc::signal<void()> signal_output_event; ///< Output event signal
|
||||||
|
sigc::signal<void(const mode_t&)> signal_mode_event; ///< Output mode event signal
|
||||||
|
sigc::signal<void(const window_event_t&)> signal_window_event; ///< Window event signal
|
||||||
|
sigc::signal<void(const bar_config_t&)> signal_barconfig_update_event; ///< Barconfig update event signal
|
||||||
|
sigc::signal<void(const binding_t&)> signal_binding_event; ///< Binding event signal
|
||||||
|
sigc::signal<void(EventType, const std::shared_ptr<const buf_t>&)> signal_event; ///< i3 event signal @note Default handler routes event to signal according to type
|
||||||
|
#else
|
||||||
|
sigc::signal<void, const workspace_event_t&> signal_workspace_event; ///< Workspace event signal
|
||||||
sigc::signal<void> signal_output_event; ///< Output event signal
|
sigc::signal<void> signal_output_event; ///< Output event signal
|
||||||
sigc::signal<void, const mode_t&> signal_mode_event; ///< Output mode event signal
|
sigc::signal<void, const mode_t&> signal_mode_event; ///< Output mode event signal
|
||||||
sigc::signal<void, const window_event_t&> signal_window_event; ///< Window event signal
|
sigc::signal<void, const window_event_t&> signal_window_event; ///< Window event signal
|
||||||
sigc::signal<void, const bar_config_t&> signal_barconfig_update_event; ///< Barconfig update event signal
|
sigc::signal<void, const bar_config_t&> signal_barconfig_update_event; ///< Barconfig update event signal
|
||||||
sigc::signal<void, const binding_t&> signal_binding_event; ///< Binding event signal
|
#endif
|
||||||
sigc::signal<void, EventType, const std::shared_ptr<const buf_t>&> signal_event; ///< i3 event signal @note Default handler routes event to signal according to type
|
|
||||||
private:
|
private:
|
||||||
const int32_t m_main_socket;
|
const int32_t m_main_socket;
|
||||||
int32_t m_event_socket;
|
int32_t m_event_socket;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
10
src/ipc.cpp
10
src/ipc.cpp
@@ -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(),
|
||||||
};
|
};
|
||||||
@@ -325,7 +325,7 @@ std::string get_socketpath() {
|
|||||||
pclose(in);
|
pclose(in);
|
||||||
str = str_buf;
|
str = str_buf;
|
||||||
}
|
}
|
||||||
if (str.back() == '\n') {
|
if (str.length() > 0 && str.back() == '\n') {
|
||||||
str.pop_back();
|
str.pop_back();
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
@@ -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;
|
||||||
@@ -661,7 +663,7 @@ const version_t& get_version() {
|
|||||||
#define I3IPC_VERSION_MINOR 5
|
#define I3IPC_VERSION_MINOR 5
|
||||||
#define I3IPC_VERSION_PATCH 0
|
#define I3IPC_VERSION_PATCH 0
|
||||||
static version_t version = {
|
static version_t version = {
|
||||||
.human_readable = auss_t() << I3IPC_VERSION_MAJOR << '.' << I3IPC_VERSION_MINOR << '.' << I3IPC_VERSION_PATCH << " (built on " << I3IPC_BUILD_DATETIME << ")",
|
.human_readable = auss_t() << I3IPC_VERSION_MAJOR << '.' << I3IPC_VERSION_MINOR << '.' << I3IPC_VERSION_PATCH,
|
||||||
.loaded_config_file_name = std::string(),
|
.loaded_config_file_name = std::string(),
|
||||||
.major = I3IPC_VERSION_MAJOR,
|
.major = I3IPC_VERSION_MAJOR,
|
||||||
.minor = I3IPC_VERSION_MINOR,
|
.minor = I3IPC_VERSION_MINOR,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
auto buff = i3_pack(ClientMessageType::COMMAND, "exit");
|
auto buff = i3_pack(ClientMessageType::COMMAND, "exit");
|
||||||
auss_t auss;
|
auss_t auss;
|
||||||
auss << std::hex;
|
auss << std::hex;
|
||||||
for (uint32_t i = 0; i < buff->size; i++) {
|
for (uint32_t i = 0; i < buff->data.size(); i++) {
|
||||||
if (buff->data[i] < 0x10) {
|
if (buff->data[i] < 0x10) {
|
||||||
auss << '0';
|
auss << '0';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user