dbus: Use calloop async executor

New version of callop has a fix for this, so we're no longer blocked
from using it.
This commit is contained in:
Ian Douglas Scott 2026-02-13 12:57:05 -08:00 committed by Victoria Brekenfeld
parent 3c834e9c85
commit 571565c28e
3 changed files with 17 additions and 14 deletions

View file

@ -1,6 +1,5 @@
// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/data/dbus-interfaces/org.freedesktop.a11y.xml
use futures_executor::ThreadPool;
use smithay::{
backend::input::KeyState,
input::keyboard::{KeysymHandle, ModifiersState},
@ -72,7 +71,7 @@ impl Clients {
#[derive(Debug)]
pub struct A11yKeyboardMonitorState {
executor: ThreadPool,
executor: calloop::futures::Scheduler<()>,
clients: Arc<Mutex<Clients>>,
active_virtual_mods: HashSet<Keysym>,
conn: Arc<OnceLock<zbus::Connection>>,
@ -80,7 +79,7 @@ pub struct A11yKeyboardMonitorState {
}
impl A11yKeyboardMonitorState {
pub fn new(executor: &ThreadPool) -> Self {
pub fn new(executor: &calloop::futures::Scheduler<()>) -> Self {
let clients = Arc::new(Mutex::new(Clients::default()));
let clients_clone = clients.clone();
let conn_cell = Arc::new(OnceLock::new());
@ -88,7 +87,7 @@ impl A11yKeyboardMonitorState {
let name_owners_cell = Arc::new(OnceLock::new());
let name_owners_cell_clone = name_owners_cell.clone();
let executor_clone = executor.clone();
executor.spawn_ok(async move {
let _ = executor.schedule(async move {
match serve(clients_clone, &executor_clone).await {
Ok((conn, name_owners)) => {
conn_cell_clone.set(conn).unwrap();
@ -186,7 +185,7 @@ impl A11yKeyboardMonitorState {
unichar,
keysym.raw_code().raw() as u16,
);
self.executor.spawn_ok(async {
let _ = self.executor.schedule(async {
let _ = future.await;
});
}
@ -314,7 +313,7 @@ impl KeyboardMonitor {
async fn serve(
clients: Arc<Mutex<Clients>>,
executor: &ThreadPool,
executor: &calloop::futures::Scheduler<()>,
) -> zbus::Result<(zbus::Connection, NameOwners)> {
let conn = zbus::Connection::session().await?;
let name_owners = NameOwners::new(&conn, executor).await?;

View file

@ -2,9 +2,10 @@
//!
//! Compare to Mutter's `MetaDbusAccessChecker`
use futures_executor::ThreadPool;
use futures_util::stream::FusedStream;
use futures_util::{StreamExt, stream::FuturesUnordered};
use futures_util::{
StreamExt,
stream::{FusedStream, FuturesUnordered},
};
use std::{
collections::{HashMap, HashSet},
future::{Future, poll_fn},
@ -94,7 +95,10 @@ fn update_task(inner: Weak<Mutex<Inner>>) -> impl Future<Output = ()> {
pub struct NameOwners(Arc<Mutex<Inner>>);
impl NameOwners {
pub async fn new(connection: &zbus::Connection, executor: &ThreadPool) -> zbus::Result<Self> {
pub async fn new(
connection: &zbus::Connection,
executor: &calloop::futures::Scheduler<()>,
) -> zbus::Result<Self> {
let dbus = fdo::DBusProxy::new(connection).await?;
let stream = dbus.receive_name_owner_changed().await?;
@ -126,7 +130,7 @@ impl NameOwners {
}));
if enforce {
executor.spawn_ok(update_task(Arc::downgrade(&inner)));
let _ = executor.schedule(update_task(Arc::downgrade(&inner)));
}
Ok(NameOwners(inner))

View file

@ -32,7 +32,6 @@ use crate::{
use anyhow::Context;
use calloop::RegistrationToken;
use cosmic_comp_config::output::comp::{OutputConfig, OutputState};
use futures_executor::ThreadPool;
use i18n_embed::{
DesktopLanguageRequester,
fluent::{FluentLanguageLoader, fluent_language_loader},
@ -234,7 +233,7 @@ pub struct Common {
pub display_handle: DisplayHandle,
pub event_loop_handle: LoopHandle<'static, State>,
pub event_loop_signal: LoopSignal,
pub async_executor: ThreadPool,
pub async_executor: calloop::futures::Scheduler<()>,
pub popups: PopupManager,
pub shell: Arc<parking_lot::RwLock<Shell>>,
@ -727,7 +726,8 @@ impl State {
);
let workspace_state = WorkspaceState::new(dh, client_not_sandboxed);
let async_executor = ThreadPool::builder().pool_size(1).create().unwrap();
let (source, async_executor) = calloop::futures::executor().unwrap();
handle.insert_source(source, |_, _, _| {}).unwrap();
if let Err(err) = crate::dbus::init(&handle) {
tracing::warn!(?err, "Failed to initialize dbus handlers");