diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs
index 2248fadd6..3d8821fca 100644
--- a/Flow.Launcher.Infrastructure/Win32Helper.cs
+++ b/Flow.Launcher.Infrastructure/Win32Helper.cs
@@ -66,7 +66,7 @@ namespace Flow.Launcher.Infrastructure
}
///
- ///
+ ///
///
///
/// DoNotRound, Round, RoundSmall, Default
@@ -362,7 +362,7 @@ namespace Flow.Launcher.Infrastructure
return HKL.Null;
}
- public static unsafe void SetEnglishKeyboardLayout(bool backupPrevious)
+ public static unsafe void SwitchToEnglishKeyboardLayout(bool backupPrevious)
{
// Find an installed English layout
var enHKL = FindEnglishKeyboardLayout();
@@ -384,14 +384,12 @@ namespace Flow.Launcher.Infrastructure
PInvoke.ActivateKeyboardLayout(enHKL, 0);
}
- public static void SetPreviousKeyboardLayout()
+ public static void RestorePreviousKeyboardLayout()
{
- if (_previousLayout != HKL.Null)
- {
- PInvoke.ActivateKeyboardLayout(_previousLayout, 0);
+ if (_previousLayout == HKL.Null) return;
- _previousLayout = HKL.Null;
- }
+ PInvoke.ActivateKeyboardLayout(_previousLayout, 0);
+ _previousLayout = HKL.Null;
}
#endregion
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 0f355a80f..5ebed0369 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -1376,7 +1376,7 @@ namespace Flow.Launcher.ViewModel
if (StartWithEnglishMode)
{
- Win32Helper.SetEnglishKeyboardLayout(true);
+ Win32Helper.SwitchToEnglishKeyboardLayout(true);
}
});
}
@@ -1385,6 +1385,11 @@ namespace Flow.Launcher.ViewModel
public async void Hide()
{
+
+ if (StartWithEnglishMode)
+ {
+ Win32Helper.RestorePreviousKeyboardLayout();
+ }
lastHistoryIndex = 1;
if (ExternalPreviewVisible)
@@ -1447,11 +1452,6 @@ namespace Flow.Launcher.ViewModel
Win32Helper.DWMSetCloakForWindow(mainWindow, true);
}
- if (StartWithEnglishMode)
- {
- Win32Helper.SetPreviousKeyboardLayout();
- }
-
await Task.Delay(50);
// Update WPF properties