aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-08-09 11:03:38 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-08-10 14:50:51 +0400
commit396ab935859f4eb46b3cf7aa36e7b496b5898b72 (patch)
treef5486a07986a8d6ade9c32acb8b734101c7fe28f /src/input.rs
parentb8e79e9cc8820e4385a8a3fe2912eb2e6f0b81f8 (diff)
downloadniri-396ab935859f4eb46b3cf7aa36e7b496b5898b72.tar.gz
niri-396ab935859f4eb46b3cf7aa36e7b496b5898b72.tar.bz2
niri-396ab935859f4eb46b3cf7aa36e7b496b5898b72.zip
Restructure things and add tty backend
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/input.rs b/src/input.rs
index 9fd894b5..9d167a0a 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -2,28 +2,52 @@ use smithay::backend::input::{
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent,
KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent,
};
-use smithay::input::keyboard::FilterResult;
+use smithay::input::keyboard::{keysyms, FilterResult};
use smithay::input::pointer::{AxisFrame, ButtonEvent, MotionEvent};
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::utils::SERIAL_COUNTER;
-use crate::state::Smallvil;
+use crate::niri::Niri;
-impl Smallvil {
+enum InputAction {
+ Quit,
+ ChangeVt(i32),
+}
+
+impl Niri {
pub fn process_input_event<I: InputBackend>(&mut self, event: InputEvent<I>) {
+ trace!("process_input_event");
+
match event {
InputEvent::Keyboard { event, .. } => {
let serial = SERIAL_COUNTER.next_serial();
let time = Event::time_msec(&event);
- self.seat.get_keyboard().unwrap().input::<(), _>(
+ let action = self.seat.get_keyboard().unwrap().input(
self,
event.key_code(),
event.state(),
serial,
time,
- |_, _, _| FilterResult::Forward,
+ |_, _, keysym| match keysym.modified_sym() {
+ keysyms::KEY_Escape => FilterResult::Intercept(InputAction::Quit),
+ keysym @ keysyms::KEY_XF86Switch_VT_1..=keysyms::KEY_XF86Switch_VT_12 => {
+ let vt = (keysym - keysyms::KEY_XF86Switch_VT_1 + 1) as i32;
+ FilterResult::Intercept(InputAction::ChangeVt(vt))
+ }
+ _ => FilterResult::Forward,
+ },
);
+
+ if let Some(action) = action {
+ match action {
+ InputAction::Quit => {
+ info!("quitting because Esc was pressed");
+ self.stop_signal.stop()
+ }
+ InputAction::ChangeVt(vt) => todo!(),
+ }
+ }
}
InputEvent::PointerMotion { .. } => {}
InputEvent::PointerMotionAbsolute { event, .. } => {