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