refactor: fully restart after the compositor exits
This commit is contained in:
parent
9a94c8f516
commit
fcb16e29c1
3 changed files with 103 additions and 65 deletions
|
|
@ -1,25 +1,25 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
use tokio::sync::oneshot;
|
||||
use tokio::sync::mpsc;
|
||||
use zbus::dbus_interface;
|
||||
|
||||
pub enum SessionRequest {
|
||||
Exit,
|
||||
Restart,
|
||||
}
|
||||
|
||||
pub struct SessionService {
|
||||
pub exit_tx: Option<oneshot::Sender<()>>,
|
||||
pub session_tx: mpsc::Sender<SessionRequest>,
|
||||
}
|
||||
|
||||
#[dbus_interface(name = "com.system76.CosmicSession")]
|
||||
impl SessionService {
|
||||
fn exit(&mut self) {
|
||||
match self.exit_tx.take() {
|
||||
Some(tx) => {
|
||||
tx.send(()).ok();
|
||||
}
|
||||
None => {
|
||||
warn!("previously failed to properly exit session");
|
||||
}
|
||||
}
|
||||
async fn exit(&mut self) {
|
||||
warn!("exiting session");
|
||||
_ = self.session_tx.send(SessionRequest::Exit).await;
|
||||
}
|
||||
|
||||
fn restart(&self) {
|
||||
async fn restart(&self) {
|
||||
warn!("restarting session");
|
||||
_ = self.session_tx.send(SessionRequest::Restart).await;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue