Basic exiting and TTY switching
This commit is contained in:
parent
840f0e31c5
commit
6140326f85
4 changed files with 48 additions and 4 deletions
8
src/input/input_manager.rs
Normal file
8
src/input/input_manager.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
use crate::input::Keyboard;
|
||||||
|
|
||||||
|
use wlroots::input;
|
||||||
|
|
||||||
|
pub fn input_manager() -> input::manager::Builder {
|
||||||
|
input::manager::Builder::default()
|
||||||
|
.keyboard_added(|_compositor_handle, _keyboard_handle| Some(Box::new(Keyboard)))
|
||||||
|
}
|
31
src/input/keyboard.rs
Normal file
31
src/input/keyboard.rs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
use wlroots::{
|
||||||
|
compositor,
|
||||||
|
input::{self, keyboard},
|
||||||
|
xkbcommon::xkb::keysyms,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct Keyboard;
|
||||||
|
|
||||||
|
impl input::keyboard::Handler for Keyboard {
|
||||||
|
fn on_key(
|
||||||
|
&mut self,
|
||||||
|
compositor_handle: compositor::Handle,
|
||||||
|
_keyboard_handle: keyboard::Handle,
|
||||||
|
key_event: &keyboard::event::Key,
|
||||||
|
) {
|
||||||
|
for key in key_event.pressed_keys() {
|
||||||
|
match key {
|
||||||
|
keysyms::KEY_Escape => compositor::terminate(),
|
||||||
|
keysyms::KEY_XF86Switch_VT_1 ..= keysyms::KEY_XF86Switch_VT_12 => {
|
||||||
|
compositor_handle.run(|compositor| {
|
||||||
|
let backend = compositor.backend_mut();
|
||||||
|
if let Some(mut session) = backend.get_session() {
|
||||||
|
session.change_vt(key - keysyms::KEY_XF86Switch_VT_1 + 1);
|
||||||
|
}
|
||||||
|
}).unwrap();
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
src/input/mod.rs
Normal file
5
src/input/mod.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
mod input_manager;
|
||||||
|
mod keyboard;
|
||||||
|
|
||||||
|
pub use self::input_manager::*;
|
||||||
|
pub use self::keyboard::*;
|
|
@ -1,3 +1,5 @@
|
||||||
|
mod input;
|
||||||
|
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
use wlroots::{
|
use wlroots::{
|
||||||
|
@ -14,10 +16,7 @@ fn main() {
|
||||||
fn init_logs() {
|
fn init_logs() {
|
||||||
init_logging(WLR_INFO, None);
|
init_logging(WLR_INFO, None);
|
||||||
|
|
||||||
env_logger::Builder::from_env(
|
env_logger::Builder::from_env(env_logger::Env::default().filter("KIWMI_LOG")).init();
|
||||||
env_logger::Env::default()
|
|
||||||
.filter("KIWMI_LOG")
|
|
||||||
).init();
|
|
||||||
|
|
||||||
info!("Logger initialized!");
|
info!("Logger initialized!");
|
||||||
}
|
}
|
||||||
|
@ -26,5 +25,6 @@ fn build_compositor() -> compositor::Compositor {
|
||||||
compositor::Builder::new()
|
compositor::Builder::new()
|
||||||
.gles2(true)
|
.gles2(true)
|
||||||
.data_device(true)
|
.data_device(true)
|
||||||
|
.input_manager(input::input_manager())
|
||||||
.build_auto(())
|
.build_auto(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue