From 646d7edc0c2601ae78e18d90eb460e5b3d5740f6 Mon Sep 17 00:00:00 2001 From: Aleksandr Neychev Date: Wed, 12 Aug 2026 18:25:28 +0500 Subject: [PATCH] clean up code --- CursorLang.Agent/Interop/TrayIconNative.cs | 8 -------- CursorLang.Agent/Interop/WindowNative.cs | 5 +++++ CursorLang.Agent/Windows/NativeTrayIcon.cs | 3 --- .../Services/LayoutNotificationCoordinatorTests.cs | 1 - CursorLang.Core/Services/SettingsService.cs | 7 ++----- CursorLang.Core/Services/SettingsSignal.cs | 6 +++--- 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/CursorLang.Agent/Interop/TrayIconNative.cs b/CursorLang.Agent/Interop/TrayIconNative.cs index c623a6d..3fbd965 100644 --- a/CursorLang.Agent/Interop/TrayIconNative.cs +++ b/CursorLang.Agent/Interop/TrayIconNative.cs @@ -29,7 +29,6 @@ internal static class TrayIconNative internal const int ContextMenuNotification = 0x007B; private const int NIM_ADD = 0x00000000; - private const int NIM_MODIFY = 0x00000001; private const int NIM_DELETE = 0x00000002; private const int NIM_SETVERSION = 0x00000004; @@ -72,13 +71,6 @@ internal static class TrayIconNative return true; } - /// Replaces the image and the tooltip of an icon already there. - internal static bool Modify(IntPtr window, int id, IntPtr icon, string tooltip) - { - NotifyIconData data = Describe(window, id, icon, tooltip); - return Shell_NotifyIcon(NIM_MODIFY, ref data); - } - /// Takes the icon away. A forgotten icon stays in the tray until hovered. internal static void Remove(IntPtr window, int id) { diff --git a/CursorLang.Agent/Interop/WindowNative.cs b/CursorLang.Agent/Interop/WindowNative.cs index a7ad755..fc3e067 100644 --- a/CursorLang.Agent/Interop/WindowNative.cs +++ b/CursorLang.Agent/Interop/WindowNative.cs @@ -103,6 +103,11 @@ internal static class WindowNative private const byte AC_SRC_ALPHA = 1; private const uint ULW_ALPHA = 0x00000002; + /// + /// BLENDFUNCTION. BlendFlags is never assigned and must stay all the same: + /// Windows reads the structure by its layout, and dropping a byte from the middle + /// of it would shift everything after. + /// [StructLayout(LayoutKind.Sequential)] private struct BlendFunction { diff --git a/CursorLang.Agent/Windows/NativeTrayIcon.cs b/CursorLang.Agent/Windows/NativeTrayIcon.cs index c6da359..5bddf73 100644 --- a/CursorLang.Agent/Windows/NativeTrayIcon.cs +++ b/CursorLang.Agent/Windows/NativeTrayIcon.cs @@ -49,9 +49,6 @@ internal sealed class NativeTrayIcon : IDisposable internal event EventHandler? ExitRequested; - /// Whether the shell accepted the icon. Reported by the diagnostics. - internal bool IsInstalled => _isInstalled; - internal bool Install() { if (_isInstalled) diff --git a/CursorLang.Core.Tests/Services/LayoutNotificationCoordinatorTests.cs b/CursorLang.Core.Tests/Services/LayoutNotificationCoordinatorTests.cs index 307a8b4..e0db2d3 100644 --- a/CursorLang.Core.Tests/Services/LayoutNotificationCoordinatorTests.cs +++ b/CursorLang.Core.Tests/Services/LayoutNotificationCoordinatorTests.cs @@ -10,7 +10,6 @@ namespace CursorLang.Core.Tests.Services; public sealed class LayoutNotificationCoordinatorTests { private static readonly KeyboardLayout Russian = KeyboardLayout.FromLocaleId(0x0419); - private static readonly KeyboardLayout English = KeyboardLayout.FromLocaleId(0x0409); [Fact] public void Starting_turns_on_the_layout_watch() diff --git a/CursorLang.Core/Services/SettingsService.cs b/CursorLang.Core/Services/SettingsService.cs index d051e4a..ff39ae0 100644 --- a/CursorLang.Core/Services/SettingsService.cs +++ b/CursorLang.Core/Services/SettingsService.cs @@ -71,9 +71,6 @@ public sealed class SettingsService : IDisposable _saveTimer.Tick += OnSaveTimerTick; } - /// The file being read. The agent's diagnostics report it. - public string FilePath => _filePath; - /// /// Reads the settings from disk or returns the default values. /// @@ -154,8 +151,8 @@ public sealed class SettingsService : IDisposable /// /// /// The file is written beside its destination and moved onto it, which on one - /// volume is a single step. That way a reader never meets a half-written file — - /// and there is a reader, in another process, watching this very file. + /// volume is a single step. That way the agent, which is told to re-read the moment + /// this returns, never meets a half-written file. /// public void Save() { diff --git a/CursorLang.Core/Services/SettingsSignal.cs b/CursorLang.Core/Services/SettingsSignal.cs index c1fda07..10ad81f 100644 --- a/CursorLang.Core/Services/SettingsSignal.cs +++ b/CursorLang.Core/Services/SettingsSignal.cs @@ -8,9 +8,9 @@ namespace CursorLang.Core.Services; /// /// The message carries nothing but the fact. The temptation to send the changed values /// along has to be resisted: the file would stop being the only source of truth, and -/// the two would part company the first time somebody edits it by hand. All this saves -/// is the wait — the agent watches the file anyway and would notice on its own, just -/// later and less predictably. +/// the two would part company the first time somebody edits it by hand. Nothing else +/// tells the agent — it does not watch the file — so a message that goes missing means +/// settings it does not pick up until it is restarted. /// /// Order is what makes it safe. The settings window writes the file whole, moves it /// into place in one step and only then signals, so by the time the agent reads there