aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-08-09 14:21:29 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-08-10 14:50:51 +0400
commit0047272673f8cc3679299b2626a526b9a329b7de (patch)
tree4f8398eafd7aa9cb4b0325fadb1568f274983ecc /src
parent7527cad20035c87255826ee276658b0b89d58f7f (diff)
downloadniri-0047272673f8cc3679299b2626a526b9a329b7de.tar.gz
niri-0047272673f8cc3679299b2626a526b9a329b7de.tar.bz2
niri-0047272673f8cc3679299b2626a526b9a329b7de.zip
Implement TTY switching
Having to pass backend around turns out to be a problem...
Diffstat (limited to 'src')
-rw-r--r--src/input.rs10
-rw-r--r--src/tty.rs10
-rw-r--r--src/winit.rs2
3 files changed, 18 insertions, 4 deletions
diff --git a/src/input.rs b/src/input.rs
index ad182645..f2a91082 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -15,7 +15,11 @@ enum InputAction {
}
impl Niri {
- pub fn process_input_event<I: InputBackend>(&mut self, event: InputEvent<I>) {
+ pub fn process_input_event<I: InputBackend>(
+ &mut self,
+ change_vt: &mut dyn FnMut(i32),
+ event: InputEvent<I>,
+ ) {
trace!("process_input_event");
match event {
@@ -45,7 +49,9 @@ impl Niri {
info!("quitting because Esc was pressed");
self.stop_signal.stop()
}
- InputAction::ChangeVt(vt) => todo!(),
+ InputAction::ChangeVt(vt) => {
+ (*change_vt)(vt);
+ }
}
}
}
diff --git a/src/tty.rs b/src/tty.rs
index bc5fe907..b2a7e61a 100644
--- a/src/tty.rs
+++ b/src/tty.rs
@@ -117,7 +117,9 @@ impl Tty {
let input_backend = LibinputInputBackend::new(libinput.clone());
event_loop
.insert_source(input_backend, |event, _, data| {
- data.niri.process_input_event(event)
+ let tty = data.tty.as_mut().unwrap();
+ let mut change_vt = |vt| tty.change_vt(vt);
+ data.niri.process_input_event(&mut change_vt, event);
})
.unwrap();
@@ -440,4 +442,10 @@ impl Tty {
)?;
Ok(compositor)
}
+
+ fn change_vt(&mut self, vt: i32) {
+ if let Err(err) = self.session.change_vt(vt) {
+ error!("error changing VT: {err}");
+ }
+ }
}
diff --git a/src/winit.rs b/src/winit.rs
index d0994f7a..b1e9bf65 100644
--- a/src/winit.rs
+++ b/src/winit.rs
@@ -110,7 +110,7 @@ impl Winit {
None,
);
}
- WinitEvent::Input(event) => niri.process_input_event(event),
+ WinitEvent::Input(event) => niri.process_input_event(&mut |_| (), event),
_ => (),
});