1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-22 18:15:47 +02:00

Fix notification timer stopping permanently when the screen is locked while a notification is visible

This commit is contained in:
chylex 2022-11-20 13:56:21 +01:00
parent 15d4ec3228
commit 697f4f1569
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
2 changed files with 7 additions and 8 deletions
windows/TweetDuck

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using TweetDuck.Controls;
using TweetDuck.Management;
using TweetDuck.Utils;
using TweetLib.Browser.Interfaces;
@ -53,12 +54,12 @@ protected override bool CanDragWindow {
}
}
private void WindowsSessionManager_LockStateChanged(object? sender, EventArgs e) {
if (WindowsSessionManager.IsLocked) {
PauseNotification(NotificationPauseReason.WindowsSessionLocked);
private void WindowsSessionManager_LockStateChanged(object? sender, bool isLocked) {
if (isLocked) {
this.InvokeAsyncSafe(() => PauseNotification(NotificationPauseReason.WindowsSessionLocked));
}
else {
ResumeNotification(NotificationPauseReason.WindowsSessionLocked);
this.InvokeAsyncSafe(() => ResumeNotification(NotificationPauseReason.WindowsSessionLocked));
}
}

View File

@ -4,8 +4,7 @@
namespace TweetDuck.Management {
static class WindowsSessionManager {
public static bool IsLocked { get; private set; } = false;
public static event EventHandler? LockStateChanged;
public static event EventHandler<bool>? LockStateChanged;
public static void Register() {
Win.Application.ApplicationExit += OnApplicationExit;
@ -27,8 +26,7 @@ private static void OnSessionSwitch(object? sender, SessionSwitchEventArgs e) {
}
private static void SetLocked(bool newState) {
IsLocked = newState;
LockStateChanged?.Invoke(null, EventArgs.Empty);
LockStateChanged?.Invoke(null, newState);
}
}
}