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:
parent
3c834e9c85
commit
571565c28e
3 changed files with 17 additions and 14 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/data/dbus-interfaces/org.freedesktop.a11y.xml
|
// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/data/dbus-interfaces/org.freedesktop.a11y.xml
|
||||||
|
|
||||||
use futures_executor::ThreadPool;
|
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::input::KeyState,
|
backend::input::KeyState,
|
||||||
input::keyboard::{KeysymHandle, ModifiersState},
|
input::keyboard::{KeysymHandle, ModifiersState},
|
||||||
|
|
@ -72,7 +71,7 @@ impl Clients {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct A11yKeyboardMonitorState {
|
pub struct A11yKeyboardMonitorState {
|
||||||
executor: ThreadPool,
|
executor: calloop::futures::Scheduler<()>,
|
||||||
clients: Arc<Mutex<Clients>>,
|
clients: Arc<Mutex<Clients>>,
|
||||||
active_virtual_mods: HashSet<Keysym>,
|
active_virtual_mods: HashSet<Keysym>,
|
||||||
conn: Arc<OnceLock<zbus::Connection>>,
|
conn: Arc<OnceLock<zbus::Connection>>,
|
||||||
|
|
@ -80,7 +79,7 @@ pub struct A11yKeyboardMonitorState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 = Arc::new(Mutex::new(Clients::default()));
|
||||||
let clients_clone = clients.clone();
|
let clients_clone = clients.clone();
|
||||||
let conn_cell = Arc::new(OnceLock::new());
|
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 = Arc::new(OnceLock::new());
|
||||||
let name_owners_cell_clone = name_owners_cell.clone();
|
let name_owners_cell_clone = name_owners_cell.clone();
|
||||||
let executor_clone = executor.clone();
|
let executor_clone = executor.clone();
|
||||||
executor.spawn_ok(async move {
|
let _ = executor.schedule(async move {
|
||||||
match serve(clients_clone, &executor_clone).await {
|
match serve(clients_clone, &executor_clone).await {
|
||||||
Ok((conn, name_owners)) => {
|
Ok((conn, name_owners)) => {
|
||||||
conn_cell_clone.set(conn).unwrap();
|
conn_cell_clone.set(conn).unwrap();
|
||||||
|
|
@ -186,7 +185,7 @@ impl A11yKeyboardMonitorState {
|
||||||
unichar,
|
unichar,
|
||||||
keysym.raw_code().raw() as u16,
|
keysym.raw_code().raw() as u16,
|
||||||
);
|
);
|
||||||
self.executor.spawn_ok(async {
|
let _ = self.executor.schedule(async {
|
||||||
let _ = future.await;
|
let _ = future.await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -314,7 +313,7 @@ impl KeyboardMonitor {
|
||||||
|
|
||||||
async fn serve(
|
async fn serve(
|
||||||
clients: Arc<Mutex<Clients>>,
|
clients: Arc<Mutex<Clients>>,
|
||||||
executor: &ThreadPool,
|
executor: &calloop::futures::Scheduler<()>,
|
||||||
) -> zbus::Result<(zbus::Connection, NameOwners)> {
|
) -> zbus::Result<(zbus::Connection, NameOwners)> {
|
||||||
let conn = zbus::Connection::session().await?;
|
let conn = zbus::Connection::session().await?;
|
||||||
let name_owners = NameOwners::new(&conn, executor).await?;
|
let name_owners = NameOwners::new(&conn, executor).await?;
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
//!
|
//!
|
||||||
//! Compare to Mutter's `MetaDbusAccessChecker`
|
//! Compare to Mutter's `MetaDbusAccessChecker`
|
||||||
|
|
||||||
use futures_executor::ThreadPool;
|
use futures_util::{
|
||||||
use futures_util::stream::FusedStream;
|
StreamExt,
|
||||||
use futures_util::{StreamExt, stream::FuturesUnordered};
|
stream::{FusedStream, FuturesUnordered},
|
||||||
|
};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
future::{Future, poll_fn},
|
future::{Future, poll_fn},
|
||||||
|
|
@ -94,7 +95,10 @@ fn update_task(inner: Weak<Mutex<Inner>>) -> impl Future<Output = ()> {
|
||||||
pub struct NameOwners(Arc<Mutex<Inner>>);
|
pub struct NameOwners(Arc<Mutex<Inner>>);
|
||||||
|
|
||||||
impl NameOwners {
|
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 dbus = fdo::DBusProxy::new(connection).await?;
|
||||||
let stream = dbus.receive_name_owner_changed().await?;
|
let stream = dbus.receive_name_owner_changed().await?;
|
||||||
|
|
||||||
|
|
@ -126,7 +130,7 @@ impl NameOwners {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if enforce {
|
if enforce {
|
||||||
executor.spawn_ok(update_task(Arc::downgrade(&inner)));
|
let _ = executor.schedule(update_task(Arc::downgrade(&inner)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(NameOwners(inner))
|
Ok(NameOwners(inner))
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ use crate::{
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use calloop::RegistrationToken;
|
use calloop::RegistrationToken;
|
||||||
use cosmic_comp_config::output::comp::{OutputConfig, OutputState};
|
use cosmic_comp_config::output::comp::{OutputConfig, OutputState};
|
||||||
use futures_executor::ThreadPool;
|
|
||||||
use i18n_embed::{
|
use i18n_embed::{
|
||||||
DesktopLanguageRequester,
|
DesktopLanguageRequester,
|
||||||
fluent::{FluentLanguageLoader, fluent_language_loader},
|
fluent::{FluentLanguageLoader, fluent_language_loader},
|
||||||
|
|
@ -234,7 +233,7 @@ pub struct Common {
|
||||||
pub display_handle: DisplayHandle,
|
pub display_handle: DisplayHandle,
|
||||||
pub event_loop_handle: LoopHandle<'static, State>,
|
pub event_loop_handle: LoopHandle<'static, State>,
|
||||||
pub event_loop_signal: LoopSignal,
|
pub event_loop_signal: LoopSignal,
|
||||||
pub async_executor: ThreadPool,
|
pub async_executor: calloop::futures::Scheduler<()>,
|
||||||
|
|
||||||
pub popups: PopupManager,
|
pub popups: PopupManager,
|
||||||
pub shell: Arc<parking_lot::RwLock<Shell>>,
|
pub shell: Arc<parking_lot::RwLock<Shell>>,
|
||||||
|
|
@ -727,7 +726,8 @@ impl State {
|
||||||
);
|
);
|
||||||
let workspace_state = WorkspaceState::new(dh, client_not_sandboxed);
|
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) {
|
if let Err(err) = crate::dbus::init(&handle) {
|
||||||
tracing::warn!(?err, "Failed to initialize dbus handlers");
|
tracing::warn!(?err, "Failed to initialize dbus handlers");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue