Skip to content

[Proof of Concept/WIP] Tmds to Avalonia.DBus migration#20799

Draft
jmacato wants to merge 13 commits intomasterfrom
fixes/avdbus-impl2
Draft

[Proof of Concept/WIP] Tmds to Avalonia.DBus migration#20799
jmacato wants to merge 13 commits intomasterfrom
fixes/avdbus-impl2

Conversation

@jmacato
Copy link
Copy Markdown
Member

@jmacato jmacato commented Mar 3, 2026

Switching our dbus backend for Avalonia.FreeDesktop from Tmds to Avalonia.DBus.

Proof of concept for now to see if this is a viable migration path.

jmacato added 8 commits March 3, 2026 20:50
Create DBusXml/Types.xml defining named structs (MenuLayout,
MenuItemProperties, MenuEvent, IconPixmap, ToolTip, InputContextArg,
FormattedPreeditSegment) and register it as an AdditionalFiles entry
in the csproj so the source generator uses readable type names.
Add xmlns:av namespace, av:ImportTypes, and av:TypeDefinition annotations
so the source generator produces named struct types instead of tuples:
- com.canonical.dbusmenu.xml: MenuLayout, MenuItemProperties, MenuEvent
- org.kde.StatusNotifierItem.xml: IconPixmap, ToolTip
- org.fcitx.Fcitx.InputMethod1.xml: InputContextArg
- org.fcitx.Fcitx.InputContext.xml: FormattedPreeditSegment
- org.fcitx.Fcitx.InputContext1.xml: FormattedPreeditSegment
Replace auto-generated DbusStruct_* names with meaningful type names
from the av:TypeDefinition annotations added to the DBus XML files:
- DbusStruct_Riaesvavz -> MenuLayout
- DbusStruct_Riaesvz -> MenuItemProperties
- DbusStruct_Risvuz -> MenuEvent
- DbusStruct_Riiayz -> IconPixmap
- DbusStruct_Rsariiayzssz -> ToolTip
- DbusStruct_Rssz -> InputContextArg
- DbusStruct_Rsiz -> FormattedPreeditSegment

Also update property accessors (.Item1/.Item2 -> named properties)
in DBusMenuExporter.cs and FcitxX11TextInputMethod.cs.
Replace Tmds.DBus.Protocol/SourceGenerator with Avalonia.DBus across
all FreeDesktop platform code: DBusHelper, system dialogs, platform
settings, and IME implementations (IBus, Fcitx).

Key changes:
- Connection → DBusConnection
- VariantValue → DBusVariant
- ObjectPath → DBusObjectPath
- Callback signatures simplified (removed Exception? first param)
- Struct/Array helpers → DBusStruct/List<T>
@jmacato jmacato requested review from MrJul and kekekeks March 3, 2026 16:40
@avaloniaui-bot
Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0062895-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@jmacato
Copy link
Copy Markdown
Member Author

jmacato commented Mar 3, 2026

Leaving this PR for future review/hold as trayicons/menus/dialogs seems to work

@avaloniaui-bot
Copy link
Copy Markdown

You can test this PR using the following package version. 12.0.999-cibuild0062907-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@tmds
Copy link
Copy Markdown
Contributor

tmds commented Mar 26, 2026

@jmacato @kekekeks @maxkatz6 I'm curious why you'd want to maintain your own library over using Tmds.DBus.Protocol. Do you have any insights you can share with me? It would be helpful for me to know what is not working well.

@kekekeks
Copy link
Copy Markdown
Member

We are planning to route dbus calls over other (non-socket) transports.

@kekekeks
Copy link
Copy Markdown
Member

Another problem we've faced was introspection that was poorly supported by existing roslyn generator. We didn't need it for previously used DBus APIs, but with AT-SPI2 it became a problem.

We needed something that we could make to work properly with accessibility, so we've opted to try writing our own generator and to use libdbus as reference wire transport to make sure that we aren't losing anything in translation (like that time with convenience variant-in-variant wrapping).

So right now we are using our in-house DBus binding for AT-SPI2 only. We'll be evaluating our options later this year. We investigate if our approaches could be somehow upstreamed.

@kekekeks
Copy link
Copy Markdown
Member

Basically the current thing used in production is in-house generator + libdbus wrapper. There is some code for managed wire transport, but it's currently experimental.

@tmds
Copy link
Copy Markdown
Contributor

tmds commented Mar 30, 2026

We are planning to route dbus calls over other (non-socket) transports.

Can you be more specific what "other (non-socket)" actually is?

@tmds
Copy link
Copy Markdown
Contributor

tmds commented Mar 30, 2026

Can you be more specific what "other (non-socket)" actually is?

ok, I assume this is the libdbus wrapper.

@kekekeks
Copy link
Copy Markdown
Member

Non-socket = abstract message-based transport. Imagine incapsulating DBusMessage packets over some other protocol or even over something cursed like WM_COPYDATA. This kind of thing.

@kekekeks
Copy link
Copy Markdown
Member

kekekeks commented Mar 30, 2026

i. e. we have plans for using AT-SPI2 for non-dbus environments.

@kekekeks
Copy link
Copy Markdown
Member

Note that the whole thing is pretty much WIP, we are including the repo as a submodule and building it with a switch that makes types internal. Once we get it into a shape that covers our usage scenarios we'll make a better document on what's different.

@tmds
Copy link
Copy Markdown
Contributor

tmds commented Mar 30, 2026

@kekekeks I don't think you have any issues with Tmds.DBus.Protocol. If you'd want to do the message-based transport with the library, we can explore that. For the generator, I'll be looking to (finally) add support for handler types to the generator that comes with the project. Thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants