Skip to content

Commit be0acbd

Browse files
authored
Fix: Fixed the taskbar behavior in full screen mode (#14300)
1 parent 962f2cc commit be0acbd

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Files.App/Helpers/Application/AppLifecycleHelper.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,5 +320,21 @@ public static void HandleAppUnhandledException(Exception? ex, bool showToastNoti
320320
}
321321
Process.GetCurrentProcess().Kill();
322322
}
323+
324+
/// <summary>
325+
/// Checks if the taskbar is set to auto-hide.
326+
/// </summary>
327+
public static bool IsAutoHideTaskbarEnabled()
328+
{
329+
const string registryKey = @"Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3";
330+
const string valueName = "Settings";
331+
332+
using var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(registryKey);
333+
334+
var value = key?.GetValue(valueName) as byte[];
335+
336+
// The least significant bit of the 9th byte controls the auto-hide setting
337+
return value != null && ((value[8] & 0x01) == 1);
338+
}
323339
}
324340
}

src/Files.App/MainWindow.xaml.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ private void EnsureEarlyWindow()
5656

5757
// Workaround for full screen window messing up the taskbar
5858
// https://github.com/microsoft/microsoft-ui-xaml/issues/8431
59-
InteropHelpers.SetPropW(WindowHandle, "NonRudeHWND", new IntPtr(1));
59+
// This property should only be set if the "Automatically hide the taskbar" in Windows 11,
60+
// or "Automatically hide the taskbar in desktop mode" in Windows 10 is enabled.
61+
// Setting this property when the setting is disabled will result in the taskbar overlapping the application
62+
if (AppLifecycleHelper.IsAutoHideTaskbarEnabled())
63+
InteropHelpers.SetPropW(WindowHandle, "NonRudeHWND", new IntPtr(1));
6064
}
6165

6266
public void ShowSplashScreen()

0 commit comments

Comments
 (0)