forge
Explore
Log in

Don't you dare go Hollow

Prefer exclusive layer focus to on-demand on the same layer

Browse files at this commit

3514cd2e368fe1883e1ed284e701ea9c18af438dIvan MolodetskikhParent: 9608384
src/niri.rsmodified+27 -20
@@ -794,43 +794,50 @@ impl State {
794 surface: Some(surface),794 surface: Some(surface),
795 })795 })
796 };796 };
797- let layer_focus = |surface: &LayerSurface| {797+
798- let can_receive_exclusive_focus = surface.cached_state().keyboard_interactivity798+ let excl_focus_on_layer = |layer| {
799- == wlr_layer::KeyboardInteractivity::Exclusive;799+ layers.layers_on(layer).find_map(|surface| {
800- let is_on_demand_surface =800+ let can_receive_exclusive_focus = surface.cached_state().keyboard_interactivity
801- Some(surface) == self.niri.layer_shell_on_demand_focus.as_ref();801+ == wlr_layer::KeyboardInteractivity::Exclusive;
802-802+ can_receive_exclusive_focus
803- (can_receive_exclusive_focus || is_on_demand_surface)803+ .then(|| surface.wl_surface().clone())
804- .then(|| surface.wl_surface().clone())804+ .map(|surface| KeyboardFocus::LayerShell { surface })
805- .map(|surface| KeyboardFocus::LayerShell { surface })805+ })
806 };806 };
807- let on_d_focus = |surface: &LayerSurface| {807+
808- let is_on_demand_surface =808+ let on_d_focus_on_layer = |layer| {
809- Some(surface) == self.niri.layer_shell_on_demand_focus.as_ref();809+ layers.layers_on(layer).find_map(|surface| {
810- is_on_demand_surface810+ let is_on_demand_surface =
811- .then(|| surface.wl_surface().clone())811+ Some(surface) == self.niri.layer_shell_on_demand_focus.as_ref();
812- .map(|surface| KeyboardFocus::LayerShell { surface })812+ is_on_demand_surface
813+ .then(|| surface.wl_surface().clone())
814+ .map(|surface| KeyboardFocus::LayerShell { surface })
815+ })
813 };816 };
814 817
818+ // Prefer exclusive focus on a layer, then check on-demand focus.
819+ let focus_on_layer =
820+ |layer| excl_focus_on_layer(layer).or_else(|| on_d_focus_on_layer(layer));
821+
815 let mut surface = grab_on_layer(Layer::Overlay);822 let mut surface = grab_on_layer(Layer::Overlay);
816 // FIXME: we shouldn't prioritize the top layer grabs over regular overlay input or a823 // FIXME: we shouldn't prioritize the top layer grabs over regular overlay input or a
817 // fullscreen layout window. This will need tracking in grab() to avoid handing it out824 // fullscreen layout window. This will need tracking in grab() to avoid handing it out
818 // in the first place. Or a better way to structure this code.825 // in the first place. Or a better way to structure this code.
819 surface = surface.or_else(|| grab_on_layer(Layer::Top));826 surface = surface.or_else(|| grab_on_layer(Layer::Top));
820 827
821- surface = surface.or_else(|| layers.layers_on(Layer::Overlay).find_map(layer_focus));828+ surface = surface.or_else(|| focus_on_layer(Layer::Overlay));
822 829
823 if mon.render_above_top_layer() {830 if mon.render_above_top_layer() {
824 surface = surface.or_else(layout_focus);831 surface = surface.or_else(layout_focus);
825- surface = surface.or_else(|| layers.layers_on(Layer::Top).find_map(layer_focus));832+ surface = surface.or_else(|| focus_on_layer(Layer::Top));
826 } else {833 } else {
827- surface = surface.or_else(|| layers.layers_on(Layer::Top).find_map(layer_focus));834+ surface = surface.or_else(|| focus_on_layer(Layer::Top));
828 surface = surface.or_else(layout_focus);835 surface = surface.or_else(layout_focus);
829 }836 }
830 837
831 // Bottom and background layers can receive on-demand focus only.838 // Bottom and background layers can receive on-demand focus only.
832- surface = surface.or_else(|| layers.layers_on(Layer::Bottom).find_map(on_d_focus));839+ surface = surface.or_else(|| on_d_focus_on_layer(Layer::Bottom));
833- surface = surface.or_else(|| layers.layers_on(Layer::Background).find_map(on_d_focus));840+ surface = surface.or_else(|| on_d_focus_on_layer(Layer::Background));
834 841
835 surface.unwrap_or(KeyboardFocus::Layout { surface: None })842 surface.unwrap_or(KeyboardFocus::Layout { surface: None })
836 } else {843 } else {