fix bar crashing on monitor add/remove
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "sigc++/signal.h"
|
||||
|
||||
class BluetoothService {
|
||||
inline static BluetoothService *instance = nullptr;
|
||||
|
||||
public:
|
||||
sigc::signal<void(bool)> powerStateChangedSignal;
|
||||
sigc::signal<void(bool)> isDiscoveringChangedSignal;
|
||||
|
||||
bool getPowerState();
|
||||
bool getIsDiscovering();
|
||||
|
||||
void togglePowerState();
|
||||
void toggleIsDiscovering();
|
||||
|
||||
static BluetoothService *getInstance() {
|
||||
if (BluetoothService::instance == nullptr) {
|
||||
|
||||
BluetoothService::instance = new BluetoothService();
|
||||
}
|
||||
return BluetoothService::instance;
|
||||
}
|
||||
|
||||
private:
|
||||
BluetoothService();
|
||||
|
||||
GDBusProxy *adapter_proxy = nullptr;
|
||||
|
||||
std::vector<std::string> getDeviceObjectPaths();
|
||||
bool powerState = false;
|
||||
bool isDiscovering = false;
|
||||
|
||||
void onPropertyChanged(GDBusProxy *proxy,
|
||||
GVariant *changed_properties,
|
||||
const gchar *const *invalidated_properties,
|
||||
gpointer user_data);
|
||||
|
||||
static void onPropertyChangedStatic(GDBusProxy *proxy,
|
||||
GVariant *changed_properties,
|
||||
const gchar *const *invalidated_properties,
|
||||
gpointer user_data);
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#include "gdkmm/monitor.h"
|
||||
|
||||
class NotificationController {
|
||||
static std::shared_ptr<NotificationController> instance;
|
||||
inline static std::shared_ptr<NotificationController> instance = nullptr;
|
||||
|
||||
public:
|
||||
static std::shared_ptr<NotificationController> getInstance() {
|
||||
if (!NotificationController::instance) {
|
||||
if (NotificationController::instance == nullptr) {
|
||||
NotificationController::instance = std::shared_ptr<NotificationController>(new NotificationController());
|
||||
}
|
||||
return NotificationController::instance;
|
||||
@@ -26,12 +26,15 @@ class NotificationController {
|
||||
void showNotificationOnAllMonitors(NotifyMessage notify);
|
||||
void showCopyNotification(NotifyMessage notify);
|
||||
|
||||
void addMonitor(std::shared_ptr<Gdk::Monitor> monitor);
|
||||
void removeMonitor(std::shared_ptr<Gdk::Monitor> monitor);
|
||||
|
||||
private:
|
||||
uint64_t globalNotificationId = 1;
|
||||
std::map<uint64_t, std::vector<std::shared_ptr<BaseNotification>>> activeNotifications;
|
||||
std::map<uint64_t, int> hoverCounts;
|
||||
NotificationController();
|
||||
std::vector<std::shared_ptr<Gdk::Monitor>> activeMonitors;
|
||||
std::map<std::string, std::shared_ptr<Gdk::Monitor>> activeMonitors;
|
||||
void updateHoverState(uint64_t notificationId, bool isHovered);
|
||||
void closeNotification(uint64_t notificationId);
|
||||
};
|
||||
Reference in New Issue
Block a user