diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-07-16 14:36:58 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-08-21 12:26:32 +0300 |
| commit | d662811bf6d004382061380f537ffdeb0bffe892 (patch) | |
| tree | ee8a973a4e5599a34725c9dd12da09b528520a26 /src/niri.rs | |
| parent | 05337ce85560efc4d20cc23e9452a1e1f360007d (diff) | |
| download | niri-d662811bf6d004382061380f537ffdeb0bffe892.tar.gz niri-d662811bf6d004382061380f537ffdeb0bffe892.tar.bz2 niri-d662811bf6d004382061380f537ffdeb0bffe892.zip | |
Unfocus layout when exit confirm dialog is open
Screen readers expect closing a modal dialog to reannounce the previous focus.
This makes the exit confirm dialog more modal in this sense: it will unfocus
the layout and then focus it back when closed, giving the desired behavior.
Diffstat (limited to 'src/niri.rs')
| -rw-r--r-- | src/niri.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/niri.rs b/src/niri.rs index 5b270f48..f1a1f3c0 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -512,6 +512,7 @@ pub enum KeyboardFocus { LayerShell { surface: WlSurface }, LockScreen { surface: Option<WlSurface> }, ScreenshotUi, + ExitConfirmDialog, Overview, } @@ -611,6 +612,7 @@ impl KeyboardFocus { KeyboardFocus::LayerShell { surface } => Some(surface), KeyboardFocus::LockScreen { surface } => surface.as_ref(), KeyboardFocus::ScreenshotUi => None, + KeyboardFocus::ExitConfirmDialog => None, KeyboardFocus::Overview => None, } } @@ -621,6 +623,7 @@ impl KeyboardFocus { KeyboardFocus::LayerShell { surface } => Some(surface), KeyboardFocus::LockScreen { surface } => surface, KeyboardFocus::ScreenshotUi => None, + KeyboardFocus::ExitConfirmDialog => None, KeyboardFocus::Overview => None, } } @@ -944,7 +947,10 @@ impl State { let pointer = &self.niri.seat.get_pointer().unwrap(); let location = pointer.current_location(); - if !self.niri.is_locked() && !self.niri.screenshot_ui.is_open() { + if !self.niri.exit_confirm_dialog.is_open() + && !self.niri.is_locked() + && !self.niri.screenshot_ui.is_open() + { // Don't refresh cursor focus during transitions. if let Some((output, _)) = self.niri.output_under(location) { let monitor = self.niri.layout.monitor_for_output(output).unwrap(); @@ -1063,7 +1069,9 @@ impl State { } // Compute the current focus. - let focus = if self.niri.is_locked() { + let focus = if self.niri.exit_confirm_dialog.is_open() { + KeyboardFocus::ExitConfirmDialog + } else if self.niri.is_locked() { KeyboardFocus::LockScreen { surface: self.niri.lock_surface_focus(), } @@ -3193,7 +3201,7 @@ impl Niri { extended_bounds: bool, pos: Point<f64, Logical>, ) -> Option<(Output, &Workspace<Mapped>)> { - if self.is_locked() || self.screenshot_ui.is_open() { + if self.exit_confirm_dialog.is_open() || self.is_locked() || self.screenshot_ui.is_open() { return None; } @@ -3226,7 +3234,7 @@ impl Niri { /// The cursor may be inside the window's activation region, but not within the window's input /// region. pub fn window_under(&self, pos: Point<f64, Logical>) -> Option<&Mapped> { - if self.is_locked() || self.screenshot_ui.is_open() { + if self.exit_confirm_dialog.is_open() || self.is_locked() || self.screenshot_ui.is_open() { return None; } @@ -3278,7 +3286,9 @@ impl Niri { // The ordering here must be consistent with the ordering in render() so that input is // consistent with the visuals. - if self.is_locked() { + if self.exit_confirm_dialog.is_open() { + return rv; + } else if self.is_locked() { let Some(state) = self.output_state.get(output) else { return rv; }; @@ -3909,6 +3919,7 @@ impl Niri { // layer-shell, the layout will briefly draw as active, despite never having focus. KeyboardFocus::LockScreen { .. } => true, KeyboardFocus::ScreenshotUi => true, + KeyboardFocus::ExitConfirmDialog => true, KeyboardFocus::Overview => true, }; |
