From f83e8eddb6aad1ed6cbec06620db6f1b1e6dab74 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Sat, 22 Mar 2025 16:23:34 +0600 Subject: [PATCH] Revert "Use focus events to trigger" This reverts commit 4146f4d3096cd44b5e81435d50d8df1711cd3a3d. --- Flow.Launcher/MainWindow.xaml | 2 -- Flow.Launcher/MainWindow.xaml.cs | 16 ---------------- Flow.Launcher/ViewModel/MainViewModel.cs | 10 ++++++++++ 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 2440e89fa..5b63303ac 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -242,8 +242,6 @@ InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}" PreviewDragOver="QueryTextBox_OnPreviewDragOver" PreviewKeyUp="QueryTextBox_KeyUp" - GotKeyboardFocus="QueryTextBox_OnGotKeyboardFocus" - PreviewLostKeyboardFocus="QueryTextBox_OnPreviewLostKeyboardFocus" Style="{DynamicResource QueryBoxStyle}" Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Visibility="Visible" diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index bf560e621..2ce3d1e95 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -989,22 +989,6 @@ namespace Flow.Launcher e.Handled = true; } - private void QueryTextBox_OnGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) - { - if (_viewModel.StartWithEnglishMode) - { - Win32Helper.SwitchToEnglishKeyboardLayout(true); - } - } - - private void QueryTextBox_OnPreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) - { - if (_viewModel.StartWithEnglishMode) - { - Win32Helper.RestorePreviousKeyboardLayout(); - } - } - #endregion } } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 97ed422c5..59af95da5 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1373,6 +1373,11 @@ namespace Flow.Launcher.ViewModel MainWindowOpacity = 1; MainWindowVisibilityStatus = true; VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = true }); + + if (StartWithEnglishMode) + { + Win32Helper.SwitchToEnglishKeyboardLayout(true); + } }); } @@ -1442,6 +1447,11 @@ namespace Flow.Launcher.ViewModel Win32Helper.DWMSetCloakForWindow(mainWindow, true); } + if (StartWithEnglishMode) + { + Win32Helper.RestorePreviousKeyboardLayout(); + } + await Task.Delay(50); // Update WPF properties