Skip to content

Commit 3fe0a3e

Browse files
committed
Remain focus on dialog when opening quick switch window
1 parent 2332436 commit 3fe0a3e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using Flow.Launcher.Plugin.SharedCommands;
2525
using Flow.Launcher.Storage;
2626
using Microsoft.VisualStudio.Threading;
27+
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
2728

2829
namespace Flow.Launcher.ViewModel
2930
{
@@ -1627,7 +1628,6 @@ public async void SetupQuickSwitch(nint handle)
16271628

16281629
dialogWindowHandleChanged = true;
16291630

1630-
// Wait for a while to make sure the dialog is shown
16311631
// If don't give a time, Positioning will be weird
16321632
await Task.Delay(300);
16331633
}
@@ -1667,6 +1667,22 @@ public async void SetupQuickSwitch(nint handle)
16671667
}
16681668
}
16691669
}
1670+
1671+
if (QuickSwitchWindowPosition == QuickSwitchWindowPositions.UnderDialog)
1672+
{
1673+
_ = Task.Run(() =>
1674+
{
1675+
// Wait for a while to make sure the dialog is shown and quick switch window has gotten the focus
1676+
var timeOut = !SpinWait.SpinUntil(() => Win32Helper.GetForegroundWindowHWND() != DialogWindowHandle, 1000);
1677+
if (timeOut)
1678+
{
1679+
return;
1680+
}
1681+
1682+
// Bring focus back to the the dialog
1683+
Win32Helper.SetForegroundWindow(DialogWindowHandle);
1684+
});
1685+
}
16701686
}
16711687

16721688
public async void ResetQuickSwitch()

0 commit comments

Comments
 (0)