diff --git a/src/niri.rs b/src/niri.rs
index f4268aeb..ce7a1c2f 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -1240,7 +1240,12 @@ impl State {
get_monotonic_time().as_millis() as u32,
);
- self.niri.screenshot_ui.open(screenshots, default_output);
+ self.backend.with_primary_renderer(|renderer| {
+ self.niri
+ .screenshot_ui
+ .open(renderer, screenshots, default_output)
+ });
+
self.niri
.cursor_manager
.set_cursor_image(CursorImageStatus::Named(CursorIcon::Crosshair));
diff --git a/src/ui/screenshot_ui.rs b/src/ui/screenshot_ui.rs
index 4ed7d122..d55073f8 100644
--- a/src/ui/screenshot_ui.rs
+++ b/src/ui/screenshot_ui.rs
@@ -6,12 +6,14 @@ use std::mem;
use anyhow::Context;
use arrayvec::ArrayVec;
use niri_config::Action;
+use pango::{Alignment, FontDescription};
+use pangocairo::cairo::{self, ImageSurface};
use smithay::backend::allocator::Fourcc;
use smithay::backend::input::{ButtonState, MouseButton};
use smithay::backend::renderer::element::utils::{Relocate, RelocateRenderElement};
use smithay::backend::renderer::element::Kind;
use smithay::backend::renderer::gles::{GlesRenderer, GlesTexture};
-use smithay::backend::renderer::ExportMem;
+use smithay::backend::renderer::{ExportMem, Texture as _};
use smithay::input::keyboard::{Keysym, ModifiersState};
use smithay::output::{Output, WeakOutput};
use smithay::utils::{Physical, Point, Rectangle, Scale, Size, Transform};
@@ -23,7 +25,17 @@ use crate::render_helpers::texture::{TextureBuffer, TextureRenderElement};
use crate::render_helpers::{render_to_texture, RenderTarget};
use crate::utils::to_physical_precise_round;
-const BORDER: i32 = 2;
+const SELECTION_BORDER: i32 = 2;
+
+const PADDING: i32 = 8;
+const FONT: &str = "sans 14px";
+const BORDER: i32 = 4;
+const TEXT_HIDE_P: &str =
+ "Press Space to save the screenshot.\n\
+ Press P to hide the pointer.";
+const TEXT_SHOW_P: &str =
+ "Press Space to save the screenshot.\n\
+ Press P to show the pointer.";
// Ideally the screenshot UI should support cross-output selections. However, that poses some
// technical challenges when the outputs have different scales and such. So, this implementation
@@ -50,6 +62,7 @@ pub struct OutputData {
screenshot: [OutputScreenshot; 3],
buffers: [SolidColorBuffer; 8],
locations: [Point; 8],
+ panel: Option<(TextureBuffer, TextureBuffer)>,
}
pub struct OutputScreenshot {
@@ -74,6 +87,7 @@ impl ScreenshotUi {
pub fn open(
&mut self,
+ renderer: &mut GlesRenderer,
// Output, screencast, screen capture.
screenshots: HashMap