forge
Explore
Log in

Don't you dare go Hollow

Only give keyboard focus to exclusive layer-shell surfaces

Browse files at this commit

04c5b9ad7489bfa6cbc7c109eb449fb81e0b4d5aIvan MolodetskikhParent: fd6c8c7
Workaround until we properly support on-demand.

See: https://github.com/YaLTeR/niri/issues/308
src/handlers/xdg_shell.rsmodified+9 -8
@@ -18,7 +18,7 @@ use smithay::wayland::compositor::{
1818 };
1919 use smithay::wayland::input_method::InputMethodSeat;
2020 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};
2222 use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler;
2323 use smithay::wayland::shell::xdg::{
2424 PopupSurface, PositionerState, ToplevelSurface, XdgPopupSurfaceData, XdgShellHandler,
@@ -121,19 +121,20 @@ impl XdgShellHandler for State {
121121 return;
122122 }
123123 } 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+ }) {
128128 let _ = PopupManager::dismiss_popup(&root, &popup);
129129 return;
130130 }
131131
132132 let mon = self.niri.layout.monitor_for_output(output).unwrap();
133133 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+ })
137138 {
138139 let _ = PopupManager::dismiss_popup(&root, &popup);
139140 return;
src/niri.rsmodified+4 -3
@@ -78,7 +78,7 @@ use smithay::wayland::selection::primary_selection::PrimarySelectionState;
7878 use smithay::wayland::selection::wlr_data_control::DataControlState;
7979 use smithay::wayland::session_lock::{LockSurface, SessionLockManagerState, SessionLocker};
8080 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};
8282 use smithay::wayland::shell::xdg::decoration::XdgDecorationState;
8383 use smithay::wayland::shell::xdg::XdgShellState;
8484 use smithay::wayland::shm::ShmState;
@@ -702,8 +702,9 @@ impl State {
702702 })
703703 };
704704 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
707708 .then(|| surface.wl_surface().clone())
708709 .map(|surface| KeyboardFocus::LayerShell { surface })
709710 };