aboutsummaryrefslogtreecommitdiff
path: root/src/niri.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-01-19 08:33:54 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-01-19 08:33:54 +0400
commit4b9cb2f0d3d9b1b2e730844be7d9fe3fb44a5ee1 (patch)
treeb8c40c33b6cb181ff4cbb3883924a4d9e7e16f6f /src/niri.rs
parent3461c66d2ce8fb53e2a709b27868229786604256 (diff)
downloadniri-4b9cb2f0d3d9b1b2e730844be7d9fe3fb44a5ee1.tar.gz
niri-4b9cb2f0d3d9b1b2e730844be7d9fe3fb44a5ee1.tar.bz2
niri-4b9cb2f0d3d9b1b2e730844be7d9fe3fb44a5ee1.zip
Add exit confirmation dialog
Diffstat (limited to 'src/niri.rs')
-rw-r--r--src/niri.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/niri.rs b/src/niri.rs
index 93b50be3..94a2056f 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -98,6 +98,7 @@ use crate::cursor::{CursorManager, CursorTextureCache, RenderCursor, XCursor};
use crate::dbus::gnome_shell_screenshot::{NiriToScreenshot, ScreenshotToNiri};
#[cfg(feature = "xdp-gnome-screencast")]
use crate::dbus::mutter_screen_cast::{self, ScreenCastToNiri};
+use crate::exit_confirm_dialog::ExitConfirmDialog;
use crate::frame_clock::FrameClock;
use crate::handlers::configure_lock_surface;
use crate::hotkey_overlay::HotkeyOverlay;
@@ -191,6 +192,7 @@ pub struct Niri {
pub screenshot_ui: ScreenshotUi,
pub config_error_notification: ConfigErrorNotification,
pub hotkey_overlay: HotkeyOverlay,
+ pub exit_confirm_dialog: Option<ExitConfirmDialog>,
#[cfg(feature = "dbus")]
pub dbus: Option<crate::dbus::DBusServers>,
@@ -867,6 +869,13 @@ impl Niri {
let screenshot_ui = ScreenshotUi::new();
let config_error_notification = ConfigErrorNotification::new();
let hotkey_overlay = HotkeyOverlay::new(config.clone(), backend.mod_key());
+ let exit_confirm_dialog = match ExitConfirmDialog::new() {
+ Ok(x) => Some(x),
+ Err(err) => {
+ warn!("error creating the exit confirm dialog: {err:?}");
+ None
+ }
+ };
let socket_source = ListeningSocketSource::new_auto().unwrap();
let socket_name = socket_source.socket_name().to_os_string();
@@ -973,6 +982,7 @@ impl Niri {
screenshot_ui,
config_error_notification,
hotkey_overlay,
+ exit_confirm_dialog,
#[cfg(feature = "dbus")]
dbus: None,
@@ -1807,7 +1817,14 @@ impl Niri {
elements = self.pointer_element(renderer, output);
}
- // The config error notification too.
+ // Next, the exit confirm dialog.
+ if let Some(dialog) = &self.exit_confirm_dialog {
+ if let Some(element) = dialog.render(renderer, output) {
+ elements.push(element.into());
+ }
+ }
+
+ // Next, the config error notification too.
if let Some(element) = self.config_error_notification.render(renderer, output) {
elements.push(element.into());
}