clean up code
Pull request / build (pull_request) Successful in 36s

This commit is contained in:
2026-08-12 18:25:28 +05:00
parent 87266e6c13
commit 646d7edc0c
6 changed files with 10 additions and 20 deletions
@@ -29,7 +29,6 @@ internal static class TrayIconNative
internal const int ContextMenuNotification = 0x007B; internal const int ContextMenuNotification = 0x007B;
private const int NIM_ADD = 0x00000000; private const int NIM_ADD = 0x00000000;
private const int NIM_MODIFY = 0x00000001;
private const int NIM_DELETE = 0x00000002; private const int NIM_DELETE = 0x00000002;
private const int NIM_SETVERSION = 0x00000004; private const int NIM_SETVERSION = 0x00000004;
@@ -72,13 +71,6 @@ internal static class TrayIconNative
return true; return true;
} }
/// <summary>Replaces the image and the tooltip of an icon already there.</summary>
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);
}
/// <summary>Takes the icon away. A forgotten icon stays in the tray until hovered.</summary> /// <summary>Takes the icon away. A forgotten icon stays in the tray until hovered.</summary>
internal static void Remove(IntPtr window, int id) internal static void Remove(IntPtr window, int id)
{ {
+5
View File
@@ -103,6 +103,11 @@ internal static class WindowNative
private const byte AC_SRC_ALPHA = 1; private const byte AC_SRC_ALPHA = 1;
private const uint ULW_ALPHA = 0x00000002; private const uint ULW_ALPHA = 0x00000002;
/// <summary>
/// BLENDFUNCTION. <c>BlendFlags</c> 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.
/// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
private struct BlendFunction private struct BlendFunction
{ {
@@ -49,9 +49,6 @@ internal sealed class NativeTrayIcon : IDisposable
internal event EventHandler? ExitRequested; internal event EventHandler? ExitRequested;
/// <summary>Whether the shell accepted the icon. Reported by the diagnostics.</summary>
internal bool IsInstalled => _isInstalled;
internal bool Install() internal bool Install()
{ {
if (_isInstalled) if (_isInstalled)
@@ -10,7 +10,6 @@ namespace CursorLang.Core.Tests.Services;
public sealed class LayoutNotificationCoordinatorTests public sealed class LayoutNotificationCoordinatorTests
{ {
private static readonly KeyboardLayout Russian = KeyboardLayout.FromLocaleId(0x0419); private static readonly KeyboardLayout Russian = KeyboardLayout.FromLocaleId(0x0419);
private static readonly KeyboardLayout English = KeyboardLayout.FromLocaleId(0x0409);
[Fact] [Fact]
public void Starting_turns_on_the_layout_watch() public void Starting_turns_on_the_layout_watch()
+2 -5
View File
@@ -71,9 +71,6 @@ public sealed class SettingsService : IDisposable
_saveTimer.Tick += OnSaveTimerTick; _saveTimer.Tick += OnSaveTimerTick;
} }
/// <summary>The file being read. The agent's diagnostics report it.</summary>
public string FilePath => _filePath;
/// <summary> /// <summary>
/// Reads the settings from disk or returns the default values. /// Reads the settings from disk or returns the default values.
/// </summary> /// </summary>
@@ -154,8 +151,8 @@ public sealed class SettingsService : IDisposable
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// The file is written beside its destination and moved onto it, which on one /// 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 — /// volume is a single step. That way the agent, which is told to re-read the moment
/// and there is a reader, in another process, watching this very file. /// this returns, never meets a half-written file.
/// </remarks> /// </remarks>
public void Save() public void Save()
{ {
+3 -3
View File
@@ -8,9 +8,9 @@ namespace CursorLang.Core.Services;
/// <remarks> /// <remarks>
/// The message carries nothing but the fact. The temptation to send the changed values /// 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 /// 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 /// the two would part company the first time somebody edits it by hand. Nothing else
/// is the wait — the agent watches the file anyway and would notice on its own, just /// tells the agent — it does not watch the file — so a message that goes missing means
/// later and less predictably. /// 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 /// 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 /// into place in one step and only then signals, so by the time the agent reads there