refactor(IPC): use sigc signal

This commit is contained in:
Alex
2019-04-19 11:09:06 +02:00
parent 4c8f4f82dc
commit bb1cf7570e
9 changed files with 140 additions and 91 deletions

View File

@ -1,5 +1,6 @@
#pragma once
#include <sigc++/sigc++.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
@ -20,9 +21,12 @@ class Ipc {
std::string payload;
};
struct ipc_response sendCmd(uint32_t type, const std::string &payload = "") const;
void subscribe(const std::string &payload) const;
struct ipc_response handleEvent() const;
sigc::signal<void, const struct ipc_response> signal_event;
sigc::signal<void, const struct ipc_response> signal_cmd;
void sendCmd(uint32_t type, const std::string &payload = "") const;
void subscribe(const std::string &payload) const;
void handleEvent() const;
protected:
static inline const std::string ipc_magic_ = "i3-ipc";

View File

@ -17,6 +17,7 @@ class Mode : public ALabel {
auto update() -> void;
private:
void onEvent(const struct Ipc::ipc_response);
void worker();
const Bar& bar_;

View File

@ -18,6 +18,8 @@ class Window : public ALabel {
auto update() -> void;
private:
void onEvent(const struct Ipc::ipc_response);
void onCmd(const struct Ipc::ipc_response);
void worker();
std::tuple<int, std::string> getFocusedNode(Json::Value nodes);
void getFocusedWindow();

View File

@ -20,6 +20,7 @@ class Workspaces : public IModule {
operator Gtk::Widget&();
private:
void onCmd(const struct Ipc::ipc_response);
void worker();
void addWorkspace(const Json::Value&);
void onButtonReady(const Json::Value&, Gtk::Button&);