Skip to content
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
2 changes: 1 addition & 1 deletion src/ManagedShell.AppBar/AppBarWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public AppBarWindow(AppBarManager appBarManager, ExplorerHelper explorerHelper,
PropertyChanged += AppBarWindow_PropertyChanged;

ResizeMode = ResizeMode.NoResize;
if (EnvironmentHelper.IsWindows11OrBetter)
if (EnvironmentHelper.EnableWin11DpiWorkaround && EnvironmentHelper.IsWindows11OrBetter)
{
// With Windows 11, we cannot use the normal way to hide from taskbar (setting as a tool window) because that breaks receiving WM_DPICHANGED.
ShowInTaskbar = false;
Expand Down
2 changes: 2 additions & 0 deletions src/ManagedShell.Common/Helpers/EnvironmentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public static class EnvironmentHelper
private static int osVersionMinor = 0;
private static int osVersionBuild = 0;

public static bool EnableWin11DpiWorkaround;

private static void getOSVersion()
{
osVersionMajor = Environment.OSVersion.Version.Major;
Expand Down
2 changes: 1 addition & 1 deletion src/ManagedShell.Common/Helpers/WindowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static IntPtr GetLowestDesktopChildHwnd()
public static void HideWindowFromTasks(IntPtr hWnd)
{
int style = GetWindowLong(hWnd, WindowLongFlags.GWL_EXSTYLE) & ~(int)ExtendedWindowStyles.WS_EX_APPWINDOW;
if (EnvironmentHelper.IsWindows11OrBetter)
if (EnvironmentHelper.EnableWin11DpiWorkaround && EnvironmentHelper.IsWindows11OrBetter)
{
// If the window has a Hidden Window owner, set the owner as a tool window instead so that we still receive WM_DPICHANGED on Windows 11.
// Hidden Window is the owner when ShowInTaskbar=false. Unfortunately, the window will not be hidden from Task Manager.
Expand Down
11 changes: 10 additions & 1 deletion src/ManagedShell/ShellConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@ public struct ShellConfig
/// - Otherwise, the string follows the format: "PathToExe:UID"
/// </summary>
public string[] PinnedNotifyIcons;

#endregion

/// <summary>
/// Controls whether the workaround for Windows 11 DPI change notification workaround for AppBars is enabled.<br />
/// <br />
/// In Windows 11, tool windows (which AppBars are, to hide from the taskbar, alt-tab, and Task Manager) do not receive DPI change notifications.<br />
/// To work around this, we can instead give the AppBar an owner window that has WS_EX_TOOLWINDOW, so the AppBar does not need it.<br />
/// Unfortunately, this results in the AppBar displaying in Task Manager, as well as some unpredictable Z-order issues due to the ownership relationship.
/// </summary>
public bool EnableWin11DpiWorkaround;
}
}
6 changes: 5 additions & 1 deletion src/ManagedShell/ShellManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public class ShellManager : IDisposable

EnableTrayService = true,
AutoStartTrayService = true,
PinnedNotifyIcons = NotificationArea.DEFAULT_PINNED
PinnedNotifyIcons = NotificationArea.DEFAULT_PINNED,

EnableWin11DpiWorkaround = false
};

/// <summary>
Expand All @@ -33,6 +35,8 @@ public ShellManager() : this(DefaultShellConfig)
/// <param name="config">A ShellConfig struct containing desired initialization parameters.</param>
public ShellManager(ShellConfig config)
{
EnvironmentHelper.EnableWin11DpiWorkaround = config.EnableWin11DpiWorkaround;

if (config.EnableTrayService)
{
TrayService = new TrayService();
Expand Down