1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-01 08:34:11 +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.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Controls;
using TweetDuck.Management; using TweetDuck.Management;
using TweetDuck.Utils; using TweetDuck.Utils;
using TweetLib.Browser.Interfaces; using TweetLib.Browser.Interfaces;
@ -53,12 +54,12 @@ protected override bool CanDragWindow {
} }
} }
private void WindowsSessionManager_LockStateChanged(object? sender, EventArgs e) { private void WindowsSessionManager_LockStateChanged(object? sender, bool isLocked) {
if (WindowsSessionManager.IsLocked) { if (isLocked) {
PauseNotification(NotificationPauseReason.WindowsSessionLocked); this.InvokeAsyncSafe(() => PauseNotification(NotificationPauseReason.WindowsSessionLocked));
} }
else { else {
ResumeNotification(NotificationPauseReason.WindowsSessionLocked); this.InvokeAsyncSafe(() => ResumeNotification(NotificationPauseReason.WindowsSessionLocked));
} }
} }

View File

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