Dock: Replace IsShownInSwitchers with HiddenOwnerWindowBehavior in DockWindow (#45839)

## Summary of the Pull Request

This PR replaces the use of the property AppWindow.IsShownInSwitchers,
which requires a running explorer.exe instance, with
HiddenOwnerWindowBehavior. This behavior is used by MainWindow and
ToastWindow to hide the window by utilizing both the Tool Window style
and a safely invoked IsShownInSwitchers.
This commit is contained in:
Jiří Polášek
2026-02-27 22:11:27 +01:00
committed by GitHub
parent 12fac01ee1
commit 96e6542cf1

View File

@@ -5,6 +5,7 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging;
using ManagedCommon; using ManagedCommon;
using Microsoft.CmdPal.UI.Helpers;
using Microsoft.CmdPal.UI.ViewModels; using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.CmdPal.UI.ViewModels.Dock; using Microsoft.CmdPal.UI.ViewModels.Dock;
using Microsoft.CmdPal.UI.ViewModels.Messages; using Microsoft.CmdPal.UI.ViewModels.Messages;
@@ -26,6 +27,7 @@ using Windows.Win32.UI.WindowsAndMessaging;
using WinRT; using WinRT;
using WinRT.Interop; using WinRT.Interop;
using WinUIEx; using WinUIEx;
using WindowExtensions = Microsoft.CmdPal.UI.Helpers.WindowExtensions;
namespace Microsoft.CmdPal.UI.Dock; namespace Microsoft.CmdPal.UI.Dock;
@@ -45,6 +47,7 @@ public sealed partial class DockWindow : WindowEx,
private readonly IThemeService _themeService; private readonly IThemeService _themeService;
private readonly DockWindowViewModel _windowViewModel; private readonly DockWindowViewModel _windowViewModel;
private readonly HiddenOwnerWindowBehavior _hiddenOwnerWindowBehavior = new();
private HWND _hwnd = HWND.Null; private HWND _hwnd = HWND.Null;
private APPBARDATA _appBarData; private APPBARDATA _appBarData;
@@ -80,7 +83,7 @@ public sealed partial class DockWindow : WindowEx,
Root.Children.Add(_dock); Root.Children.Add(_dock);
ExtendsContentIntoTitleBar = true; ExtendsContentIntoTitleBar = true;
AppWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Collapsed; AppWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Collapsed;
AppWindow.IsShownInSwitchers = false; _hiddenOwnerWindowBehavior.ShowInTaskbar(this, false);
if (AppWindow.Presenter is OverlappedPresenter overlappedPresenter) if (AppWindow.Presenter is OverlappedPresenter overlappedPresenter)
{ {
overlappedPresenter.SetBorderAndTitleBar(false, false); overlappedPresenter.SetBorderAndTitleBar(false, false);