Hyprland IPC improvements

Fixes IPC being blocked at shutdown
This commit is contained in:
zjeffer
2025-02-19 00:58:08 +01:00
parent c32d5e3883
commit 5b8839ab5c
12 changed files with 188 additions and 154 deletions

View File

@ -5,6 +5,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <utility>
#include "util/json.hpp"
@ -19,7 +20,9 @@ class EventHandler {
class IPC {
public:
IPC() { startIPC(); }
IPC();
~IPC();
static IPC& inst();
void registerForIPC(const std::string& ev, EventHandler* ev_handler);
void unregisterForIPC(EventHandler* handler);
@ -32,14 +35,16 @@ class IPC {
static std::filesystem::path socketFolder_;
private:
void startIPC();
void socketListener();
void parseIPC(const std::string&);
std::jthread ipcThread_;
std::mutex callbackMutex_;
util::JsonParser parser_;
std::list<std::pair<std::string, EventHandler*>> callbacks_;
int socketfd_; // the hyprland socket file descriptor
bool running_ = true;
};
inline std::unique_ptr<IPC> gIPC;
inline bool modulesReady = false;
}; // namespace waybar::modules::hyprland