mirror of
https://github.com/quickshell-mirror/quickshell.git
synced 2026-10-27 02:54:36 +00:00
service/notifications: emit NotificationClosed after Notify returns
This commit is contained in:
2 files changed
+16
-3
No files matched your search
@@ -9,3 +9,4 @@
|
||||
- Fixed potential crashes from usage of `WindowsetProjection.screens` during monitor unplug.
|
||||
- Fixed crashes from accessing freed objects laundered through a `ScriptModel`.
|
||||
- Fixed crashes when a wifi network disappear.
|
||||
- Fixed unhandled notifications sending `NotificationClosed` out of order.
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <qdbusservicewatcher.h>
|
||||
#include <qlogging.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobjectdefs.h>
|
||||
#include <qqmlengine.h>
|
||||
#include <qtmetamacros.h>
|
||||
#include <qtypes.h>
|
||||
@@ -192,19 +194,29 @@ uint NotificationServer::Notify(
|
||||
|
||||
notification->updateProperties(appName, appIcon, summary, body, actions, hints, expireTimeout);
|
||||
|
||||
auto id = notification->id();
|
||||
|
||||
if (!old) {
|
||||
emit this->notification(notification);
|
||||
|
||||
if (!notification->isTracked()) {
|
||||
emit this->NotificationClosed(notification->id(), notification->closeReason());
|
||||
auto closeReason = notification->closeReason();
|
||||
|
||||
// Emit NotificationClosed after Notify returns
|
||||
QMetaObject::invokeMethod(
|
||||
this,
|
||||
[this, id, closeReason]() { emit this->NotificationClosed(id, closeReason); },
|
||||
Qt::QueuedConnection
|
||||
);
|
||||
|
||||
delete notification;
|
||||
} else {
|
||||
this->idMap.insert(notification->id(), notification);
|
||||
this->idMap.insert(id, notification);
|
||||
this->mNotifications.insertObject(notification);
|
||||
}
|
||||
}
|
||||
|
||||
return notification->id();
|
||||
return id;
|
||||
}
|
||||
|
||||
} // namespace qs::service::notifications
|
||||
Reference in new issue
Block a user