Merge branch 'Alexays:master' into hyprland/windowcount
This commit is contained in:
@ -2,9 +2,9 @@
|
||||
|
||||
#include <filesystem>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#include "util/json.hpp"
|
||||
@ -19,7 +19,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 +34,16 @@ class IPC {
|
||||
static std::filesystem::path socketFolder_;
|
||||
|
||||
private:
|
||||
void startIPC();
|
||||
void socketListener();
|
||||
void parseIPC(const std::string&);
|
||||
|
||||
std::thread 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
|
||||
|
@ -37,6 +37,8 @@ class Language : public waybar::ALabel, public EventHandler {
|
||||
util::JsonParser parser_;
|
||||
|
||||
Layout layout_;
|
||||
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
@ -28,6 +28,8 @@ class Submap : public waybar::ALabel, public EventHandler {
|
||||
std::string submap_;
|
||||
bool always_on_ = false;
|
||||
std::string default_submap_ = "Default";
|
||||
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
@ -60,6 +60,8 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
|
||||
bool swallowing_;
|
||||
bool fullscreen_;
|
||||
bool focused_;
|
||||
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
@ -83,6 +83,7 @@ class Workspace {
|
||||
Gtk::Button m_button;
|
||||
Gtk::Box m_content;
|
||||
Gtk::Label m_label;
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -55,14 +56,14 @@ class Workspaces : public AModule, public EventHandler {
|
||||
|
||||
static Json::Value createMonitorWorkspaceData(std::string const& name,
|
||||
std::string const& monitor);
|
||||
void removeWorkspace(std::string const& name);
|
||||
void removeWorkspace(std::string const& workspaceString);
|
||||
void setUrgentWorkspace(std::string const& windowaddress);
|
||||
|
||||
// Config
|
||||
void parseConfig(const Json::Value& config);
|
||||
auto populateIconsMap(const Json::Value& formatIcons) -> void;
|
||||
static auto populateBoolConfig(const Json::Value& config, const std::string& key,
|
||||
bool& member) -> void;
|
||||
static auto populateBoolConfig(const Json::Value& config, const std::string& key, bool& member)
|
||||
-> void;
|
||||
auto populateSortByConfig(const Json::Value& config) -> void;
|
||||
auto populateIgnoreWorkspacesConfig(const Json::Value& config) -> void;
|
||||
auto populateFormatWindowSeparatorConfig(const Json::Value& config) -> void;
|
||||
@ -74,10 +75,11 @@ class Workspaces : public AModule, public EventHandler {
|
||||
void onWorkspaceActivated(std::string const& payload);
|
||||
void onSpecialWorkspaceActivated(std::string const& payload);
|
||||
void onWorkspaceDestroyed(std::string const& payload);
|
||||
void onWorkspaceCreated(std::string const& workspaceName,
|
||||
void onWorkspaceCreated(std::string const& payload,
|
||||
Json::Value const& clientsData = Json::Value::nullRef);
|
||||
void onWorkspaceMoved(std::string const& payload);
|
||||
void onWorkspaceRenamed(std::string const& payload);
|
||||
static std::optional<int> parseWorkspaceId(std::string const& workspaceIdStr);
|
||||
|
||||
// monitor events
|
||||
void onMonitorFocused(std::string const& payload);
|
||||
@ -93,11 +95,18 @@ class Workspaces : public AModule, public EventHandler {
|
||||
|
||||
int windowRewritePriorityFunction(std::string const& window_rule);
|
||||
|
||||
// event payload management
|
||||
template <typename... Args>
|
||||
static std::string makePayload(Args const&... args);
|
||||
static std::pair<std::string, std::string> splitDoublePayload(std::string const& payload);
|
||||
static std::tuple<std::string, std::string, std::string> splitTriplePayload(
|
||||
std::string const& payload);
|
||||
|
||||
// Update methods
|
||||
void doUpdate();
|
||||
void removeWorkspacesToRemove();
|
||||
void createWorkspacesToCreate();
|
||||
static std::vector<std::string> getVisibleWorkspaces();
|
||||
static std::vector<int> getVisibleWorkspaces();
|
||||
void updateWorkspaceStates();
|
||||
bool updateWindowsToCreate();
|
||||
|
||||
@ -138,7 +147,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
|
||||
bool m_withIcon;
|
||||
uint64_t m_monitorId;
|
||||
std::string m_activeWorkspaceName;
|
||||
int m_activeWorkspaceId;
|
||||
std::string m_activeSpecialWorkspaceName;
|
||||
std::vector<std::unique_ptr<Workspace>> m_workspaces;
|
||||
std::vector<std::pair<Json::Value, Json::Value>> m_workspacesToCreate;
|
||||
@ -150,6 +159,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
std::mutex m_mutex;
|
||||
const Bar& m_bar;
|
||||
Gtk::Box m_box;
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
Reference in New Issue
Block a user