Skip to content

Commit

Permalink
TrayIcon fixes (#16111)
Browse files Browse the repository at this point in the history
* Add private app init

* add todo

* update TrayIcon.cs

* add debugging message for now

* Reapply "Bump DBus stack (#15568)" (#15656)

This reverts commit e787bb4.

* update dbus stuff

* DBus init and usage fixes

* revert application class changes

* Revert "DBus init and usage fixes"

This reverts commit 833da08.

* dont dispose the thrown exception on DBusTrayIconImpl.cs

* Update src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs

Co-authored-by: Max Katz <maxkatz6@outlook.com>

---------

Co-authored-by: Nikita Tsukanov <keks9n@gmail.com>
Co-authored-by: Max Katz <maxkatz6@outlook.com>
  • Loading branch information
3 people authored Jun 26, 2024
1 parent 9c955d3 commit eb14afe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 36 deletions.
10 changes: 3 additions & 7 deletions src/Avalonia.Controls/TrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Avalonia.Controls.Platform;
using Avalonia.Platform;
using Avalonia.Reactive;
using Avalonia.Threading;

namespace Avalonia.Controls
{
Expand Down Expand Up @@ -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;
}

/// <summary>
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
27 changes: 0 additions & 27 deletions src/Browser/Avalonia.Browser/webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eb14afe

Please sign in to comment.