dbus: Refactor to share DBus connections

We should avoid creating more than one session connection or more than
one system connection. We should also ideally avoid blocking the main
thread.

For now this still uses blocking in a couple places, but wrapping async
code (which is how `zbus::blocking` is implemented anyway).

This moves the `NameOwners` creation out of `A11yKeyboardMonitorState`,
so it can be shared with other things. We will likely want that for
https://github.com/pop-os/cosmic-comp/pull/465 to define a secured
protocol to pass an fd to the portal, and potentially any other
sensitive DBus protocols implemented by the compositor.
This commit is contained in:
Ian Douglas Scott 2026-03-05 15:56:06 -08:00 committed by Victoria Brekenfeld
parent c8d9ff1215
commit 4eaaf4f55c
9 changed files with 238 additions and 173 deletions

View file

@ -1577,7 +1577,9 @@ impl Common {
self.popups.cleanup();
self.toplevel_info_state.refresh(&self.workspace_state);
self.refresh_idle_inhibit();
self.a11y_keyboard_monitor_state.refresh();
if let Some(mut a11y_keyboard_monitor) = self.dbus_state.a11y_keyboard_monitor() {
a11y_keyboard_monitor.refresh();
}
self.image_copy_capture_state.cleanup();
}