shell: Handle focus shortcuts for floating layer

This commit is contained in:
Victoria Brekenfeld 2023-09-20 16:30:37 +02:00
parent 63c073e3e5
commit 3d10ca6105
4 changed files with 122 additions and 20 deletions

View file

@ -65,7 +65,7 @@ use super::{
},
focus::{
target::{KeyboardFocusTarget, PointerFocusTarget, WindowGroup},
FocusStack, FocusStackMut,
FocusDirection, FocusStack, FocusStackMut,
},
grabs::{ResizeEdge, ResizeGrab},
layout::tiling::{Data, NodeDesc},
@ -133,6 +133,25 @@ pub enum ManagedState {
Floating,
}
#[derive(Debug, Clone, PartialEq)]
pub enum FocusResult {
None,
Handled,
Some(KeyboardFocusTarget),
}
impl FocusResult {
pub fn or_else<F>(self, f: F) -> FocusResult
where
F: FnOnce() -> FocusResult,
{
match self {
FocusResult::None => f(),
x => x,
}
}
}
impl Workspace {
pub fn new(handle: WorkspaceHandle, tiling_enabled: bool, gaps: (u8, u8)) -> Workspace {
Workspace {
@ -795,6 +814,25 @@ impl Workspace {
}
}
pub fn next_focus<'a>(
&mut self,
direction: FocusDirection,
seat: &Seat<State>,
swap_desc: Option<NodeDesc>,
) -> FocusResult {
if self.fullscreen.contains_key(&seat.active_output()) {
return FocusResult::None;
}
let focus_stack = self.focus_stack.get(seat);
self.floating_layer
.next_focus(direction, seat, focus_stack.iter())
.or_else(|| {
self.tiling_layer
.next_focus(direction, seat, focus_stack.iter(), swap_desc)
})
}
pub fn render_output<'a, R>(
&self,
renderer: &mut R,