|
|
|
@ -15,14 +15,13 @@ namespace Avalonia.X11 |
|
|
|
{ |
|
|
|
internal class X11TrayIconImpl : ITrayIconImpl |
|
|
|
{ |
|
|
|
|
|
|
|
private static int s_trayIconInstanceId = 0; |
|
|
|
private static int GetTID() => s_trayIconInstanceId++; |
|
|
|
private ObjectPath _dbusmenuPath; |
|
|
|
private StatusNotifierItemDbusObj _statusNotifierItemDbusObj; |
|
|
|
private Connection con; |
|
|
|
private DbusPixmap _icon; |
|
|
|
|
|
|
|
|
|
|
|
private IStatusNotifierWatcher _statusNotifierWatcher; |
|
|
|
|
|
|
|
private string _sysTrayServiceName; |
|
|
|
@ -30,10 +29,10 @@ namespace Avalonia.X11 |
|
|
|
private bool _isActive; |
|
|
|
private bool _isDisposed; |
|
|
|
private readonly bool _ctorFinished; |
|
|
|
|
|
|
|
|
|
|
|
public INativeMenuExporter MenuExporter { get; } |
|
|
|
public Action OnClicked { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public X11TrayIconImpl() |
|
|
|
{ |
|
|
|
con = DBusHelper.TryGetConnection(); |
|
|
|
@ -42,7 +41,7 @@ namespace Avalonia.X11 |
|
|
|
CreateTrayIcon(); |
|
|
|
_ctorFinished = true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async void CreateTrayIcon() |
|
|
|
{ |
|
|
|
_statusNotifierWatcher = con.CreateProxy<IStatusNotifierWatcher>("org.kde.StatusNotifierWatcher", |
|
|
|
@ -111,7 +110,7 @@ namespace Avalonia.X11 |
|
|
|
_icon = new DbusPixmap(w, h, pixByteArray); |
|
|
|
_statusNotifierItemDbusObj.SetIcon(_icon); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void SetIsVisible(bool visible) |
|
|
|
{ |
|
|
|
if (con == null || _isDisposed || !_ctorFinished) return; |
|
|
|
@ -134,7 +133,7 @@ namespace Avalonia.X11 |
|
|
|
_statusNotifierItemDbusObj?.SetTitleAndTooltip(_tooltipText); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// DBus Object used for setting system tray icons.
|
|
|
|
/// </summary>
|
|
|
|
@ -232,12 +231,7 @@ namespace Avalonia.X11 |
|
|
|
|
|
|
|
public async Task<object> GetAsync(string prop) |
|
|
|
{ |
|
|
|
if (prop.Contains("Menu")) |
|
|
|
{ |
|
|
|
return _backingProperties.Menu; |
|
|
|
} |
|
|
|
|
|
|
|
return default; |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<StatusNotifierItemProperties> GetAllAsync() |
|
|
|
|