From bceacedae338b2ee77a59c23680a78603e16226b Mon Sep 17 00:00:00 2001 From: Vladimir Florov Date: Wed, 7 Jun 2023 12:48:17 +0300 Subject: [PATCH] [FIX] Added missing IPlatformIconLoader in LinuxFramebufferPlatform.cs [FIX] --fbdev parameter check before attach DevTools --- samples/ControlCatalog.NetCore/Program.cs | 22 ++++++++++++++----- .../LinuxFramebufferPlatform.cs | 21 +++++++++++++++++- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/samples/ControlCatalog.NetCore/Program.cs b/samples/ControlCatalog.NetCore/Program.cs index 85c159467b..5249a4fb41 100644 --- a/samples/ControlCatalog.NetCore/Program.cs +++ b/samples/ControlCatalog.NetCore/Program.cs @@ -18,9 +18,16 @@ namespace ControlCatalog.NetCore { static class Program { + private static bool s_useFramebuffer; + [STAThread] static int Main(string[] args) { + if (args.Contains("--fbdev")) + { + s_useFramebuffer = true; + } + if (args.Contains("--wait-for-attach")) { Console.WriteLine("Attach debugger and use 'Set next statement'"); @@ -42,10 +49,10 @@ namespace ControlCatalog.NetCore return scaling; return 1; } - if (args.Contains("--fbdev")) + if (s_useFramebuffer) { - SilenceConsole(); - return builder.StartLinuxFbDev(args, scaling: GetScaling()); + SilenceConsole(); + return builder.StartLinuxFbDev(args, scaling: GetScaling()); } else if (args.Contains("--vnc")) { @@ -128,10 +135,13 @@ namespace ControlCatalog.NetCore .WithInterFont() .AfterSetup(builder => { - builder.Instance!.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() + if (!s_useFramebuffer) { - StartupScreenIndex = 1, - }); + builder.Instance!.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() + { + StartupScreenIndex = 1, + }); + } EmbedSample.Implementation = OperatingSystem.IsWindows() ? (INativeDemoControl)new EmbedSampleWin() : OperatingSystem.IsMacOS() ? new EmbedSampleMac() diff --git a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs index 438e94b42e..10ec4372c7 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.IO; using System.Threading; using Avalonia; using Avalonia.Controls; @@ -22,13 +23,30 @@ using Avalonia.Threading; namespace Avalonia.LinuxFramebuffer { + internal class LinuxFramebufferIconLoaderStub : IPlatformIconLoader + { + private class IconStub : IWindowIconImpl + { + public void Save(Stream outputStream) + { + + } + } + + public IWindowIconImpl LoadIcon(string fileName) => new IconStub(); + + public IWindowIconImpl LoadIcon(Stream stream) => new IconStub(); + + public IWindowIconImpl LoadIcon(IBitmapImpl bitmap) => new IconStub(); + } + class LinuxFramebufferPlatform { IOutputBackend _fb; public static ManualRawEventGrouperDispatchQueue EventGrouperDispatchQueue = new(); internal static Compositor Compositor { get; private set; } = null!; - + LinuxFramebufferPlatform(IOutputBackend backend) { @@ -47,6 +65,7 @@ namespace Avalonia.LinuxFramebuffer .Bind().ToConstant(new DefaultRenderTimer(opts.Fps)) .Bind().ToTransient() .Bind().ToConstant(new KeyboardDevice()) + .Bind().ToSingleton() .Bind().ToSingleton() .Bind().ToSingleton();