Unfocus layout when exit confirm dialog is open
Browse files at this commitd662811bf6d004382061380f537ffdeb0bffe892Parent: 05337ce3 changed files +27 -11
- src/handlers/xdg_shell.rs +5 -1
- src/input/mod.rs +6 -5
- src/niri.rs +16 -5
src/handlers/xdg_shell.rsmodified+5 -1
| @@ -303,7 +303,11 @@ impl XdgShellHandler for State { | |||
| 303 | // We need to hand out the grab in a way consistent with what update_keyboard_focus() | 303 | // We need to hand out the grab in a way consistent with what update_keyboard_focus() |
| 304 | // thinks the current focus is, otherwise it will desync and cause weird issues with | 304 | // thinks the current focus is, otherwise it will desync and cause weird issues with |
| 305 | // keyboard focus being at the wrong place. | 305 | // keyboard focus being at the wrong place. |
| 306 | - if self.niri.is_locked() { | 306 | + if self.niri.exit_confirm_dialog.is_open() { |
| 307 | + trace!("ignoring popup grab because the exit confirm dialog is open"); | ||
| 308 | + let _ = PopupManager::dismiss_popup(&root, &popup); | ||
| 309 | + return; | ||
| 310 | + } else if self.niri.is_locked() { | ||
| 307 | if Some(&root) != self.niri.lock_surface_focus().as_ref() { | 311 | if Some(&root) != self.niri.lock_surface_focus().as_ref() { |
| 308 | trace!("ignoring popup grab because the session is locked"); | 312 | trace!("ignoring popup grab because the session is locked"); |
| 309 | let _ = PopupManager::dismiss_popup(&root, &popup); | 313 | let _ = PopupManager::dismiss_popup(&root, &popup); |
src/input/mod.rsmodified+6 -5
| @@ -375,12 +375,13 @@ impl State { | |||
| 375 | let modified = keysym.modified_sym(); | 375 | let modified = keysym.modified_sym(); |
| 376 | let raw = keysym.raw_latin_sym_or_raw_current_sym(); | 376 | let raw = keysym.raw_latin_sym_or_raw_current_sym(); |
| 377 | 377 | ||
| 378 | - if this.niri.exit_confirm_dialog.is_open() && pressed && raw == Some(Keysym::Return) | 378 | + if this.niri.exit_confirm_dialog.is_open() && pressed { |
| 379 | - { | 379 | + if raw == Some(Keysym::Return) { |
| 380 | - info!("quitting after confirming exit dialog"); | 380 | + info!("quitting after confirming exit dialog"); |
| 381 | - this.niri.stop_signal.stop(); | 381 | + this.niri.stop_signal.stop(); |
| 382 | + } | ||
| 382 | 383 | ||
| 383 | - // Don't send this Enter press to any clients. | 384 | + // Don't send this press to any clients. |
| 384 | this.niri.suppressed_keys.insert(key_code); | 385 | this.niri.suppressed_keys.insert(key_code); |
| 385 | return FilterResult::Intercept(None); | 386 | return FilterResult::Intercept(None); |
| 386 | } | 387 | } |
src/niri.rsmodified+16 -5
| @@ -512,6 +512,7 @@ pub enum KeyboardFocus { | |||
| 512 | LayerShell { surface: WlSurface }, | 512 | LayerShell { surface: WlSurface }, |
| 513 | LockScreen { surface: Option<WlSurface> }, | 513 | LockScreen { surface: Option<WlSurface> }, |
| 514 | ScreenshotUi, | 514 | ScreenshotUi, |
| 515 | + ExitConfirmDialog, | ||
| 515 | Overview, | 516 | Overview, |
| 516 | } | 517 | } |
| 517 | 518 | ||
| @@ -611,6 +612,7 @@ impl KeyboardFocus { | |||
| 611 | KeyboardFocus::LayerShell { surface } => Some(surface), | 612 | KeyboardFocus::LayerShell { surface } => Some(surface), |
| 612 | KeyboardFocus::LockScreen { surface } => surface.as_ref(), | 613 | KeyboardFocus::LockScreen { surface } => surface.as_ref(), |
| 613 | KeyboardFocus::ScreenshotUi => None, | 614 | KeyboardFocus::ScreenshotUi => None, |
| 615 | + KeyboardFocus::ExitConfirmDialog => None, | ||
| 614 | KeyboardFocus::Overview => None, | 616 | KeyboardFocus::Overview => None, |
| 615 | } | 617 | } |
| 616 | } | 618 | } |
| @@ -621,6 +623,7 @@ impl KeyboardFocus { | |||
| 621 | KeyboardFocus::LayerShell { surface } => Some(surface), | 623 | KeyboardFocus::LayerShell { surface } => Some(surface), |
| 622 | KeyboardFocus::LockScreen { surface } => surface, | 624 | KeyboardFocus::LockScreen { surface } => surface, |
| 623 | KeyboardFocus::ScreenshotUi => None, | 625 | KeyboardFocus::ScreenshotUi => None, |
| 626 | + KeyboardFocus::ExitConfirmDialog => None, | ||
| 624 | KeyboardFocus::Overview => None, | 627 | KeyboardFocus::Overview => None, |
| 625 | } | 628 | } |
| 626 | } | 629 | } |
| @@ -944,7 +947,10 @@ impl State { | |||
| 944 | let pointer = &self.niri.seat.get_pointer().unwrap(); | 947 | let pointer = &self.niri.seat.get_pointer().unwrap(); |
| 945 | let location = pointer.current_location(); | 948 | let location = pointer.current_location(); |
| 946 | 949 | ||
| 947 | - if !self.niri.is_locked() && !self.niri.screenshot_ui.is_open() { | 950 | + if !self.niri.exit_confirm_dialog.is_open() |
| 951 | + && !self.niri.is_locked() | ||
| 952 | + && !self.niri.screenshot_ui.is_open() | ||
| 953 | + { | ||
| 948 | // Don't refresh cursor focus during transitions. | 954 | // Don't refresh cursor focus during transitions. |
| 949 | if let Some((output, _)) = self.niri.output_under(location) { | 955 | if let Some((output, _)) = self.niri.output_under(location) { |
| 950 | let monitor = self.niri.layout.monitor_for_output(output).unwrap(); | 956 | let monitor = self.niri.layout.monitor_for_output(output).unwrap(); |
| @@ -1063,7 +1069,9 @@ impl State { | |||
| 1063 | } | 1069 | } |
| 1064 | 1070 | ||
| 1065 | // Compute the current focus. | 1071 | // Compute the current focus. |
| 1066 | - let focus = if self.niri.is_locked() { | 1072 | + let focus = if self.niri.exit_confirm_dialog.is_open() { |
| 1073 | + KeyboardFocus::ExitConfirmDialog | ||
| 1074 | + } else if self.niri.is_locked() { | ||
| 1067 | KeyboardFocus::LockScreen { | 1075 | KeyboardFocus::LockScreen { |
| 1068 | surface: self.niri.lock_surface_focus(), | 1076 | surface: self.niri.lock_surface_focus(), |
| 1069 | } | 1077 | } |
| @@ -3193,7 +3201,7 @@ impl Niri { | |||
| 3193 | extended_bounds: bool, | 3201 | extended_bounds: bool, |
| 3194 | pos: Point<f64, Logical>, | 3202 | pos: Point<f64, Logical>, |
| 3195 | ) -> Option<(Output, &Workspace<Mapped>)> { | 3203 | ) -> Option<(Output, &Workspace<Mapped>)> { |
| 3196 | - if self.is_locked() || self.screenshot_ui.is_open() { | 3204 | + if self.exit_confirm_dialog.is_open() || self.is_locked() || self.screenshot_ui.is_open() { |
| 3197 | return None; | 3205 | return None; |
| 3198 | } | 3206 | } |
| 3199 | 3207 | ||
| @@ -3226,7 +3234,7 @@ impl Niri { | |||
| 3226 | /// The cursor may be inside the window's activation region, but not within the window's input | 3234 | /// The cursor may be inside the window's activation region, but not within the window's input |
| 3227 | /// region. | 3235 | /// region. |
| 3228 | pub fn window_under(&self, pos: Point<f64, Logical>) -> Option<&Mapped> { | 3236 | pub fn window_under(&self, pos: Point<f64, Logical>) -> Option<&Mapped> { |
| 3229 | - if self.is_locked() || self.screenshot_ui.is_open() { | 3237 | + if self.exit_confirm_dialog.is_open() || self.is_locked() || self.screenshot_ui.is_open() { |
| 3230 | return None; | 3238 | return None; |
| 3231 | } | 3239 | } |
| 3232 | 3240 | ||
| @@ -3278,7 +3286,9 @@ impl Niri { | |||
| 3278 | // The ordering here must be consistent with the ordering in render() so that input is | 3286 | // The ordering here must be consistent with the ordering in render() so that input is |
| 3279 | // consistent with the visuals. | 3287 | // consistent with the visuals. |
| 3280 | 3288 | ||
| 3281 | - if self.is_locked() { | 3289 | + if self.exit_confirm_dialog.is_open() { |
| 3290 | + return rv; | ||
| 3291 | + } else if self.is_locked() { | ||
| 3282 | let Some(state) = self.output_state.get(output) else { | 3292 | let Some(state) = self.output_state.get(output) else { |
| 3283 | return rv; | 3293 | return rv; |
| 3284 | }; | 3294 | }; |
| @@ -3909,6 +3919,7 @@ impl Niri { | |||
| 3909 | // layer-shell, the layout will briefly draw as active, despite never having focus. | 3919 | // layer-shell, the layout will briefly draw as active, despite never having focus. |
| 3910 | KeyboardFocus::LockScreen { .. } => true, | 3920 | KeyboardFocus::LockScreen { .. } => true, |
| 3911 | KeyboardFocus::ScreenshotUi => true, | 3921 | KeyboardFocus::ScreenshotUi => true, |
| 3922 | + KeyboardFocus::ExitConfirmDialog => true, | ||
| 3912 | KeyboardFocus::Overview => true, | 3923 | KeyboardFocus::Overview => true, |
| 3913 | }; | 3924 | }; |
| 3914 | 3925 | ||