Merge branch 'Alexays:master' into hyprland/windowcount

This commit is contained in:
Khiet Tam Nguyen
2025-05-09 20:46:00 +10:00
committed by GitHub
62 changed files with 1138 additions and 595 deletions

View File

@ -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

View File

@ -37,6 +37,8 @@ class Language : public waybar::ALabel, public EventHandler {
util::JsonParser parser_;
Layout layout_;
IPC& m_ipc;
};
} // namespace waybar::modules::hyprland

View File

@ -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

View File

@ -60,6 +60,8 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
bool swallowing_;
bool fullscreen_;
bool focused_;
IPC& m_ipc;
};
} // namespace waybar::modules::hyprland

View File

@ -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

View File

@ -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