fix bar crashing on monitor add/remove

This commit is contained in:
2026-02-09 13:49:52 +01:00
parent a90d1c2f6c
commit e1217305a5
30 changed files with 1186 additions and 247 deletions

View File

@@ -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);
};