multi click not fucked

This commit is contained in:
2026-02-03 00:11:59 +01:00
parent 9898c48c67
commit 9c70065bf6
5 changed files with 10 additions and 6 deletions

View File

@@ -2,8 +2,9 @@
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <string>
#include <map> #include <map>
#include <memory>
#include <string>
#include <sys/types.h> #include <sys/types.h>
#include <vector> #include <vector>
#include "gdkmm/pixbuf.h" #include "gdkmm/pixbuf.h"
@@ -39,6 +40,8 @@ struct NotifyMessage {
int32_t expire_timeout; int32_t expire_timeout;
// Callback to invoke when an action is triggered // Callback to invoke when an action is triggered
std::function<void(const std::string& action_id)> on_action; std::function<void(const std::string& action_id)> on_action;
// Guard to prevent multiple action invocations across mirrors
std::shared_ptr<bool> actionInvoked;
// image data (if any) from dbus // image data (if any) from dbus
std::optional<Glib::RefPtr<Gdk::Pixbuf>> imageData; std::optional<Glib::RefPtr<Gdk::Pixbuf>> imageData;
}; };

View File

@@ -9,7 +9,7 @@
#include "gdkmm/monitor.h" #include "gdkmm/monitor.h"
#include "gtkmm/window.h" #include "gtkmm/window.h"
#define DEFAULT_NOTIFICATION_TIMEOUT 7000 #define DEFAULT_NOTIFICATION_TIMEOUT 5000
class BaseNotification : public Gtk::Window { class BaseNotification : public Gtk::Window {
@@ -35,7 +35,6 @@ class BaseNotification : public Gtk::Window {
void pause_auto_close(); void pause_auto_close();
void resume_auto_close(); void resume_auto_close();
// onClose signal can be added here if needed
protected: protected:
uint64_t notificationId; uint64_t notificationId;

View File

@@ -84,6 +84,7 @@ void NotificationService::handle_notify(const Glib::VariantContainerBase &parame
notify.app_icon = app_icon; notify.app_icon = app_icon;
notify.summary = static_cast<std::string>(summary); notify.summary = static_cast<std::string>(summary);
notify.body = static_cast<std::string>(body); notify.body = static_cast<std::string>(body);
notify.actionInvoked = std::make_shared<bool>(false);
std::vector<std::string> actions_converted; std::vector<std::string> actions_converted;
actions_converted.reserve(actions.size()); actions_converted.reserve(actions.size());

View File

@@ -93,7 +93,7 @@ void NotificationController::showSpotifyNotification(MprisPlayer2Message mpris)
}); });
notification->startAutoClose(10000); notification->startAutoClose(DEFAULT_NOTIFICATION_TIMEOUT);
} }
this->activeNotifications[id] = notifications; this->activeNotifications[id] = notifications;

View File

@@ -88,8 +88,9 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
break; break;
} }
btn->signal_clicked().connect([this, action_id, cb = notify.on_action]() { btn->signal_clicked().connect([this, action_id, cb = notify.on_action, guard = notify.actionInvoked]() {
if (cb) { if (cb && guard && !*guard) {
*guard = true;
cb(action_id); cb(action_id);
this->signal_close.emit(this->notificationId); this->signal_close.emit(this->notificationId);
} }