mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Use Alt as mod with winit backend
This commit is contained in:
+15
-4
@@ -22,10 +22,16 @@ enum InputAction {
|
|||||||
ToggleFullscreen,
|
ToggleFullscreen,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum CompositorMod {
|
||||||
|
Super,
|
||||||
|
Alt,
|
||||||
|
}
|
||||||
|
|
||||||
impl Niri {
|
impl Niri {
|
||||||
pub fn process_input_event<I: InputBackend>(
|
pub fn process_input_event<I: InputBackend>(
|
||||||
&mut self,
|
&mut self,
|
||||||
change_vt: &mut dyn FnMut(i32),
|
change_vt: &mut dyn FnMut(i32),
|
||||||
|
compositor_mod: CompositorMod,
|
||||||
event: InputEvent<I>,
|
event: InputEvent<I>,
|
||||||
) {
|
) {
|
||||||
let _span = tracy_client::span!("process_input_event");
|
let _span = tracy_client::span!("process_input_event");
|
||||||
@@ -44,10 +50,15 @@ impl Niri {
|
|||||||
time,
|
time,
|
||||||
|_, mods, keysym| {
|
|_, mods, keysym| {
|
||||||
if event.state() == KeyState::Pressed {
|
if event.state() == KeyState::Pressed {
|
||||||
|
let mod_down = match compositor_mod {
|
||||||
|
CompositorMod::Super => mods.logo,
|
||||||
|
CompositorMod::Alt => mods.alt,
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME: these don't work in the Russian layout. I guess I'll need to
|
// FIXME: these don't work in the Russian layout. I guess I'll need to
|
||||||
// find a US keymap, then map keys somehow.
|
// find a US keymap, then map keys somehow.
|
||||||
match keysym.modified_sym() {
|
match keysym.modified_sym() {
|
||||||
keysyms::KEY_E if mods.logo => {
|
keysyms::KEY_E if mod_down => {
|
||||||
FilterResult::Intercept(InputAction::Quit)
|
FilterResult::Intercept(InputAction::Quit)
|
||||||
}
|
}
|
||||||
keysym @ keysyms::KEY_XF86Switch_VT_1
|
keysym @ keysyms::KEY_XF86Switch_VT_1
|
||||||
@@ -55,13 +66,13 @@ impl Niri {
|
|||||||
let vt = (keysym - keysyms::KEY_XF86Switch_VT_1 + 1) as i32;
|
let vt = (keysym - keysyms::KEY_XF86Switch_VT_1 + 1) as i32;
|
||||||
FilterResult::Intercept(InputAction::ChangeVt(vt))
|
FilterResult::Intercept(InputAction::ChangeVt(vt))
|
||||||
}
|
}
|
||||||
keysyms::KEY_t if mods.logo => {
|
keysyms::KEY_t if mod_down => {
|
||||||
FilterResult::Intercept(InputAction::SpawnTerminal)
|
FilterResult::Intercept(InputAction::SpawnTerminal)
|
||||||
}
|
}
|
||||||
keysyms::KEY_q if mods.logo => {
|
keysyms::KEY_q if mod_down => {
|
||||||
FilterResult::Intercept(InputAction::CloseWindow)
|
FilterResult::Intercept(InputAction::CloseWindow)
|
||||||
}
|
}
|
||||||
keysyms::KEY_f if mods.logo => {
|
keysyms::KEY_f if mod_down => {
|
||||||
FilterResult::Intercept(InputAction::ToggleFullscreen)
|
FilterResult::Intercept(InputAction::ToggleFullscreen)
|
||||||
}
|
}
|
||||||
_ => FilterResult::Forward,
|
_ => FilterResult::Forward,
|
||||||
|
|||||||
+3
-1
@@ -28,6 +28,7 @@ use smithay::utils::DeviceFd;
|
|||||||
use smithay_drm_extras::edid::EdidInfo;
|
use smithay_drm_extras::edid::EdidInfo;
|
||||||
|
|
||||||
use crate::backend::Backend;
|
use crate::backend::Backend;
|
||||||
|
use crate::input::CompositorMod;
|
||||||
use crate::niri::OutputRenderElements;
|
use crate::niri::OutputRenderElements;
|
||||||
use crate::{LoopData, Niri};
|
use crate::{LoopData, Niri};
|
||||||
|
|
||||||
@@ -111,7 +112,8 @@ impl Tty {
|
|||||||
.insert_source(input_backend, |event, _, data| {
|
.insert_source(input_backend, |event, _, data| {
|
||||||
let tty = data.tty.as_mut().unwrap();
|
let tty = data.tty.as_mut().unwrap();
|
||||||
let mut change_vt = |vt| tty.change_vt(vt);
|
let mut change_vt = |vt| tty.change_vt(vt);
|
||||||
data.niri.process_input_event(&mut change_vt, event);
|
data.niri
|
||||||
|
.process_input_event(&mut change_vt, CompositorMod::Super, event);
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -10,6 +10,7 @@ use smithay::reexports::calloop::LoopHandle;
|
|||||||
use smithay::utils::{Rectangle, Transform};
|
use smithay::utils::{Rectangle, Transform};
|
||||||
|
|
||||||
use crate::backend::Backend;
|
use crate::backend::Backend;
|
||||||
|
use crate::input::CompositorMod;
|
||||||
use crate::niri::OutputRenderElements;
|
use crate::niri::OutputRenderElements;
|
||||||
use crate::{LoopData, Niri};
|
use crate::{LoopData, Niri};
|
||||||
|
|
||||||
@@ -116,7 +117,9 @@ impl Winit {
|
|||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
WinitEvent::Input(event) => niri.process_input_event(&mut |_| (), event),
|
WinitEvent::Input(event) => {
|
||||||
|
niri.process_input_event(&mut |_| (), CompositorMod::Alt, event)
|
||||||
|
}
|
||||||
WinitEvent::Focus(_) => (),
|
WinitEvent::Focus(_) => (),
|
||||||
WinitEvent::Refresh => niri.queue_redraw(),
|
WinitEvent::Refresh => niri.queue_redraw(),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user