fix bar crashing on monitor add/remove
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
#define NUM_WORKSPACES 7
|
||||
|
||||
class HyprlandService {
|
||||
inline static HyprlandService *instance = nullptr;
|
||||
static inline std::shared_ptr<HyprlandService> instance;
|
||||
|
||||
|
||||
public:
|
||||
struct Client {
|
||||
@@ -49,9 +50,9 @@ class HyprlandService {
|
||||
std::shared_ptr<Bar> bar;
|
||||
};
|
||||
|
||||
static HyprlandService *getInstance() {
|
||||
static std::shared_ptr<HyprlandService> getInstance() {
|
||||
if (!instance) {
|
||||
instance = new HyprlandService();
|
||||
instance = std::shared_ptr<HyprlandService>(new HyprlandService());
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
@@ -60,7 +61,12 @@ class HyprlandService {
|
||||
|
||||
void addBar(std::shared_ptr<Bar> bar, std::string monitorName);
|
||||
|
||||
sigc::signal<void(std::string)> &signal_monitor_added() { return m_signal_monitor_added; }
|
||||
sigc::signal<void(std::string)> &signal_monitor_removed() { return m_signal_monitor_removed; }
|
||||
|
||||
private:
|
||||
HyprlandService();
|
||||
|
||||
enum SocketEventType {
|
||||
WORKSPACE_CHANGED,
|
||||
|
||||
@@ -72,6 +78,7 @@ class HyprlandService {
|
||||
|
||||
FOCUSED_MONITOR,
|
||||
MONITOR_REMOVED,
|
||||
MONITOR_ADDED,
|
||||
};
|
||||
|
||||
std::map<std::string, SocketEventType> socketEventTypeMap = {
|
||||
@@ -83,7 +90,9 @@ class HyprlandService {
|
||||
{"urgent", URGENT},
|
||||
{"focusedmon", FOCUSED_MONITOR},
|
||||
{"monitorremoved", MONITOR_REMOVED},
|
||||
{"monitoradded", MONITOR_ADDED},
|
||||
};
|
||||
|
||||
void onWorkspaceChanged(int workspaceId);
|
||||
void onFocusedMonitorChanged(std::string monitorData);
|
||||
void onOpenWindow(std::string windowData);
|
||||
@@ -92,16 +101,15 @@ class HyprlandService {
|
||||
void onUrgent(std::string windowAddress);
|
||||
void onActiveWindowChanged(std::string windowAddress);
|
||||
void onMonitorRemoved(std::string monitorName);
|
||||
// void onMonitorAdded(std::string monitorName);
|
||||
void onMonitorAdded(std::string monitorName);
|
||||
|
||||
HyprlandService();
|
||||
std::map<std::string, std::shared_ptr<Monitor>> monitors;
|
||||
std::map<int, std::shared_ptr<Workspace>> workspaces;
|
||||
std::map<std::string, std::shared_ptr<Client>> clients;
|
||||
|
||||
/// maybe refactor into reusable class
|
||||
std::string socketBuffer;
|
||||
int socketFd;
|
||||
int socketFd = -1;
|
||||
///
|
||||
|
||||
void bindHyprlandSocket();
|
||||
@@ -112,4 +120,7 @@ class HyprlandService {
|
||||
void refreshIndicator(std::shared_ptr<Workspace> workspace);
|
||||
|
||||
void handleSocketMessage(SocketHelper::SocketMessage message);
|
||||
|
||||
sigc::signal<void(std::string)> m_signal_monitor_added;
|
||||
sigc::signal<void(std::string)> m_signal_monitor_removed;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user