namespace XFESystem.Desktop; /// Framebuffer adapter. Coordinates are layout units; the adapter clips and maps them to native scanout pixels. public interface IDesktopCanvas { int Width { get; } int Height { get; } int NativeWidth => Width; int NativeHeight => Height; int ScalePercent => 100; int TextWidth(string text) => text.Length * 8; void Fill(uint rgb, int x, int y, int width, int height); void Line(uint rgb, int x1, int y1, int x2, int y2); void Text(string text, uint rgb, int x, int y); void Present(); bool SupportsSceneCache => false; void BeginScene(DesktopBounds damage) { } void SaveScene() { } void SaveScene(DesktopBounds damage) => SaveScene(); void RestoreSceneRegion(DesktopBounds bounds) { } void Present(DesktopBounds damage) => Present(); } public interface IBrandedDesktopCanvas : IDesktopCanvas { void BrandIcon(int x, int y, int size); } /// Theme assets are supplied by the platform; shared UI never opens host files. public interface IDesktopIconCanvas : IDesktopCanvas { void DrawIcon(DesktopIcon icon, int x, int y, int size); } /// /// Optional native-resolution coverage compositing. The mask contains straight /// alpha coverage bytes, row-major with stride equal to width and exactly /// width*height entries. Native coordinates may extend beyond the framebuffer; /// the implementation clips and blends against its actual current pixel buffer. /// There is no assumed white background or premultiplied RGB input. /// public interface IDesktopCoverageCanvas : IDesktopCanvas { void BlendCoverage(uint rgb, int nativeX, int nativeY, int width, int height, ReadOnlySpan coverage); } /// Reuses an unchanged opaque document body from the last pointer-free scene during a pure window translation. public interface IDesktopSceneMotionCanvas : IDesktopCanvas { void PreserveTranslatedSceneRegion(DesktopBounds source, int destinationX, int destinationY); void PreserveTranslatedSceneRegion(DesktopBounds source, int destinationX, int destinationY, bool unchangedInScanout) => PreserveTranslatedSceneRegion(source, destinationX, destinationY); void EndScenePreservation(); // Cancellation must also discard any pending scanout-copy exclusions. // Normal EndScenePreservation may keep those until the completed Present. void AbortScenePreservation() => EndScenePreservation(); } public enum DesktopIcon { Files, Editor, Browser, Terminal, Folder, TextFile, CodeFile, MarkdownFile, ApplicationFile, Settings } public readonly record struct DesktopBounds(int X, int Y, int Width, int Height) { public bool Contains(int x, int y) => x >= X && y >= Y && x < X + Width && y < Y + Height; } public enum DesktopKey { Character, Enter, Backspace, Delete, Left, Right, Up, Down, Home, End, Tab, Escape, Save, Run, FocusAddress, StartMenu, ShowDesktop, OpenFiles, SwitchWindow, SwitchWindowBack, EndWindowSwitch, SnapLeft, SnapRight, Maximize, Restore, Minimize, CloseWindow } public enum DesktopApplication { Files, Editor, Browser, Terminal, Settings }