diff --git a/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs b/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs index c7ff775d6f..58e8a8efc8 100644 --- a/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs +++ b/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs @@ -41,7 +41,7 @@ namespace Avalonia.FreeDesktop public bool IsActive { get; private set; } public INativeMenuExporter? MenuExporter { get; } public Action? OnClicked { get; set; } - public Func? IconConverterDelegate { get; set; } + public Func IconConverterDelegate { get; set; } public DBusTrayIconImpl() { diff --git a/src/Avalonia.X11/X11Platform.cs b/src/Avalonia.X11/X11Platform.cs index 452a72bc83..a2bd57404b 100644 --- a/src/Avalonia.X11/X11Platform.cs +++ b/src/Avalonia.X11/X11Platform.cs @@ -105,23 +105,25 @@ namespace Avalonia.X11 public IntPtr DeferredDisplay { get; set; } public IntPtr Display { get; set; } - public ITrayIconImpl CreateTrayIcon () + private static uint[] X11IconConverter(IWindowIconImpl? icon) + { + if (!(icon is X11IconData x11icon)) + return Array.Empty(); + + return x11icon.Data.Select(x => x.ToUInt32()).ToArray(); + } + + public ITrayIconImpl CreateTrayIcon() { var dbusTrayIcon = new DBusTrayIconImpl(); if (!dbusTrayIcon.IsActive) return new XEmbedTrayIconImpl(); - - dbusTrayIcon.IconConverterDelegate = (icon) => - { - if (!(icon is X11IconData x11icon)) - return Array.Empty(); - return x11icon.Data.Select(x=>x.ToUInt32()).ToArray(); - }; - + dbusTrayIcon.IconConverterDelegate = X11IconConverter; + return dbusTrayIcon; } - + public IWindowImpl CreateWindow() { return new X11Window(this, null);