mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
CmdPal: Prevent cloaking of a visible window when not necessary (#40981)
## Summary of the Pull Request This change prevents unnecessary cloaking of a visible window when showing it to the user, significantly reducing flickering. Some minor flickering remains due to page content refreshes, but it is much less noticeable. New windows are now pre-cloaked immediately after creation. Cloaking is explicitly applied only when an animation is expected (e.g., when minimized). Additionally, this change removes explicit window activation, as the summon mechanism will activate the window as needed. ## PR Checklist - [x] Closes: #40969 - [ ] **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 - [x] **Localization:** no need - [x] **Dev docs:** none - [x] **New binaries:** none - [x] **Documentation updated:** none ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed
This commit is contained in:
@@ -123,6 +123,9 @@ public sealed partial class MainWindow : WindowEx,
|
||||
_localKeyboardListener = new LocalKeyboardListener();
|
||||
_localKeyboardListener.KeyPressed += LocalKeyboardListener_OnKeyPressed;
|
||||
_localKeyboardListener.Start();
|
||||
|
||||
// Force window to be created, and then cloaked. This will offset initial animation when the window is shown.
|
||||
HideWindow();
|
||||
}
|
||||
|
||||
private static void LocalKeyboardListener_OnKeyPressed(object? sender, LocalKeyboardListenerKeyPressedEventArgs e)
|
||||
@@ -233,9 +236,6 @@ public sealed partial class MainWindow : WindowEx,
|
||||
{
|
||||
var hwnd = new HWND(hwndValue != 0 ? hwndValue : _hwnd);
|
||||
|
||||
// Make sure our HWND is cloaked before any possible window manipulations
|
||||
Cloak();
|
||||
|
||||
// Remember, IsIconic == "minimized", which is entirely different state
|
||||
// from "show/hide"
|
||||
// If we're currently minimized, restore us first, before we reveal
|
||||
@@ -243,6 +243,9 @@ public sealed partial class MainWindow : WindowEx,
|
||||
// which would remain not visible to the user.
|
||||
if (PInvoke.IsIconic(hwnd))
|
||||
{
|
||||
// Make sure our HWND is cloaked before any possible window manipulations
|
||||
Cloak();
|
||||
|
||||
PInvoke.ShowWindow(hwnd, SHOW_WINDOW_CMD.SW_RESTORE);
|
||||
}
|
||||
|
||||
@@ -634,8 +637,6 @@ public sealed partial class MainWindow : WindowEx,
|
||||
// so that we can bind hotkeys to individual commands
|
||||
if (!isVisible || !isRootHotkey)
|
||||
{
|
||||
Activate();
|
||||
|
||||
Summon(commandId);
|
||||
}
|
||||
else if (isRootHotkey)
|
||||
|
||||
Reference in New Issue
Block a user