aboutsummaryrefslogtreecommitdiff
path: root/src/tty.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/tty.rs
parent1575753b69cabf7f4d84f765a025ce1d7672b522 (diff)
downloadniri-af7b978eb405b6c221f8342658fbf5466432b108.tar.gz
niri-af7b978eb405b6c221f8342658fbf5466432b108.tar.bz2
niri-af7b978eb405b6c221f8342658fbf5466432b108.zip
Implement taking a monitor screenshot
Diffstat (limited to 'src/tty.rs')
-rw-r--r--src/tty.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/tty.rs b/src/tty.rs
index 528fb0bd..79b9e3c4 100644
--- a/src/tty.rs
+++ b/src/tty.rs
@@ -31,7 +31,7 @@ use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
use smithay_drm_extras::edid::EdidInfo;
use crate::backend::Backend;
-use crate::input::CompositorMod;
+use crate::input::{BackendAction, CompositorMod};
use crate::niri::OutputRenderElements;
use crate::{LoopData, Niri};
@@ -173,10 +173,21 @@ impl Tty {
event_loop
.insert_source(input_backend, |mut event, _, data| {
let tty = data.tty.as_mut().unwrap();
- let mut change_vt = |vt| tty.change_vt(vt);
- data.niri.process_libinput_event(&mut event);
- data.niri
- .process_input_event(&mut change_vt, CompositorMod::Super, event);
+ let niri = &mut data.niri;
+
+ niri.process_libinput_event(&mut event);
+ match niri.process_input_event(CompositorMod::Super, event) {
+ BackendAction::None => (),
+ BackendAction::ChangeVt(vt) => tty.change_vt(vt),
+ BackendAction::Screenshot => {
+ let active = niri.monitor_set.active_output().cloned();
+ if let Some(active) = active {
+ if let Err(err) = niri.screenshot(tty.renderer(), &active) {
+ warn!("error taking screenshot: {err:?}");
+ }
+ }
+ }
+ };
})
.unwrap();