Skip to content

Commit

Permalink
Bump DBus stack take 2 (#15685)
Browse files Browse the repository at this point in the history
* Bump DBus stack
- Use new Variant system

* Fix merge issues

* Intentionally break the DBus spec

* Dispose DBus connection and signal watchers

* Bump Tmds,DBus.Protocol

* Dispose DBus objects correctly

* Use PathHandler for DBus objects

* Revert to old initialization

* Bump DBus packages

* Fix global menu

* Add comment about wrapped variants

* Bump Tmds.DBus.SourceGenerator

* Update api baseline

* Bump Tmds.DBus stack

---------

Co-authored-by: Max Katz <maxkatz6@outlook.com>
  • Loading branch information
affederaffe and maxkatz6 authored Aug 19, 2024
1 parent 6d10a68 commit 1d9a018
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 207 deletions.
10 changes: 10 additions & 0 deletions api/Avalonia.FreeDesktop.nupkg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Tmds.DBus.SourceGenerator.PropertyChanges`1</Target>
<Left>baseline/netstandard2.0/Avalonia.FreeDesktop.dll</Left>
<Right>target/netstandard2.0/Avalonia.FreeDesktop.dll</Right>
</Suppression>
</Suppressions>
4 changes: 2 additions & 2 deletions src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Tmds.DBus.Protocol" Version="0.16.0" />
<PackageReference Include="Tmds.DBus.SourceGenerator" Version="0.0.15" PrivateAssets="all" />
<PackageReference Include="Tmds.DBus.Protocol" Version="0.20.0" />
<PackageReference Include="Tmds.DBus.SourceGenerator" Version="0.0.19" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.FreeDesktop/DBusIme/Fcitx/FcitxICWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public ValueTask<IDisposable> WatchCommitStringAsync(Action<Exception?, string>

public ValueTask<IDisposable> WatchForwardKeyAsync(Action<Exception?, (uint keyval, uint state, int type)> handler) =>
_old?.WatchForwardKeyAsync(handler)
?? _modern?.WatchForwardKeyAsync((e, ev) => handler.Invoke(e, (ev.keyval, ev.state, ev.type ? 1 : 0)))
?? _modern?.WatchForwardKeyAsync((e, ev) => handler.Invoke(e, (ev.Keyval, ev.State, ev.Type ? 1 : 0)))
?? new ValueTask<IDisposable>(Disposable.Empty);

public ValueTask<IDisposable> WatchUpdateFormattedPreeditAsync(
Action<Exception?, ((string?, int)[]? str, int cursorpos)> handler) =>
_old?.WatchUpdateFormattedPreeditAsync(handler!)
?? _modern?.WatchUpdateFormattedPreeditAsync(handler!)
?? new ValueTask<IDisposable>(Disposable.Empty);

public Task SetCapacityAsync(uint flags) =>
_old?.SetCapacityAsync(flags) ?? _modern?.SetCapabilityAsync(flags) ?? Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override async Task<bool> Connect(string name)
var resp = await method.CreateICv3Async(GetAppName(),
Process.GetCurrentProcess().Id);

var proxy = new OrgFcitxFcitxInputContext(Connection, name, $"/inputcontext_{resp.icid}");
var proxy = new OrgFcitxFcitxInputContext(Connection, name, $"/inputcontext_{resp.Icid}");
_context = new FcitxICWrapper(proxy);
}
else
Expand Down
21 changes: 10 additions & 11 deletions src/Avalonia.FreeDesktop/DBusIme/IBus/IBusX11TextInputMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,16 @@ private void OnShowPreedit(Exception? obj)
Client.SetPreeditText(_preeditText, _preeditText == null ? null : _preeditCursor);
}

private void OnUpdatePreedit(Exception? arg1, (DBusVariantItem text, uint cursor_pos, bool visible) preeditComponents)
private void OnUpdatePreedit(Exception? arg1, (VariantValue Text, uint CursorPos, bool Visible) preeditComponents)
{
if (preeditComponents.text is { Value: DBusStructItem { Count: >= 3 } structItem } &&
structItem[2] is DBusStringItem stringItem)
if (preeditComponents.Text is { Type: VariantValueType.Struct, Count: >= 3 } structItem && structItem.GetItem(2) is { Type: VariantValueType.String} stringItem)
{
_preeditText = stringItem.Value;
_preeditText = stringItem.GetString();
_preeditCursor = _preeditText != null
? Utf16Utils.CharacterOffsetToStringOffset(_preeditText,
(int)Math.Min(preeditComponents.cursor_pos, int.MaxValue), false)
(int)Math.Min(preeditComponents.CursorPos, int.MaxValue), false)
: 0;

_preeditShown = true;
}
else
Expand Down Expand Up @@ -102,13 +101,13 @@ private void OnForwardKey(Exception? e, (uint keyval, uint keycode, uint state)
});
}

private void OnCommitText(Exception? e, DBusVariantItem variantItem)
private void OnCommitText(Exception? e, VariantValue variantItem)
{
if (_insideReset > 0)
if (_insideReset > 0)
{
// For some reason iBus can trigger a CommitText while being reset.
// Thankfully the signal is sent _during_ Reset call processing,
// so it arrives on-the-wire before Reset call result, so we can
// so it arrives on-the-wire before Reset call result, so we can
// check if we have any pending Reset calls and ignore the signal here
return;
}
Expand All @@ -118,8 +117,8 @@ private void OnCommitText(Exception? e, DBusVariantItem variantItem)
return;
}

if (variantItem.Value is DBusStructItem { Count: >= 3 } structItem && structItem[2] is DBusStringItem stringItem)
FireCommit(stringItem.Value);
if (variantItem.Count >= 3 && variantItem.GetItem(2) is { Type: VariantValueType.String } stringItem)
FireCommit(stringItem.GetString());
}

protected override Task DisconnectAsync() => _service?.DestroyAsync() ?? Task.CompletedTask;
Expand Down
Loading

0 comments on commit 1d9a018

Please sign in to comment.