From df48337d83f78bbd2a923863e73941b6bd236a28 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 21 Jan 2024 10:25:39 +0400 Subject: tty: Delay output config update until resume We can't do anything while paused. --- src/backend/tty.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/backend') diff --git a/src/backend/tty.rs b/src/backend/tty.rs index c093d722..cecb0e29 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -74,6 +74,8 @@ pub struct Tty { // The allocator for the primary GPU. It is only `Some()` if we have a device corresponding to // the primary GPU. primary_allocator: Option>>, + // The output config had changed, but the session is paused, so we need to update it on resume. + update_output_config_on_resume: bool, ipc_outputs: Rc>>, enabled_outputs: Arc>>, } @@ -222,6 +224,7 @@ impl Tty { devices: HashMap::new(), dmabuf_global: None, primary_allocator: None, + update_output_config_on_resume: false, ipc_outputs: Rc::new(RefCell::new(HashMap::new())), enabled_outputs: Arc::new(Mutex::new(HashMap::new())), } @@ -370,6 +373,10 @@ impl Tty { } } + if self.update_output_config_on_resume { + self.on_output_config_changed(niri); + } + self.refresh_ipc_outputs(); } } @@ -1234,6 +1241,13 @@ impl Tty { pub fn on_output_config_changed(&mut self, niri: &mut Niri) { let _span = tracy_client::span!("Tty::on_output_config_changed"); + // If we're inactive, we can't do anything, so just set a flag for later. + if !self.session.is_active() { + self.update_output_config_on_resume = true; + return; + } + self.update_output_config_on_resume = false; + let mut to_disconnect = vec![]; let mut to_connect = vec![]; -- cgit