diff --git a/Sources/SmartTaskbar.Win10/Worker/Engine.cs b/Sources/SmartTaskbar.Win10/Worker/Engine.cs index 5f9f558..2a451e6 100644 --- a/Sources/SmartTaskbar.Win10/Worker/Engine.cs +++ b/Sources/SmartTaskbar.Win10/Worker/Engine.cs @@ -13,6 +13,7 @@ internal sealed class Engine private static int _timerCount; private static TaskbarInfo _taskbar; + private static readonly HashSet NonMouseOverShowHandleSet = new HashSet(); private static readonly HashSet DesktopHandleSet = new HashSet(); private static readonly Stack LastHideForegroundHandle = new Stack(); private static ForegroundWindowInfo _currentForegroundWindow; @@ -53,7 +54,7 @@ private static void Timer_Tick(object sender, EventArgs e) Hooker.SetHook(_taskbar.Handle); } - switch (_taskbar.CheckIfMouseOver()) + switch (_taskbar.CheckIfMouseOver(NonMouseOverShowHandleSet)) { case TaskbarBehavior.DoNothing: break; @@ -78,6 +79,7 @@ private static void Timer_Tick(object sender, EventArgs e) _timerCount = 0; DesktopHandleSet.Clear(); + NonMouseOverShowHandleSet.Clear(); Hooker.ResetHook(); } diff --git a/Sources/SmartTaskbar.Win10/Worker/TaskbarHelper.cs b/Sources/SmartTaskbar.Win10/Worker/TaskbarHelper.cs index 2bb1223..b65e15b 100644 --- a/Sources/SmartTaskbar.Win10/Worker/TaskbarHelper.cs +++ b/Sources/SmartTaskbar.Win10/Worker/TaskbarHelper.cs @@ -180,9 +180,9 @@ public static void ShowTaskar(this in TaskbarInfo taskbar) /// Mouse over the taskbar or a specific window, /// it will only cause the taskbar to show or do nothing. /// - /// /// - public static TaskbarBehavior CheckIfMouseOver(this in TaskbarInfo taskbar) + public static TaskbarBehavior CheckIfMouseOver(this in TaskbarInfo taskbar, + HashSet nonMouseOverShowHandleSet) { // Get mouse coordinates if (!GetCursorPos(out var point)) @@ -214,11 +214,19 @@ public static TaskbarBehavior CheckIfMouseOver(this in TaskbarInfo taskbar) && mouseOverRect.right <= taskbar.Rect.right + TrayTolerance) return TaskbarBehavior.DoNothing; - // If it is a thumbnail of the floating taskbar icon, - // the taskbar needs to be displayed. - return mouseOverHandle.GetClassName() is TrayTaskListThumbnailWnd - ? TaskbarBehavior.Show - : TaskbarBehavior.Pending; + if (nonMouseOverShowHandleSet.Contains(mouseOverHandle)) + return TaskbarBehavior.Pending; + + switch (mouseOverHandle.GetClassName()) + { + // If it is a thumbnail of the floating taskbar icon, + // the taskbar needs to be displayed. + case TrayTaskListThumbnailWnd: + return TaskbarBehavior.Show; + default: + nonMouseOverShowHandleSet.Add(mouseOverHandle); + return TaskbarBehavior.Pending; + } } public static bool CheckIfWindowShouldHideTaskbar(this in TaskbarInfo taskbar, IntPtr foregroundHandle) diff --git a/Sources/SmartTaskbar/Worker/Engine.cs b/Sources/SmartTaskbar/Worker/Engine.cs index f5a6f8e..e0be923 100644 --- a/Sources/SmartTaskbar/Worker/Engine.cs +++ b/Sources/SmartTaskbar/Worker/Engine.cs @@ -11,6 +11,7 @@ internal sealed class Engine private static int _timerCount; private static TaskbarInfo _taskbar; + private static readonly HashSet NonMouseOverShowHandleSet = new(); private static readonly HashSet DesktopHandleSet = new(); private static readonly Stack LastHideForegroundHandle = new(); private static ForegroundWindowInfo _currentForegroundWindow; @@ -46,7 +47,7 @@ private static void Timer_Tick(object sender, EventArgs e) return; } - switch (_taskbar.CheckIfMouseOver()) + switch (_taskbar.CheckIfMouseOver(NonMouseOverShowHandleSet)) { case TaskbarBehavior.DoNothing: break; @@ -71,6 +72,7 @@ private static void Timer_Tick(object sender, EventArgs e) _timerCount = 0; DesktopHandleSet.Clear(); + NonMouseOverShowHandleSet.Clear(); } private static void CheckCurrentWindow() diff --git a/Sources/SmartTaskbar/Worker/TaskbarHelper.cs b/Sources/SmartTaskbar/Worker/TaskbarHelper.cs index d135495..2c78142 100644 --- a/Sources/SmartTaskbar/Worker/TaskbarHelper.cs +++ b/Sources/SmartTaskbar/Worker/TaskbarHelper.cs @@ -176,9 +176,9 @@ public static void ShowTaskar(this in TaskbarInfo taskbar) /// Mouse over the taskbar or a specific window, /// it will only cause the taskbar to show or do nothing. /// - /// /// - public static TaskbarBehavior CheckIfMouseOver(this in TaskbarInfo taskbar) + public static TaskbarBehavior CheckIfMouseOver(this in TaskbarInfo taskbar, + HashSet nonMouseOverShowHandleSet) { // Get mouse coordinates if (!GetCursorPos(out var point)) @@ -210,11 +210,19 @@ public static TaskbarBehavior CheckIfMouseOver(this in TaskbarInfo taskbar) && mouseOverRect.right <= taskbar.Rect.right + TrayTolerance) return TaskbarBehavior.DoNothing; - // If it is a thumbnail of the floating taskbar icon, - // the taskbar needs to be displayed. - return mouseOverHandle.GetClassName() is TrayTaskListThumbnailWnd - ? TaskbarBehavior.Show - : TaskbarBehavior.Pending; + if (nonMouseOverShowHandleSet.Contains(mouseOverHandle)) + return TaskbarBehavior.Pending; + + switch (mouseOverHandle.GetClassName()) + { + // If it is a thumbnail of the floating taskbar icon, + // the taskbar needs to be displayed. + case TrayTaskListThumbnailWnd: + return TaskbarBehavior.Show; + default: + nonMouseOverShowHandleSet.Add(mouseOverHandle); + return TaskbarBehavior.Pending; + } } public static bool CheckIfWindowShouldHideTaskbar(this in TaskbarInfo taskbar, IntPtr foregroundHandle)