Skip to content

Commit 747f958

Browse files
committed
Fix keyboard restore issue when window is deactivated
1 parent ca04823 commit 747f958

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,31 @@ private void OnLocationChanged(object sender, EventArgs e)
250250

251251
private async void OnDeactivated(object sender, EventArgs e)
252252
{
253+
// When window is deactivated, FL cannot set keyboard correctly
254+
// This is a workaround to restore the keyboard layout
255+
if (_settings.HideWhenDeactivated && _viewModel.StartWithEnglishMode)
256+
{
257+
Activate();
258+
QueryTextBox.Focus();
259+
Win32Helper.RestorePreviousKeyboardLayout();
260+
}
261+
253262
_settings.WindowLeft = Left;
254263
_settings.WindowTop = Top;
255264
ClockPanel.Opacity = 0;
256265
SearchIcon.Opacity = 0;
257-
//This condition stops extra hide call when animator is on,
266+
267+
// This condition stops extra hide call when animator is on,
258268
// which causes the toggling to occasional hide instead of show.
259269
if (_viewModel.MainWindowVisibilityStatus)
260270
{
261271
// Need time to initialize the main query window animation.
262272
// This also stops the mainwindow from flickering occasionally after Settings window is opened
263273
// and always after Settings window is closed.
264274
if (_settings.UseAnimation)
265-
275+
{
266276
await Task.Delay(100);
277+
}
267278

268279
if (_settings.HideWhenDeactivated && !_viewModel.ExternalPreviewVisible)
269280
{

0 commit comments

Comments
 (0)