|
|
@ -15,27 +15,25 @@ namespace Avalonia.X11 |
|
|
{ |
|
|
{ |
|
|
internal class X11TrayIconImpl : ITrayIconImpl |
|
|
internal class X11TrayIconImpl : ITrayIconImpl |
|
|
{ |
|
|
{ |
|
|
private readonly ObjectPath _dbusmenuPath; |
|
|
|
|
|
|
|
|
|
|
|
private static int s_trayIconInstanceId = 0; |
|
|
private static int s_trayIconInstanceId = 0; |
|
|
|
|
|
private static int GetTID() => s_trayIconInstanceId++; |
|
|
private IStatusNotifierWatcher _statusNotifierWatcher; |
|
|
private ObjectPath _dbusmenuPath; |
|
|
private string _sysTrayServiceName; |
|
|
|
|
|
private StatusNotifierItemDbusObj _statusNotifierItemDbusObj; |
|
|
private StatusNotifierItemDbusObj _statusNotifierItemDbusObj; |
|
|
|
|
|
|
|
|
private Connection con; |
|
|
private Connection con; |
|
|
private DbusPixmap _icon; |
|
|
private DbusPixmap _icon; |
|
|
|
|
|
|
|
|
|
|
|
private IStatusNotifierWatcher _statusNotifierWatcher; |
|
|
|
|
|
|
|
|
|
|
|
private string _sysTrayServiceName; |
|
|
private string _tooltipText; |
|
|
private string _tooltipText; |
|
|
private bool _isActive; |
|
|
private bool _isActive; |
|
|
private bool _isDisposed; |
|
|
private bool _isDisposed; |
|
|
private readonly bool _ctorFinished; |
|
|
private readonly bool _ctorFinished; |
|
|
|
|
|
|
|
|
private static int GetTID() => s_trayIconInstanceId++; |
|
|
|
|
|
|
|
|
|
|
|
public INativeMenuExporter MenuExporter { get; } |
|
|
public INativeMenuExporter MenuExporter { get; } |
|
|
public Action OnClicked { get; set; } |
|
|
public Action OnClicked { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public X11TrayIconImpl() |
|
|
public X11TrayIconImpl() |
|
|
{ |
|
|
{ |
|
|
con = DBusHelper.TryGetConnection(); |
|
|
con = DBusHelper.TryGetConnection(); |
|
|
@ -44,8 +42,7 @@ namespace Avalonia.X11 |
|
|
CreateTrayIcon(); |
|
|
CreateTrayIcon(); |
|
|
_ctorFinished = true; |
|
|
_ctorFinished = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async void CreateTrayIcon() |
|
|
public async void CreateTrayIcon() |
|
|
{ |
|
|
{ |
|
|
_statusNotifierWatcher = con.CreateProxy<IStatusNotifierWatcher>("org.kde.StatusNotifierWatcher", |
|
|
_statusNotifierWatcher = con.CreateProxy<IStatusNotifierWatcher>("org.kde.StatusNotifierWatcher", |
|
|
@ -81,7 +78,6 @@ namespace Avalonia.X11 |
|
|
_isActive = false; |
|
|
_isActive = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Dispose() |
|
|
public void Dispose() |
|
|
{ |
|
|
{ |
|
|
_isDisposed = true; |
|
|
_isDisposed = true; |
|
|
@ -115,8 +111,7 @@ namespace Avalonia.X11 |
|
|
_icon = new DbusPixmap(w, h, pixByteArray); |
|
|
_icon = new DbusPixmap(w, h, pixByteArray); |
|
|
_statusNotifierItemDbusObj.SetIcon(_icon); |
|
|
_statusNotifierItemDbusObj.SetIcon(_icon); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void SetIsVisible(bool visible) |
|
|
public void SetIsVisible(bool visible) |
|
|
{ |
|
|
{ |
|
|
if (con == null || _isDisposed || !_ctorFinished) return; |
|
|
if (con == null || _isDisposed || !_ctorFinished) return; |
|
|
|