lightweight variant (#1)

Reviewed-on: #1
Co-authored-by: Aleksandr Neychev <alexnejchev73@gmail.com>
This commit was merged in pull request #1.
This commit is contained in:
2026-08-12 13:37:30 +00:00
committed by alex
parent a0d3098fe4
commit 55ac8e6556
147 changed files with 4055 additions and 2349 deletions
@@ -0,0 +1,30 @@
using System.Runtime.InteropServices;
namespace CursorLang.Settings.Interop;
/// <summary>
/// Window frame styling by the system: the title bar is drawn by Windows,
/// and in the dark theme it has to be switched separately from the window content.
/// </summary>
internal static class WindowThemeNative
{
[DllImport("dwmapi.dll")]
private static extern int DwmSetWindowAttribute(IntPtr hWnd, int attribute, ref int value, int size);
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
/// <summary>
/// Recolours the window title bar. On Windows 10 builds before 2004 the attribute
/// is not supported — the title bar simply stays light.
/// </summary>
internal static void SetDarkTitleBar(IntPtr hWnd, bool isDark)
{
if (hWnd == IntPtr.Zero)
{
return;
}
int value = isDark ? 1 : 0;
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, ref value, sizeof(int));
}
}