From c5729befe5e8afa58ce853f22d060028ad6bddc7 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 7 Jul 2023 17:03:14 +1000 Subject: [PATCH] inputd: do not reswitch if the same Signed-off-by: Anhad Singh --- inputd/src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/inputd/src/main.rs b/inputd/src/main.rs index 3f78339d2e..a963789c06 100644 --- a/inputd/src/main.rs +++ b/inputd/src/main.rs @@ -158,11 +158,17 @@ impl SchemeMut for InputScheme { if let Some(new_active) = new_active_opt { if let Some(vt) = self.vts.get(&new_active) { + // If the VT is already active, don't do anything. + if let Some(current) = self.active_vt.as_ref() { + if vt == ¤t.0 { + continue; + } + } + // Result: display/virtio-gpu:3/acvtivate let activate = format!("display/{vt}:{new_active}/activate"); log::info!("inputd: switching to VT #{new_active} ({activate})"); - let file = File::open(&activate).unwrap(); // Drop the old active VT first. // // TODO(andypython): This can be drastically improved by introducting something @@ -180,6 +186,7 @@ impl SchemeMut for InputScheme { } } + let file = File::open(&activate).unwrap(); self.active_vt = Some((vt.clone(), file)); } else { log::warn!("inputd: switch to non-existent VT #{new_active} was requested");