aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-08-22 07:59:28 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-08-22 08:54:28 +0300
commit9d3beb49315ae4cde3d8edfb979fccda52af3fae (patch)
treee593592117d32e15ce9f50cfc64bb73c961b9c25 /src/ui
parent7aba44a0199f5cb9f9bd1cc5bc66b6b0e752aa1e (diff)
downloadniri-9d3beb49315ae4cde3d8edfb979fccda52af3fae.tar.gz
niri-9d3beb49315ae4cde3d8edfb979fccda52af3fae.tar.bz2
niri-9d3beb49315ae4cde3d8edfb979fccda52af3fae.zip
exit_confirm_dialog: Add backdrop
Makes it more obvious that the focus is taken by the dialog. Makes it easier to tell if you're about to close nested vs. host compositor.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/exit_confirm_dialog.rs29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/ui/exit_confirm_dialog.rs b/src/ui/exit_confirm_dialog.rs
index d9e93ae8..9162118b 100644
--- a/src/ui/exit_confirm_dialog.rs
+++ b/src/ui/exit_confirm_dialog.rs
@@ -1,5 +1,6 @@
use std::cell::RefCell;
use std::collections::HashMap;
+use std::sync::Mutex;
use arrayvec::ArrayVec;
use ordered_float::NotNan;
@@ -8,12 +9,13 @@ use pangocairo::pango::{Alignment, FontDescription};
use smithay::backend::renderer::element::Kind;
use smithay::output::Output;
use smithay::reexports::gbm::Format as Fourcc;
-use smithay::utils::Transform;
+use smithay::utils::{Point, Transform};
use crate::niri_render_elements;
use crate::render_helpers::memory::MemoryBuffer;
use crate::render_helpers::primary_gpu_texture::PrimaryGpuTextureRenderElement;
use crate::render_helpers::renderer::NiriRenderer;
+use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement};
use crate::render_helpers::texture::{TextureBuffer, TextureRenderElement};
use crate::utils::{output_size, to_physical_precise_round};
@@ -22,6 +24,7 @@ const TEXT: &str = "Are you sure you want to exit niri?\n\n\
const PADDING: i32 = 16;
const FONT: &str = "sans 14px";
const BORDER: i32 = 8;
+const BACKDROP_COLOR: [f32; 4] = [0., 0., 0., 0.4];
pub struct ExitConfirmDialog {
is_open: bool,
@@ -31,9 +34,14 @@ pub struct ExitConfirmDialog {
niri_render_elements! {
ExitConfirmDialogRenderElement => {
Texture = PrimaryGpuTextureRenderElement,
+ SolidColor = SolidColorRenderElement,
}
}
+struct OutputData {
+ backdrop: SolidColorBuffer,
+}
+
impl ExitConfirmDialog {
pub fn new() -> Self {
let buffer = match render(1.) {
@@ -82,7 +90,7 @@ impl ExitConfirmDialog {
&self,
renderer: &mut R,
output: &Output,
- ) -> ArrayVec<ExitConfirmDialogRenderElement, 1> {
+ ) -> ArrayVec<ExitConfirmDialogRenderElement, 2> {
let mut rv = ArrayVec::new();
if !self.is_open {
@@ -126,6 +134,23 @@ impl ExitConfirmDialog {
PrimaryGpuTextureRenderElement(elem),
));
+ // Backdrop.
+ let data = output.user_data().get_or_insert(|| {
+ Mutex::new(OutputData {
+ backdrop: SolidColorBuffer::new(output_size, BACKDROP_COLOR),
+ })
+ });
+ let mut data = data.lock().unwrap();
+ data.backdrop.resize(output_size);
+
+ let elem = SolidColorRenderElement::from_buffer(
+ &data.backdrop,
+ Point::new(0., 0.),
+ 1.,
+ Kind::Unspecified,
+ );
+ rv.push(ExitConfirmDialogRenderElement::SolidColor(elem));
+
rv
}
}