Small code style changes in keyboard change logic

This commit is contained in:
Yusyuriv 2025-03-23 20:41:28 +06:00
parent d827d0ac9f
commit 4f2a951adf
No known key found for this signature in database
GPG key ID: A91C52E6F73148E0

View file

@ -464,19 +464,18 @@ namespace Flow.Launcher.Infrastructure
// https://github.com/dotnet/winforms/pull/8573#issuecomment-1542600949
//
// NOTE: this logic may break in future versions of Windows since it is not documented.
if (langId is (int)PInvoke.LOCALE_TRANSIENT_KEYBOARD1
or (int)PInvoke.LOCALE_TRANSIENT_KEYBOARD2
or (int)PInvoke.LOCALE_TRANSIENT_KEYBOARD3
or (int)PInvoke.LOCALE_TRANSIENT_KEYBOARD4)
if (langId is PInvoke.LOCALE_TRANSIENT_KEYBOARD1
or PInvoke.LOCALE_TRANSIENT_KEYBOARD2
or PInvoke.LOCALE_TRANSIENT_KEYBOARD3
or PInvoke.LOCALE_TRANSIENT_KEYBOARD4)
{
using RegistryKey key = Registry.CurrentUser.OpenSubKey(UserProfileRegistryPath);
if (key is not null && key.GetValue("Languages") is string[] languages)
using var key = Registry.CurrentUser.OpenSubKey(UserProfileRegistryPath);
if (key?.GetValue("Languages") is string[] languages)
{
foreach (string language in languages)
{
using RegistryKey subKey = key.OpenSubKey(language);
if (subKey is not null
&& subKey.GetValue("TransientLangId") is int transientLangId
using var subKey = key.OpenSubKey(language);
if (subKey?.GetValue("TransientLangId") is int transientLangId
&& transientLangId == langId)
{
return language;