From cd28c09c09b3a30a78571a9448db07fba2303e72 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Sun, 23 Mar 2025 17:56:52 +0600 Subject: [PATCH] Fix the issue with not being able to switch back to the original keyboard layout in OnDeactivated --- Flow.Launcher.Infrastructure/NativeMethods.txt | 7 ++++++- Flow.Launcher.Infrastructure/Win32Helper.cs | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Infrastructure/NativeMethods.txt b/Flow.Launcher.Infrastructure/NativeMethods.txt index d26478bbe..54ae099f8 100644 --- a/Flow.Launcher.Infrastructure/NativeMethods.txt +++ b/Flow.Launcher.Infrastructure/NativeMethods.txt @@ -51,4 +51,9 @@ WM_EXITSIZEMOVE GetKeyboardLayout GetWindowThreadProcessId ActivateKeyboardLayout -GetKeyboardLayoutList \ No newline at end of file +GetKeyboardLayoutList + +PostMessage +HWND_BROADCAST +WM_INPUTLANGCHANGEREQUEST +INPUTLANGCHANGE_FORWARD diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index f23f02447..197a5a556 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -403,7 +403,11 @@ namespace Flow.Launcher.Infrastructure { if (_previousLayout == HKL.Null) return; - PInvoke.ActivateKeyboardLayout(_previousLayout, 0); + PInvoke.PostMessage(HWND.HWND_BROADCAST, + PInvoke.WM_INPUTLANGCHANGEREQUEST, + PInvoke.INPUTLANGCHANGE_FORWARD, + _previousLayout.Value + ); _previousLayout = HKL.Null; }