Skip to content

CmdPal: add support for compact mode#48801

Open
zadjii-msft wants to merge 20 commits into
mainfrom
dev/migrie/compact-cmdpal-review
Open

CmdPal: add support for compact mode#48801
zadjii-msft wants to merge 20 commits into
mainfrom
dev/migrie/compact-cmdpal-review

Conversation

@zadjii-msft

Copy link
Copy Markdown
Member

This is a bear of a PR. Watch out.
This PR adds support for compact mode to the command palette. In compact mode, the results of the command palette window are collapsed by default. And the only thing that is visible is the search bar. When the user types, the window is expanded only just enough to show the available results1

cmdpal-compact-pr-000.mp4

This is made possible by a fairly annoyingly substantial refactoring to how our windowing is done. Animating the size or bounds of an HWND on Windows is not fun. With pretty much any XAML application, you're going to get at least one frame of blackness when you resize your window. The trick then is to create an experience where it looks like your application is resizing, but the HWND never actually resizes.

So the main bulk of this PR is actually just refactoring our window handling. Our MainWindow class now becomes a dummy holder of some content, and most of the main content is moved into the CmdPalMainControl class. MainWindow's job then is to handle a transparent window that hosts some XAML content inside of it, and pretend that content is the real bounds of the window. We need to fake our NCHITTEST results, so that the edges of the XAML content act like they're the edge of the actual HWND. We need to hide our actual window frame and shadow, but then also re-create them in XAML around our content.
Previously we've done work like this using a single full screen transparent window with XAML content inside of it. However that has the downside of not allowing the XAML content to be movable across different monitors. By faking out the NCHITTEST results, we allow users to resize and move the window using the normal user32 move size loop.
Our HWND is also cropped (with SetWindowRgn to the bounds of the shadow around our XAML content. We need to include the shadow in the hit testable region, because if we don't, then the shadow will be visibly cropped on the edges.

In compact mode, instead of centering our window in the middle of the monitor, the user can set a relative height where the search box opens on that monitor. This defaults to about 60% up from the bottom of the monitor, so that there's room for the results to expand downwards and feel centered within the screen. This position is a setting, so users can customize it to whatever they like.

I've also added a developer only debug build only internal setting, which allows you to see the actual frame of our HWND. This makes it easier to visually debug where the bounds of the window are and understand a little bit more about the layout of our application. This setting and functionality is disabled in release builds.

cmdpal-compact-diagram

Closes #38423

Footnotes

  1. with some caveats: pages with details expand fully always.

zadjii-msft and others added 18 commits June 1, 2026 10:33
- HotReloadSettings now recomputes the card-height clamp for the current
  expanded state instead of forcing it off, so unrelated setting changes
  no longer let a centered compact palette overflow the work area.
- UpdateRegionsForCustomTitleBar clears stale caption/passthrough regions
  and the HWND clip when the card isn't measurable, instead of leaving
  old hit-test zones behind.
- ComputeExpandedCardMaxHeightDip falls back to a screen-bounded height
  (not PositiveInfinity) when available space is <= 0, keeping the clamp.
- Uncloak() checks the DwmSetWindowAttribute HRESULT before flipping
  IsVisibleToUser, matching Cloak().
- Renamed MainWindow.HandleExpandCompactOnUiThread to
  ApplyCompactCardHeightClampOnUiThread to clarify it owns card sizing,
  not the semantic compact state (ShellViewModel.ExpandedMode).
- Scoped the post-expand select suppression to the specific page that the
  expand realized so it can't leak across rapid navigation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Product-Command Palette Refers to the Command Palette utility label Jun 22, 2026
@jiripolasek

Copy link
Copy Markdown
Contributor
CoolGIF

@michaeljolley michaeljolley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't wait to use this. Couple Dispose methods that look like they weren't finished, but otherwise, great.


public void Dispose()
{
throw new NotImplementedException();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image


public void Dispose()
{
throw new NotImplementedException();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CmdPal: Add a "minimal" / search box only mode

3 participants