Skip to content

Commit

Permalink
Fix: Fixed the taskbar behavior in full screen mode (files-community#…
Browse files Browse the repository at this point in the history
  • Loading branch information
el-ev authored Jan 2, 2024
1 parent 962f2cc commit be0acbd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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 @@ -320,5 +320,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

0 comments on commit be0acbd

Please sign in to comment.