CmdPal: Make Command Palette's main and toast windows tool windows (#41835)

## Summary of the Pull Request
Replaces the `SetVisibilityInSwitchers` method with `WS_EX_TOOLWINDOW`
style, removing reliance on the fragile `IsShownInSwitchers` property.
Explicitly overrides window corner preference so tool windows keep the
same rounded corners as regular app windows (tool windows otherwise
default to a smaller corner radius, which would change the look).

Benefits:
- Avoids use of the unreliable `IsShownInSwitchers` property, which has
multiple known failure cases.
- Allows window managers to correctly treat Command Palette as a popup
window rather than a normal app window, preventing unwanted tiling, grid
placement, or similar behaviors. This better matches the intended design
of CmdPal as an overlay UI.


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #41772
- [x] Closes: #41593
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
This commit is contained in:
Jiří Polášek
2025-09-24 18:26:23 +02:00
committed by GitHub
parent 13da00640f
commit 55251607a7
4 changed files with 84 additions and 13 deletions

View File

@@ -126,6 +126,16 @@ public sealed partial class MainWindow : WindowEx,
// Force window to be created, and then cloaked. This will offset initial animation when the window is shown.
HideWindow();
ApplyWindowStyle();
}
private void ApplyWindowStyle()
{
// Tool windows don't show up in ALT+TAB, and don't show up in the taskbar
// Since tool windows have smaller corner radii, we need to force the normal ones
this.ToggleExtendedWindowStyle(WINDOW_EX_STYLE.WS_EX_TOOLWINDOW, !Debugger.IsAttached);
this.SetCornerPreference(DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND);
}
private static void LocalKeyboardListener_OnKeyPressed(object? sender, LocalKeyboardListenerKeyPressedEventArgs e)
@@ -173,8 +183,6 @@ public sealed partial class MainWindow : WindowEx,
App.Current.Services.GetService<TrayIconService>()!.SetupTrayIcon(settings.ShowSystemTrayIcon);
_ignoreHotKeyWhenFullScreen = settings.IgnoreShortcutWhenFullscreen;
this.SetVisibilityInSwitchers(Debugger.IsAttached);
}
// We want to use DesktopAcrylicKind.Thin and custom colors as this is the default material
@@ -252,6 +260,13 @@ public sealed partial class MainWindow : WindowEx,
var display = GetScreen(hwnd, target);
PositionCentered(display);
// Check if the debugger is attached. If it is, we don't want to apply the tool window style,
// because that would make it hard to debug the app
if (Debugger.IsAttached)
{
ApplyWindowStyle();
}
// Just to be sure, SHOW our hwnd.
PInvoke.ShowWindow(hwnd, SHOW_WINDOW_CMD.SW_SHOW);