Skip to content

Commit 67be335

Browse files
committed
Rename methods to make their purpose more obvious; slight code style changes
1 parent 465108a commit 67be335

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Flow.Launcher.Infrastructure/Win32Helper.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static unsafe bool DWMSetDarkModeForWindow(Window window, bool useDarkMod
6666
}
6767

6868
/// <summary>
69-
///
69+
///
7070
/// </summary>
7171
/// <param name="window"></param>
7272
/// <param name="cornerType">DoNotRound, Round, RoundSmall, Default</param>
@@ -362,7 +362,7 @@ private static unsafe HKL FindEnglishKeyboardLayout()
362362
return HKL.Null;
363363
}
364364

365-
public static unsafe void SetEnglishKeyboardLayout(bool backupPrevious)
365+
public static unsafe void SwitchToEnglishKeyboardLayout(bool backupPrevious)
366366
{
367367
// Find an installed English layout
368368
var enHKL = FindEnglishKeyboardLayout();
@@ -384,14 +384,12 @@ public static unsafe void SetEnglishKeyboardLayout(bool backupPrevious)
384384
PInvoke.ActivateKeyboardLayout(enHKL, 0);
385385
}
386386

387-
public static void SetPreviousKeyboardLayout()
387+
public static void RestorePreviousKeyboardLayout()
388388
{
389-
if (_previousLayout != HKL.Null)
390-
{
391-
PInvoke.ActivateKeyboardLayout(_previousLayout, 0);
389+
if (_previousLayout == HKL.Null) return;
392390

393-
_previousLayout = HKL.Null;
394-
}
391+
PInvoke.ActivateKeyboardLayout(_previousLayout, 0);
392+
_previousLayout = HKL.Null;
395393
}
396394

397395
#endregion

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ public void Show()
13761376

13771377
if (StartWithEnglishMode)
13781378
{
1379-
Win32Helper.SetEnglishKeyboardLayout(true);
1379+
Win32Helper.SwitchToEnglishKeyboardLayout(true);
13801380
}
13811381
});
13821382
}
@@ -1385,6 +1385,11 @@ public void Show()
13851385

13861386
public async void Hide()
13871387
{
1388+
1389+
if (StartWithEnglishMode)
1390+
{
1391+
Win32Helper.RestorePreviousKeyboardLayout();
1392+
}
13881393
lastHistoryIndex = 1;
13891394

13901395
if (ExternalPreviewVisible)
@@ -1447,11 +1452,6 @@ public async void Hide()
14471452
Win32Helper.DWMSetCloakForWindow(mainWindow, true);
14481453
}
14491454

1450-
if (StartWithEnglishMode)
1451-
{
1452-
Win32Helper.SetPreviousKeyboardLayout();
1453-
}
1454-
14551455
await Task.Delay(50);
14561456

14571457
// Update WPF properties

0 commit comments

Comments
 (0)