aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-08-27 19:34:37 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-08-27 20:00:28 +0400
commitaf7b978eb405b6c221f8342658fbf5466432b108 (patch)
tree5862c8f81baeafbc8fda378cb605d0c4709419ac /src/input.rs
parent1575753b69cabf7f4d84f765a025ce1d7672b522 (diff)
downloadniri-af7b978eb405b6c221f8342658fbf5466432b108.tar.gz
niri-af7b978eb405b6c221f8342658fbf5466432b108.tar.bz2
niri-af7b978eb405b6c221f8342658fbf5466432b108.zip
Implement taking a monitor screenshot
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/input.rs b/src/input.rs
index c5420623..9ffe0613 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -20,6 +20,7 @@ enum Action {
Quit,
ChangeVt(i32),
Spawn(String),
+ Screenshot,
CloseWindow,
ToggleFullscreen,
FocusLeft,
@@ -48,6 +49,12 @@ enum Action {
ToggleFullWidth,
}
+pub enum BackendAction {
+ None,
+ ChangeVt(i32),
+ Screenshot,
+}
+
pub enum CompositorMod {
Super,
Alt,
@@ -88,6 +95,8 @@ fn action(comp_mod: CompositorMod, keysym: KeysymHandle, mods: ModifiersState) -
KEY_t => Action::Spawn("alacritty".to_owned()),
KEY_d => Action::Spawn("fuzzel".to_owned()),
KEY_n => Action::Spawn("nautilus".to_owned()),
+ // Alt + PrtSc = SysRq
+ KEY_Sys_Req | KEY_Print => Action::Screenshot,
KEY_q => Action::CloseWindow,
KEY_F => Action::ToggleFullscreen,
KEY_comma => Action::ConsumeIntoColumn,
@@ -126,10 +135,9 @@ fn action(comp_mod: CompositorMod, keysym: KeysymHandle, mods: ModifiersState) -
impl Niri {
pub fn process_input_event<I: InputBackend>(
&mut self,
- change_vt: &mut dyn FnMut(i32),
comp_mod: CompositorMod,
event: InputEvent<I>,
- ) {
+ ) -> BackendAction {
let _span = tracy_client::span!("process_input_event");
trace!("process_input_event");
@@ -167,13 +175,16 @@ impl Niri {
self.stop_signal.stop()
}
Action::ChangeVt(vt) => {
- (*change_vt)(vt);
+ return BackendAction::ChangeVt(vt);
}
Action::Spawn(command) => {
if let Err(err) = Command::new(command).spawn() {
warn!("error spawning alacritty: {err}");
}
}
+ Action::Screenshot => {
+ return BackendAction::Screenshot;
+ }
Action::CloseWindow => {
if let Some(window) = self.monitor_set.focus() {
window.toplevel().send_close();
@@ -602,6 +613,8 @@ impl Niri {
}
_ => {}
}
+
+ BackendAction::None
}
pub fn process_libinput_event(&mut self, event: &mut InputEvent<LibinputInputBackend>) {