Only give keyboard focus to exclusive layer-shell surfaces
Browse files at this commit04c5b9ad7489bfa6cbc7c109eb449fb81e0b4d5aParent: fd6c8c72 changed files +13 -11
- src/handlers/xdg_shell.rs +9 -8
- src/niri.rs +4 -3
src/handlers/xdg_shell.rsmodified+9 -8
| @@ -18,7 +18,7 @@ use smithay::wayland::compositor::{ | ||
| 18 | 18 | }; |
| 19 | 19 | use smithay::wayland::input_method::InputMethodSeat; |
| 20 | 20 | use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState}; |
| 21 | -use smithay::wayland::shell::wlr_layer::Layer; | |
| 21 | +use smithay::wayland::shell::wlr_layer::{self, Layer}; | |
| 22 | 22 | use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler; |
| 23 | 23 | use smithay::wayland::shell::xdg::{ |
| 24 | 24 | PopupSurface, PositionerState, ToplevelSurface, XdgPopupSurfaceData, XdgShellHandler, |
| @@ -121,19 +121,20 @@ impl XdgShellHandler for State { | ||
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | } else { |
| 124 | - if layers | |
| 125 | - .layers_on(Layer::Overlay) | |
| 126 | - .any(|l| l.can_receive_keyboard_focus()) | |
| 127 | - { | |
| 124 | + if layers.layers_on(Layer::Overlay).any(|l| { | |
| 125 | + l.cached_state().keyboard_interactivity | |
| 126 | + == wlr_layer::KeyboardInteractivity::Exclusive | |
| 127 | + }) { | |
| 128 | 128 | let _ = PopupManager::dismiss_popup(&root, &popup); |
| 129 | 129 | return; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | let mon = self.niri.layout.monitor_for_output(output).unwrap(); |
| 133 | 133 | if !mon.render_above_top_layer() |
| 134 | - && layers | |
| 135 | - .layers_on(Layer::Top) | |
| 136 | - .any(|l| l.can_receive_keyboard_focus()) | |
| 134 | + && layers.layers_on(Layer::Top).any(|l| { | |
| 135 | + l.cached_state().keyboard_interactivity | |
| 136 | + == wlr_layer::KeyboardInteractivity::Exclusive | |
| 137 | + }) | |
| 137 | 138 | { |
| 138 | 139 | let _ = PopupManager::dismiss_popup(&root, &popup); |
| 139 | 140 | return; |
src/niri.rsmodified+4 -3
| @@ -78,7 +78,7 @@ use smithay::wayland::selection::primary_selection::PrimarySelectionState; | ||
| 78 | 78 | use smithay::wayland::selection::wlr_data_control::DataControlState; |
| 79 | 79 | use smithay::wayland::session_lock::{LockSurface, SessionLockManagerState, SessionLocker}; |
| 80 | 80 | use smithay::wayland::shell::kde::decoration::KdeDecorationState; |
| 81 | -use smithay::wayland::shell::wlr_layer::{Layer, WlrLayerShellState}; | |
| 81 | +use smithay::wayland::shell::wlr_layer::{self, Layer, WlrLayerShellState}; | |
| 82 | 82 | use smithay::wayland::shell::xdg::decoration::XdgDecorationState; |
| 83 | 83 | use smithay::wayland::shell::xdg::XdgShellState; |
| 84 | 84 | use smithay::wayland::shm::ShmState; |
| @@ -702,8 +702,9 @@ impl State { | ||
| 702 | 702 | }) |
| 703 | 703 | }; |
| 704 | 704 | let layer_focus = |surface: &LayerSurface| { |
| 705 | - surface | |
| 706 | - .can_receive_keyboard_focus() | |
| 705 | + let can_receive_keyboard_focus = surface.cached_state().keyboard_interactivity | |
| 706 | + == wlr_layer::KeyboardInteractivity::Exclusive; | |
| 707 | + can_receive_keyboard_focus | |
| 707 | 708 | .then(|| surface.wl_surface().clone()) |
| 708 | 709 | .map(|surface| KeyboardFocus::LayerShell { surface }) |
| 709 | 710 | }; |