dbus: Remove unused return value from dbus::init
If we don't use this anyway, this can make things simpler.
This commit is contained in:
parent
571565c28e
commit
c8d9ff1215
1 changed files with 29 additions and 35 deletions
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
utils::prelude::OutputExt,
|
||||
};
|
||||
use anyhow::{Context, Result};
|
||||
use calloop::{InsertError, LoopHandle, RegistrationToken, stream::StreamSource};
|
||||
use calloop::{InsertError, LoopHandle, stream::StreamSource};
|
||||
use cosmic_comp_config::output::comp::OutputState;
|
||||
use futures_executor::block_on;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -16,54 +16,48 @@ pub mod logind;
|
|||
mod name_owners;
|
||||
mod power;
|
||||
|
||||
pub fn init(evlh: &LoopHandle<'static, State>) -> Result<Vec<RegistrationToken>> {
|
||||
let mut tokens = Vec::new();
|
||||
|
||||
pub fn init(evlh: &LoopHandle<'static, State>) -> Result<()> {
|
||||
match block_on(power::init()) {
|
||||
Ok(power_daemon) => {
|
||||
if let Ok(stream) = block_on(power_daemon.receive_hot_plug_detect()) {
|
||||
let source = StreamSource::new(stream).unwrap();
|
||||
let token = evlh
|
||||
.insert_source(source, |_, _, state| {
|
||||
let nodes = match &mut state.backend {
|
||||
BackendData::Kms(kms) => {
|
||||
kms.drm_devices.keys().cloned().collect::<Vec<_>>()
|
||||
}
|
||||
_ => Vec::new(),
|
||||
};
|
||||
let mut added = Vec::new();
|
||||
for node in nodes {
|
||||
match state.device_changed(node.dev_id()) {
|
||||
Ok(outputs) => added.extend(outputs),
|
||||
Err(err) => {
|
||||
tracing::error!(?err, "Failed to update drm device {}.", node)
|
||||
}
|
||||
evlh.insert_source(source, |_, _, state| {
|
||||
let nodes = match &mut state.backend {
|
||||
BackendData::Kms(kms) => {
|
||||
kms.drm_devices.keys().cloned().collect::<Vec<_>>()
|
||||
}
|
||||
_ => Vec::new(),
|
||||
};
|
||||
let mut added = Vec::new();
|
||||
for node in nodes {
|
||||
match state.device_changed(node.dev_id()) {
|
||||
Ok(outputs) => added.extend(outputs),
|
||||
Err(err) => {
|
||||
tracing::error!(?err, "Failed to update drm device {}.", node)
|
||||
}
|
||||
}
|
||||
if let Err(err) = state.refresh_output_config() {
|
||||
warn!("Unable to load output config: {}", err);
|
||||
if !added.is_empty() {
|
||||
for output in added {
|
||||
output.config_mut().enabled = OutputState::Disabled;
|
||||
}
|
||||
if let Err(err) = state.refresh_output_config() {
|
||||
error!("Unrecoverable config error: {}", err);
|
||||
}
|
||||
}
|
||||
if let Err(err) = state.refresh_output_config() {
|
||||
warn!("Unable to load output config: {}", err);
|
||||
if !added.is_empty() {
|
||||
for output in added {
|
||||
output.config_mut().enabled = OutputState::Disabled;
|
||||
}
|
||||
if let Err(err) = state.refresh_output_config() {
|
||||
error!("Unrecoverable config error: {}", err);
|
||||
}
|
||||
}
|
||||
})
|
||||
.map_err(|InsertError { error, .. }| error)
|
||||
.with_context(|| "Failed to add channel to event_loop")?;
|
||||
|
||||
tokens.push(token);
|
||||
}
|
||||
})
|
||||
.map_err(|InsertError { error, .. }| error)
|
||||
.with_context(|| "Failed to add channel to event_loop")?;
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::info!(?err, "Failed to connect to com.system76.PowerDaemon");
|
||||
}
|
||||
};
|
||||
|
||||
Ok(tokens)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Updated the D-Bus activation environment with `WAYLAND_DISPLAY` and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue