Skip to content

Commit 99af084

Browse files
committed
fix: Ignore the desktop window for widget
1 parent b656e66 commit 99af084

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎TaskbarWidget.xaml.cs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ private bool IsFullscreenAppActive()
211211
var fgHwnd = GetForegroundWindow();
212212
if (fgHwnd == IntPtr.Zero || fgHwnd == _hWnd) return false;
213213

214+
// Ignore the desktop window (clicking the desktop should not hide the widget)
215+
if (fgHwnd == GetShellWindow()) return false;
216+
var className = new System.Text.StringBuilder(256);
217+
GetClassName(fgHwnd, className, className.Capacity);
218+
var cls = className.ToString();
219+
if (cls is "Progman" or "WorkerW") return false;
220+
214221
if (!GetWindowRect(fgHwnd, out var wndRect)) return false;
215222

216223
// Get the monitor that contains the foreground window
@@ -895,6 +902,12 @@ private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attribute,
895902
[DllImport("user32.dll")]
896903
private static extern IntPtr GetForegroundWindow();
897904

905+
[DllImport("user32.dll")]
906+
private static extern IntPtr GetShellWindow();
907+
908+
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
909+
private static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder lpClassName, int nMaxCount);
910+
898911
[DllImport("user32.dll")]
899912
private static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags);
900913

0 commit comments

Comments
 (0)