fixed comment into code

This commit is contained in:
2026-08-09 20:02:23 +05:00
parent 778fc1034b
commit 7e4e569d53
34 changed files with 332 additions and 306 deletions
+17 -17
View File
@@ -3,16 +3,16 @@ using System.Runtime.InteropServices;
namespace CursorLang.Interop;
/// <summary>
/// Win32 API для определения раскладки активного приложения.
/// Win32 API for reading the layout of the active application.
/// </summary>
internal static class KeyboardLayoutNative
{
private const uint WmInputLangChangeRequest = 0x0050;
/// <summary>Взять следующую раскладку из системного списка.</summary>
/// <summary>Take the next layout from the system list.</summary>
private static readonly IntPtr InputLangChangeForward = new(0x0002);
/// <summary>HKL_NEXT — та же просьба на языке старых версий Windows.</summary>
/// <summary>HKL_NEXT — the same request in the language of older Windows versions.</summary>
private static readonly IntPtr HklNext = new(1);
[DllImport("user32.dll")]
@@ -28,17 +28,17 @@ internal static class KeyboardLayoutNative
private static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
/// <summary>
/// Раскладка, которой сейчас печатает пользователь.
/// The layout the user is currently typing with.
/// </summary>
internal static int GetActiveLocaleId() => GetLocaleIdOf(GetInputWindow());
/// <summary>
/// Просит активное приложение перейти на следующую раскладку из системного списка.
/// Asks the active application to switch to the next layout from the system list.
/// </summary>
/// <remarks>
/// Синтезировать системное сочетание вроде Alt+Shift не годится: его назначение
/// пользователь меняет в настройках Windows и может отключить вовсе. Просьба
/// сообщением от таких настроек не зависит и работает в чужом процессе.
/// Synthesizing a system shortcut such as Alt+Shift will not do: the user can
/// reassign it in the Windows settings or turn it off entirely. A request sent as
/// a message does not depend on those settings and works in another process.
/// </remarks>
internal static void RequestNextLayout()
{
@@ -48,19 +48,19 @@ internal static class KeyboardLayoutNative
return;
}
// Оба параметра означают одно и то же: разные версии Windows и разные
// библиотеки интерфейса смотрят то на флаг, то на lParam
// Both parameters mean the same thing: different Windows versions and different
// UI frameworks look either at the flag or at lParam
PostMessage(target, WmInputLangChangeRequest, InputLangChangeForward, HklNext);
}
/// <summary>
/// Окно, которому принадлежит ввод с клавиатуры.
/// The window that owns keyboard input.
/// </summary>
/// <remarks>
/// Спрашиваем окно с фокусом клавиатуры, а не окно верхнего плана: у Блокнота
/// Windows 11, меню «Пуск» и прочих приложений на WinUI поле ввода живёт в
/// отдельном потоке, и раскладка меняется только у него. У потока главного
/// окна она остаётся прежней, и переключение проходит незамеченным.
/// We ask the window with keyboard focus rather than the foreground window: in
/// Windows 11 Notepad, the Start menu and other WinUI applications the input field
/// lives in a separate thread, and the layout changes only for that thread. For the
/// main window's thread it stays the same, and the switch goes unnoticed.
/// </remarks>
private static IntPtr GetInputWindow()
{
@@ -74,8 +74,8 @@ internal static class KeyboardLayoutNative
}
/// <summary>
/// Идентификатор локали для окна. Раскладка в Windows привязана к потоку,
/// поэтому так её видно у любого приложения, а не только у своего.
/// The locale identifier for a window. In Windows the layout is bound to a thread,
/// so this reveals it for any application, not only for our own.
/// </summary>
internal static int GetLocaleIdOf(IntPtr hWnd)
{