From eb14afe19ab6067382627198a73c965b4adc7598 Mon Sep 17 00:00:00 2001 From: Jumar Macato <16554748+jmacato@users.noreply.github.com> Date: Wed, 26 Jun 2024 12:03:28 +0800 Subject: [PATCH] TrayIcon fixes (#16111) * Add private app init * add todo * update TrayIcon.cs * add debugging message for now * Reapply "Bump DBus stack (#15568)" (#15656) This reverts commit e787bb4e641faa5c3ba7f2ffba989464efc66818. * update dbus stuff * DBus init and usage fixes * revert application class changes * Revert "DBus init and usage fixes" This reverts commit 833da084dccae526582ad83a225652e690bf83f0. * dont dispose the thrown exception on DBusTrayIconImpl.cs * Update src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs Co-authored-by: Max Katz --------- Co-authored-by: Nikita Tsukanov Co-authored-by: Max Katz --- src/Avalonia.Controls/TrayIcon.cs | 10 +++---- src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs | 4 +-- .../Avalonia.Browser/webapp/package-lock.json | 27 ------------------- 3 files changed, 5 insertions(+), 36 deletions(-) diff --git a/src/Avalonia.Controls/TrayIcon.cs b/src/Avalonia.Controls/TrayIcon.cs index 1b91a08e34b..4339675a9ee 100644 --- a/src/Avalonia.Controls/TrayIcon.cs +++ b/src/Avalonia.Controls/TrayIcon.cs @@ -7,6 +7,7 @@ using Avalonia.Controls.Platform; using Avalonia.Platform; using Avalonia.Reactive; +using Avalonia.Threading; namespace Avalonia.Controls { @@ -64,12 +65,7 @@ static TrayIcon() } }); - var app = Application.Current ?? throw new InvalidOperationException("Application not yet initialized."); - - if (app.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime) - { - lifetime.Exit += Lifetime_Exit; - } + Dispatcher.UIThread.ShutdownStarted += ShutdownStarted; } /// @@ -184,7 +180,7 @@ public bool IsVisible internal ITrayIconImpl? Impl => _impl; - private static void Lifetime_Exit(object? sender, ControlledApplicationLifetimeExitEventArgs e) + private static void ShutdownStarted(object? sender, EventArgs? e) { var app = Application.Current ?? throw new InvalidOperationException("Application not yet initialized."); var trayIcons = GetIcons(app); diff --git a/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs b/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs index 73444704b8d..43093601c0b 100644 --- a/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs +++ b/src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs @@ -71,11 +71,11 @@ private async void WatchAsync() var nameOwner = await _dBus.GetNameOwnerAsync("org.kde.StatusNotifierWatcher"); OnNameChange("org.kde.StatusNotifierWatcher", nameOwner); } - catch + catch (Exception e) { _serviceWatchDisposable = null; Logger.TryGet(LogEventLevel.Error, "DBUS") - ?.Log(this, "Interface 'org.kde.StatusNotifierWatcher' is unavailable."); + ?.Log(this, "Interface 'org.kde.StatusNotifierWatcher' is unavailable.\n{Exception}", e); } } diff --git a/src/Browser/Avalonia.Browser/webapp/package-lock.json b/src/Browser/Avalonia.Browser/webapp/package-lock.json index cc1262fc47a..12aa6660d80 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" },