Skip to content

Fix: Fixed the taskbar behavior in full screen mode #14300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Files.App/Helpers/Application/AppLifecycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,21 @@ public static void HandleAppUnhandledException(Exception? ex, bool showToastNoti
}
Process.GetCurrentProcess().Kill();
}

/// <summary>
/// Checks if the taskbar is set to auto-hide.
/// </summary>
public static bool IsAutoHideTaskbarEnabled()
{
const string registryKey = @"Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3";
const string valueName = "Settings";

using var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(registryKey);

var value = key?.GetValue(valueName) as byte[];

// The least significant bit of the 9th byte controls the auto-hide setting
return value != null && ((value[8] & 0x01) == 1);
}
}
}
6 changes: 5 additions & 1 deletion src/Files.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ private void EnsureEarlyWindow()

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

public void ShowSplashScreen()
Expand Down