diff --git a/src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj b/src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj index f4bdae4d03..fe008cb188 100644 --- a/src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj +++ b/src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/src/Avalonia.FreeDesktop/DBusMenuExporter.cs b/src/Avalonia.FreeDesktop/DBusMenuExporter.cs index beb949536f..931c574edc 100644 --- a/src/Avalonia.FreeDesktop/DBusMenuExporter.cs +++ b/src/Avalonia.FreeDesktop/DBusMenuExporter.cs @@ -43,7 +43,9 @@ namespace Avalonia.FreeDesktop InitBackingProperties(); Connection = connection; _xid = (uint)xid.ToInt32(); - Path = GenerateDBusMenuObjPath; + TargetPath = GenerateDBusMenuObjPath; + _pathHandler = new PathHandler(TargetPath); + _pathHandler.Add(this); SetNativeMenu(new NativeMenu()); _ = InitializeAsync(); } @@ -53,19 +55,21 @@ namespace Avalonia.FreeDesktop InitBackingProperties(); Connection = connection; _appMenu = false; - Path = path; + TargetPath = path; + _pathHandler = new PathHandler(TargetPath); + _pathHandler.Add(this); SetNativeMenu(new NativeMenu()); _ = InitializeAsync(); } + public string TargetPath { get; set; } + private void InitBackingProperties() { Version = 4; } - protected override Connection Connection { get; } - - public override string Path { get; } + public override Connection Connection { get; } protected override ValueTask<(uint Revision, (int, Dictionary, Variant[]) Layout)> OnGetLayoutAsync(int parentId, int recursionDepth, string[] propertyNames) { @@ -106,7 +110,7 @@ namespace Avalonia.FreeDesktop private async Task InitializeAsync() { - Connection.AddMethodHandler(this); + Connection.AddMethodHandler(_pathHandler); if (!_appMenu) return; @@ -114,7 +118,7 @@ namespace Avalonia.FreeDesktop try { if (!_disposed) - await _registrar.RegisterWindowAsync(_xid, Path); + await _registrar.RegisterWindowAsync(_xid, TargetPath); } catch { @@ -217,6 +221,8 @@ namespace Avalonia.FreeDesktop "type", "label", "enabled", "visible", "shortcut", "toggle-type", "children-display", "toggle-state", "icon-data" }; + private PathHandler _pathHandler; + private static Variant? GetProperty((NativeMenuItemBase? item, NativeMenu? menu) i, string name) { var (it, menu) = i; diff --git a/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs b/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs index b63b2a2342..8b3592090d 100644 --- a/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs +++ b/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs @@ -30,6 +30,7 @@ namespace Avalonia.FreeDesktop private bool _isDisposed; private bool _serviceConnected; private bool _isVisible = true; + private readonly PathHandler _pathHandler1; public bool IsActive { get; private set; } public INativeMenuExporter? MenuExporter { get; } @@ -56,7 +57,9 @@ namespace Avalonia.FreeDesktop MenuExporter = DBusMenuExporter.TryCreateDetachedNativeMenu(_dbusMenuPath, _connection); _statusNotifierItemDbusObj = new StatusNotifierItemDbusObj(_connection, _dbusMenuPath); - _connection.AddMethodHandler(_statusNotifierItemDbusObj); + _pathHandler1 = new PathHandler("/StatusNotifierItem"); + _pathHandler1.Add(_statusNotifierItemDbusObj); + _connection.AddMethodHandler(_pathHandler1); WatchAsync(); } @@ -212,19 +215,20 @@ namespace Avalonia.FreeDesktop /// internal class StatusNotifierItemDbusObj : OrgKdeStatusNotifierItem { + private readonly PathHandler _pathHandler; + public StatusNotifierItemDbusObj(Connection connection, ObjectPath dbusMenuPath) { Connection = connection; Menu = dbusMenuPath; + _pathHandler = new PathHandler(dbusMenuPath); + _pathHandler.Add(this); InvalidateAll(); } - protected override Connection Connection { get; } - - public override string Path => "/StatusNotifierItem"; - public event Action? ActivationDelegate; + public override Connection Connection { get; } protected override ValueTask OnContextMenuAsync(int x, int y) => new(); protected override ValueTask OnActivateAsync(int x, int y) diff --git a/src/Browser/Avalonia.Browser/webapp/package-lock.json b/src/Browser/Avalonia.Browser/webapp/package-lock.json index cc1262fc47..12aa6660d8 100644 --- a/src/Browser/Avalonia.Browser/webapp/package-lock.json +++ b/src/Browser/Avalonia.Browser/webapp/package-lock.json @@ -731,30 +731,6 @@ "integrity": "sha512-OnYr1rkMVxtmMHIAKZLMcEUlJmqcbxBz9QoBU8G9v455na0fuzlT/GLu6l+SRghrk0Mm2fSSciMmzV43Q8e0Gg==", "dev": true, "hasInstallScript": true, - "dependencies": { - "@esbuild/android-arm": "0.15.9", - "@esbuild/linux-loong64": "0.15.9", - "esbuild-android-64": "0.15.9", - "esbuild-android-arm64": "0.15.9", - "esbuild-darwin-64": "0.15.9", - "esbuild-darwin-arm64": "0.15.9", - "esbuild-freebsd-64": "0.15.9", - "esbuild-freebsd-arm64": "0.15.9", - "esbuild-linux-32": "0.15.9", - "esbuild-linux-64": "0.15.9", - "esbuild-linux-arm": "0.15.9", - "esbuild-linux-arm64": "0.15.9", - "esbuild-linux-mips64le": "0.15.9", - "esbuild-linux-ppc64le": "0.15.9", - "esbuild-linux-riscv64": "0.15.9", - "esbuild-linux-s390x": "0.15.9", - "esbuild-netbsd-64": "0.15.9", - "esbuild-openbsd-64": "0.15.9", - "esbuild-sunos-64": "0.15.9", - "esbuild-windows-32": "0.15.9", - "esbuild-windows-64": "0.15.9", - "esbuild-windows-arm64": "0.15.9" - }, "bin": { "esbuild": "bin/esbuild" }, @@ -2353,9 +2329,6 @@ } ], "license": "MIT", - "dependencies": { - "fetch-blob": "^3.2.0" - }, "engines": { "node": ">=14.8.0" },