From 1452281fa7bf40ff976542ff682073f55aa2d2fc Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Wed, 14 Jun 2023 17:29:08 +0200 Subject: [PATCH] tiling: Focus whole stack on Focus::In --- src/shell/element/mod.rs | 7 +++++++ src/shell/element/stack.rs | 5 +++++ src/shell/layout/tiling/mod.rs | 7 ++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index 64e33588..b230d67f 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -465,6 +465,13 @@ impl CosmicMapped { } } + pub fn stack_ref(&self) -> Option<&CosmicStack> { + match &self.element { + CosmicMappedInternal::Stack(stack) => Some(stack), + _ => None, + } + } + pub fn stack_ref_mut(&mut self) -> Option<&mut CosmicStack> { match &mut self.element { CosmicMappedInternal::Stack(stack) => Some(stack), diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index 87b8d5b8..fca06ab0 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -436,6 +436,11 @@ impl CosmicStack { }) } + pub(in super::super) fn focus_stack(&self) { + self.0 + .with_program(|p| p.group_focused.store(true, Ordering::SeqCst)); + } + pub(super) fn loop_handle(&self) -> LoopHandle<'static, crate::state::Data> { self.0.loop_handle() } diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index 608c0e02..20dd2c8a 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -984,7 +984,12 @@ impl TilingLayout { if let Some(id) = id { return match tree.get(&id).unwrap().data() { - Data::Mapped { mapped, .. } => FocusResult::Some(mapped.clone().into()), + Data::Mapped { mapped, .. } => { + if mapped.is_stack() { + mapped.stack_ref().unwrap().focus_stack(); + } + FocusResult::Some(mapped.clone().into()) + } Data::Group { alive, .. } => FocusResult::Some( WindowGroup { node: id,