aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-07-07 09:54:19 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-07-07 09:54:19 +0400
commit6ec9c72539684ed409427649a11837ab56a0250c (patch)
tree918da1e4edf9d17b0171e0e2375b68fdd35a657c /src
parent1a1086206c584f4be9c3fcf0f4dd692c04c30587 (diff)
downloadniri-6ec9c72539684ed409427649a11837ab56a0250c.tar.gz
niri-6ec9c72539684ed409427649a11837ab56a0250c.tar.bz2
niri-6ec9c72539684ed409427649a11837ab56a0250c.zip
Clear pointer grab upon opening the screenshot UI
Gets rid of DND surfaces.
Diffstat (limited to 'src')
-rw-r--r--src/input/mod.rs4
-rw-r--r--src/niri.rs59
2 files changed, 37 insertions, 26 deletions
diff --git a/src/input/mod.rs b/src/input/mod.rs
index 5251f94f..d1ce4114 100644
--- a/src/input/mod.rs
+++ b/src/input/mod.rs
@@ -513,9 +513,7 @@ impl State {
self.niri.queue_redraw_all();
}
Action::Screenshot => {
- self.backend.with_primary_renderer(|renderer| {
- self.niri.open_screenshot_ui(renderer);
- });
+ self.open_screenshot_ui();
}
Action::ScreenshotWindow => {
let active = self.niri.layout.active_window();
diff --git a/src/niri.rs b/src/niri.rs
index 7940fc59..f4268aeb 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -1211,6 +1211,42 @@ impl State {
self.niri.output_management_state.notify_changes(new_config);
}
+ pub fn open_screenshot_ui(&mut self) {
+ if self.niri.is_locked() || self.niri.screenshot_ui.is_open() {
+ return;
+ }
+
+ let default_output = self
+ .niri
+ .output_under_cursor()
+ .or_else(|| self.niri.layout.active_output().cloned());
+ let Some(default_output) = default_output else {
+ return;
+ };
+
+ self.niri.layout.update_render_elements_all();
+
+ let Some(screenshots) = self
+ .backend
+ .with_primary_renderer(|renderer| self.niri.capture_screenshots(renderer).collect())
+ else {
+ return;
+ };
+
+ // Now that we captured the screenshots, clear grabs like drag-and-drop, etc.
+ self.niri.seat.get_pointer().unwrap().unset_grab(
+ self,
+ SERIAL_COUNTER.next_serial(),
+ get_monotonic_time().as_millis() as u32,
+ );
+
+ self.niri.screenshot_ui.open(screenshots, default_output);
+ self.niri
+ .cursor_manager
+ .set_cursor_image(CursorImageStatus::Named(CursorIcon::Crosshair));
+ self.niri.queue_redraw_all();
+ }
+
#[cfg(feature = "xdp-gnome-screencast")]
pub fn on_pw_msg(&mut self, msg: PwToNiri) {
match msg {
@@ -3829,29 +3865,6 @@ impl Niri {
})
}
- pub fn open_screenshot_ui(&mut self, renderer: &mut GlesRenderer) {
- if self.is_locked() || self.screenshot_ui.is_open() {
- return;
- }
-
- let default_output = self
- .output_under_cursor()
- .or_else(|| self.layout.active_output().cloned())
- .or_else(|| self.global_space.outputs().next().cloned());
- let Some(default_output) = default_output else {
- return;
- };
-
- self.layout.update_render_elements_all();
-
- let screenshots = self.capture_screenshots(renderer).collect();
-
- self.screenshot_ui.open(screenshots, default_output);
- self.cursor_manager
- .set_cursor_image(CursorImageStatus::Named(CursorIcon::Crosshair));
- self.queue_redraw_all();
- }
-
pub fn screenshot(
&mut self,
renderer: &mut GlesRenderer,