diff --git a/src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj b/src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj
index 8791efd313..19de358abb 100644
--- a/src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj
+++ b/src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/src/Avalonia.FreeDesktop/DBusMenuExporter.cs b/src/Avalonia.FreeDesktop/DBusMenuExporter.cs
index d08828f796..06e085e4d5 100644
--- a/src/Avalonia.FreeDesktop/DBusMenuExporter.cs
+++ b/src/Avalonia.FreeDesktop/DBusMenuExporter.cs
@@ -60,38 +60,43 @@ namespace Avalonia.FreeDesktop
public override string Path { get; }
- protected override (uint revision, (int, Dictionary, DBusVariantItem[]) layout) OnGetLayout(int parentId, int recursionDepth, string[] propertyNames)
- {
- var menu = GetMenu(parentId);
- var layout = GetLayout(menu.item, menu.menu, recursionDepth, propertyNames);
- if (!IsNativeMenuExported)
+ protected override async ValueTask<(uint revision, (int, Dictionary, DBusVariantItem[]) layout)> OnGetLayoutAsync(int parentId, int recursionDepth, string[]? propertyNames) =>
+ await Dispatcher.UIThread.InvokeAsync(() =>
{
- IsNativeMenuExported = true;
- Dispatcher.UIThread.Post(() => OnIsNativeMenuExportedChanged?.Invoke(this, EventArgs.Empty));
- }
+ var menu = GetMenu(parentId);
+ var layout = GetLayout(menu.item, menu.menu, recursionDepth, propertyNames);
+ if (!IsNativeMenuExported)
+ {
+ IsNativeMenuExported = true;
+ OnIsNativeMenuExportedChanged?.Invoke(this, EventArgs.Empty);
+ }
- return (_revision, layout);
- }
+ return (_revision, layout);
+ });
- protected override (int, Dictionary)[] OnGetGroupProperties(int[] ids, string[] propertyNames) =>
- ids.Select(id => (id, GetProperties(GetMenu(id), propertyNames))).ToArray();
+ protected override async ValueTask<(int, Dictionary)[]> OnGetGroupPropertiesAsync(int[] ids, string[] propertyNames) =>
+ await Dispatcher.UIThread.InvokeAsync(() => ids.Select(id => (id, GetProperties(GetMenu(id), propertyNames))).ToArray());
- protected override DBusVariantItem OnGetProperty(int id, string name) => GetProperty(GetMenu(id), name) ?? new DBusVariantItem("i", new DBusInt32Item(0));
+ protected override async ValueTask OnGetPropertyAsync(int id, string name) =>
+ await Dispatcher.UIThread.InvokeAsync(() => GetProperty(GetMenu(id), name) ?? new DBusVariantItem("i", new DBusInt32Item(0)));
- protected override void OnEvent(int id, string eventId, DBusVariantItem data, uint timestamp) =>
+ protected override ValueTask OnEventAsync(int id, string eventId, DBusVariantItem data, uint timestamp)
+ {
Dispatcher.UIThread.Post(() => HandleEvent(id, eventId));
+ return new ValueTask();
+ }
- protected override int[] OnEventGroup((int, string, DBusVariantItem, uint)[] events)
+ protected override ValueTask OnEventGroupAsync((int, string, DBusVariantItem, uint)[] events)
{
foreach (var e in events)
Dispatcher.UIThread.Post(() => HandleEvent(e.Item1, e.Item2));
- return Array.Empty();
+ return new ValueTask(Array.Empty());
}
- protected override bool OnAboutToShow(int id) => false;
+ protected override ValueTask OnAboutToShowAsync(int id) => new(false);
- protected override (int[] updatesNeeded, int[] idErrors) OnAboutToShowGroup(int[] ids) =>
- (Array.Empty(), Array.Empty());
+ protected override ValueTask<(int[] updatesNeeded, int[] idErrors)> OnAboutToShowGroupAsync(int[] ids) =>
+ new((Array.Empty(), Array.Empty()));
private async Task InitializeAsync()
{
diff --git a/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs b/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs
index afbee77067..fed8b87bc9 100644
--- a/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs
+++ b/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs
@@ -1,8 +1,10 @@
using System;
using System.Diagnostics;
+using System.Threading.Tasks;
using Avalonia.Controls.Platform;
using Avalonia.Logging;
using Avalonia.Platform;
+using Avalonia.Threading;
using Tmds.DBus.Protocol;
using Tmds.DBus.SourceGenerator;
@@ -219,13 +221,6 @@ namespace Avalonia.FreeDesktop
Connection = connection;
BackingProperties.Menu = dbusMenuPath;
BackingProperties.ToolTip = (string.Empty, Array.Empty<(int, int, byte[])>(), string.Empty, string.Empty);
- BackingProperties.IconName = string.Empty;
- BackingProperties.AttentionIconName = string.Empty;
- BackingProperties.AttentionIconPixmap = new []{ DBusTrayIconImpl.EmptyPixmap };
- BackingProperties.AttentionMovieName = string.Empty;
- BackingProperties.IconThemePath = string.Empty;
- BackingProperties.OverlayIconName = string.Empty;
- BackingProperties.OverlayIconPixmap = new []{ DBusTrayIconImpl.EmptyPixmap };
InvalidateAll();
}
@@ -235,13 +230,17 @@ namespace Avalonia.FreeDesktop
public event Action? ActivationDelegate;
- protected override void OnContextMenu(int x, int y) { }
+ protected override ValueTask OnContextMenuAsync(int x, int y) => new();
- protected override void OnActivate(int x, int y) => ActivationDelegate?.Invoke();
+ protected override ValueTask OnActivateAsync(int x, int y)
+ {
+ Dispatcher.UIThread.Post(() => ActivationDelegate?.Invoke());
+ return new ValueTask();
+ }
- protected override void OnSecondaryActivate(int x, int y) { }
+ protected override ValueTask OnSecondaryActivateAsync(int x, int y) => new();
- protected override void OnScroll(int delta, string orientation) { }
+ protected override ValueTask OnScrollAsync(int delta, string orientation) => new();
public void InvalidateAll()
{