Browse Source

update dbus stuff

pull/16111/head
Jumar Macato 2 years ago
parent
commit
066bcab7eb
  1. 4
      src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj
  2. 20
      src/Avalonia.FreeDesktop/DBusMenuExporter.cs
  3. 14
      src/Avalonia.FreeDesktop/DBusTrayIconImpl.cs
  4. 27
      src/Browser/Avalonia.Browser/webapp/package-lock.json

4
src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj

@ -12,8 +12,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Tmds.DBus.Protocol" Version="0.17.0" />
<PackageReference Include="Tmds.DBus.SourceGenerator" Version="0.0.16" PrivateAssets="all" />
<PackageReference Include="Tmds.DBus.Protocol" Version="0.19.0" />
<PackageReference Include="Tmds.DBus.SourceGenerator" Version="0.0.17" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>

20
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<string, Variant>, 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;

14
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
/// </remarks>
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)

27
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"
},

Loading…
Cancel
Save