From 04c5b9ad7489bfa6cbc7c109eb449fb81e0b4d5a Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 25 Apr 2024 08:43:37 +0400 Subject: Only give keyboard focus to exclusive layer-shell surfaces Workaround until we properly support on-demand. See: https://github.com/YaLTeR/niri/issues/308 --- src/handlers/xdg_shell.rs | 17 +++++++++-------- src/niri.rs | 7 ++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index 0b0a5a33..6f627850 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -18,7 +18,7 @@ use smithay::wayland::compositor::{ }; use smithay::wayland::input_method::InputMethodSeat; use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState}; -use smithay::wayland::shell::wlr_layer::Layer; +use smithay::wayland::shell::wlr_layer::{self, Layer}; use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler; use smithay::wayland::shell::xdg::{ PopupSurface, PositionerState, ToplevelSurface, XdgPopupSurfaceData, XdgShellHandler, @@ -121,19 +121,20 @@ impl XdgShellHandler for State { return; } } else { - if layers - .layers_on(Layer::Overlay) - .any(|l| l.can_receive_keyboard_focus()) - { + if layers.layers_on(Layer::Overlay).any(|l| { + l.cached_state().keyboard_interactivity + == wlr_layer::KeyboardInteractivity::Exclusive + }) { let _ = PopupManager::dismiss_popup(&root, &popup); return; } let mon = self.niri.layout.monitor_for_output(output).unwrap(); if !mon.render_above_top_layer() - && layers - .layers_on(Layer::Top) - .any(|l| l.can_receive_keyboard_focus()) + && layers.layers_on(Layer::Top).any(|l| { + l.cached_state().keyboard_interactivity + == wlr_layer::KeyboardInteractivity::Exclusive + }) { let _ = PopupManager::dismiss_popup(&root, &popup); return; diff --git a/src/niri.rs b/src/niri.rs index 10fc31a7..4baff6f0 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -78,7 +78,7 @@ use smithay::wayland::selection::primary_selection::PrimarySelectionState; use smithay::wayland::selection::wlr_data_control::DataControlState; use smithay::wayland::session_lock::{LockSurface, SessionLockManagerState, SessionLocker}; use smithay::wayland::shell::kde::decoration::KdeDecorationState; -use smithay::wayland::shell::wlr_layer::{Layer, WlrLayerShellState}; +use smithay::wayland::shell::wlr_layer::{self, Layer, WlrLayerShellState}; use smithay::wayland::shell::xdg::decoration::XdgDecorationState; use smithay::wayland::shell::xdg::XdgShellState; use smithay::wayland::shm::ShmState; @@ -702,8 +702,9 @@ impl State { }) }; let layer_focus = |surface: &LayerSurface| { - surface - .can_receive_keyboard_focus() + let can_receive_keyboard_focus = surface.cached_state().keyboard_interactivity + == wlr_layer::KeyboardInteractivity::Exclusive; + can_receive_keyboard_focus .then(|| surface.wl_surface().clone()) .map(|surface| KeyboardFocus::LayerShell { surface }) }; -- cgit