Public Access
Fix Toast timing and alert once per shown Toast
- ToastQueue compared times unsigned: a Toast stamped a few ms after the main loop read the clock looked expired, so Toasts were skipped or shown late and bursts chained wrongly - Notifier now beeps and flashes when each Toast appears instead of when the Notification arrives, so a burst alerts once per Toast Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -9,7 +9,7 @@ void ToastQueue::push(const std::string& text, NotificationLevel level, uint32_t
|
||||
queue_.erase(queue_.begin() + (showing_ && queue_.size() > 1 ? 1 : 0));
|
||||
if (!showing_) changed_ = true;
|
||||
}
|
||||
queue_.push_back({text, level});
|
||||
queue_.push_back({text, level, nextId_++});
|
||||
if (!showing_) {
|
||||
showing_ = true;
|
||||
shownAtMs_ = nowMs;
|
||||
@@ -19,7 +19,9 @@ void ToastQueue::push(const std::string& text, NotificationLevel level, uint32_t
|
||||
|
||||
const Toast* ToastQueue::current(uint32_t nowMs) {
|
||||
if (!showing_) return nullptr;
|
||||
if (nowMs - shownAtMs_ >= durationMs_) dismiss(shownAtMs_ + durationMs_);
|
||||
// Signed: a caller's clock reading may be a few ms older than the Toast's stamp.
|
||||
int32_t elapsed = static_cast<int32_t>(nowMs - shownAtMs_);
|
||||
if (elapsed >= static_cast<int32_t>(durationMs_)) dismiss(shownAtMs_ + durationMs_);
|
||||
return showing_ ? &queue_.front() : nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user