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
+25 -24
View File
@@ -5,25 +5,26 @@ using CursorLang.Interop;
namespace CursorLang.Services;
/// <summary>
/// Решает, где появиться окну настроек: впервые за сеанс — по центру монитора,
/// на котором пользователь работает, а затем — там, где он это окно оставил.
/// Decides where the settings window shows up: for the first time in a session — in
/// the centre of the monitor the user is working on, and after that — where they
/// left that window.
/// </summary>
/// <remarks>
/// Положение живёт только в памяти и между запусками не сохраняется: набор
/// мониторов к следующему запуску может стать другим, а «по центру активного»
/// верно всегда.
/// The position lives in memory only and is not kept between launches: the set of
/// monitors may be different by the next launch, while "in the centre of the active
/// one" is always right.
/// </remarks>
public sealed class MainWindowPlacement
{
private PopupWindowNative.Point? _position;
// Окно сообщает о переносе и тогда, когда двигаем его мы сами;
// запоминать надо только то, что выбрал пользователь
// The window reports a move when we move it ourselves as well;
// what has to be remembered is only what the user chose
private bool _isPlacing;
/// <summary>
/// Берёт на себя размещение окна: ставит его на место к первому показу
/// и следит за тем, куда пользователь его переносит.
/// Takes over the placement of the window: puts it in place by the first show
/// and follows where the user moves it.
/// </summary>
public void Attach(Window window)
{
@@ -32,13 +33,13 @@ public sealed class MainWindowPlacement
}
/// <summary>
/// Возвращает окно на запомненное место, а если за этот сеанс его ещё
/// не показывали — ставит по центру активного монитора.
/// Returns the window to the remembered place, and when it has not been shown
/// yet during this session — puts it in the centre of the active monitor.
/// </summary>
public void Apply(Window window)
{
// У свёрнутого окна нет осмысленных границ: его разворачивают на прежнем
// месте, и разместить его можно только после этого
// A minimized window has no meaningful bounds: it is restored in its former
// place, and it can be positioned only after that
if (window.WindowState != WindowState.Normal)
{
return;
@@ -69,10 +70,10 @@ public sealed class MainWindowPlacement
_position = target;
}
// Высота окна подстраивается под содержимое, и до первой раскладки она
// неизвестна — по центру встал бы пустой каркас окна. Раскладку поэтому
// просим посчитать сразу: окно к этому моменту ещё не показано, так что
// на прежнем месте оно не мелькнёт
// The window height adapts to its content and is unknown until the first layout
// pass — an empty window frame would end up in the centre. So we ask for the
// layout to be computed right away: by that moment the window is not shown yet,
// so it will not flash in its former place
private void OnSourceInitialized(object? sender, EventArgs e)
{
if (sender is not Window window)
@@ -115,15 +116,15 @@ public sealed class MainWindowPlacement
}
/// <summary>
/// Подтягивает окно в рабочую область ближайшего монитора.
/// Pulls the window into the work area of the nearest monitor.
/// </summary>
/// <remarks>
/// Нужно в двух случаях. Монитор, на который окно поставил пользователь,
/// за сеанс может быть отключён — возвращать окно на его место значило бы
/// оставить пользователя без окна, поэтому запомненное положение здесь
/// пожелание, а не приказ. А высота окна равна высоте содержимого и на
/// невысоком мониторе может рабочую область превысить — тогда у окна,
/// поставленного по центру, заголовок ушёл бы за верхний край.
/// Needed in two cases. The monitor the user put the window on may be disconnected
/// during the session — returning the window to its place would then leave the
/// user without a window, so the remembered position is a wish here rather than an
/// order. And the window height equals the height of its content and may exceed
/// the work area on a short monitor — then the title bar of a window placed in the
/// centre would go past the top edge.
/// </remarks>
private static PopupWindowNative.Point? KeepOnScreen(
PopupWindowNative.Point position, PopupWindowNative.Rect bounds)