lightweight variant #1
@@ -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;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
internal static void Remove(IntPtr window, int id)
|
||||
{
|
||||
|
||||
@@ -103,6 +103,11 @@ internal static class WindowNative
|
||||
private const byte AC_SRC_ALPHA = 1;
|
||||
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)]
|
||||
private struct BlendFunction
|
||||
{
|
||||
|
||||
@@ -49,9 +49,6 @@ internal sealed class NativeTrayIcon : IDisposable
|
||||
|
||||
internal event EventHandler? ExitRequested;
|
||||
|
||||
/// <summary>Whether the shell accepted the icon. Reported by the diagnostics.</summary>
|
||||
internal bool IsInstalled => _isInstalled;
|
||||
|
||||
internal bool Install()
|
||||
{
|
||||
if (_isInstalled)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -71,9 +71,6 @@ public sealed class SettingsService : IDisposable
|
||||
_saveTimer.Tick += OnSaveTimerTick;
|
||||
}
|
||||
|
||||
/// <summary>The file being read. The agent's diagnostics report it.</summary>
|
||||
public string FilePath => _filePath;
|
||||
|
||||
/// <summary>
|
||||
/// Reads the settings from disk or returns the default values.
|
||||
/// </summary>
|
||||
@@ -154,8 +151,8 @@ public sealed class SettingsService : IDisposable
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
public void Save()
|
||||
{
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace CursorLang.Core.Services;
|
||||
/// <remarks>
|
||||
/// 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
|
||||
|
||||
Reference in New Issue
Block a user