diff --git a/src/app/core.rs b/src/app/core.rs index 940e1636..38ca72ce 100644 --- a/src/app/core.rs +++ b/src/app/core.rs @@ -46,6 +46,9 @@ pub struct Core { /// Whether the window is too small for the nav bar + main content. is_condensed: bool, + /// Enables built in keyboard navigation + pub(super) keyboard_nav: bool, + /// Current status of the nav bar panel. nav_bar: NavBar, @@ -78,6 +81,7 @@ impl Default for Core { Self { debug: false, is_condensed: false, + keyboard_nav: true, nav_bar: NavBar { active: true, toggled: true, @@ -134,6 +138,17 @@ impl Core { self.scale_factor } + /// Enable or disable keyboard navigation + pub fn set_keyboard_nav(&mut self, enabled: bool) { + self.keyboard_nav = enabled; + } + + #[must_use] + /// Enable or disable keyboard navigation + pub fn keyboard_nav(&self) -> bool { + self.keyboard_nav + } + /// Changes the scaling factor used by the application. pub(crate) fn set_scale_factor(&mut self, factor: f32) { self.scale_factor = factor; diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index 7c25c68b..1d6258ec 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -177,11 +177,8 @@ where None }); - Subscription::batch(vec![ + let mut subscriptions = vec![ self.app.subscription().map(super::Message::App), - keyboard_nav::subscription() - .map(Message::KeyboardNav) - .map(super::Message::Cosmic), self.app .core() .watch_config::(if self.app.core().system_theme_mode.is_dark { @@ -213,7 +210,17 @@ where .single_instance .then(|| super::single_instance_subscription::()) .unwrap_or_else(Subscription::none), - ]) + ]; + + if self.app.core().keyboard_nav { + subscriptions.push( + keyboard_nav::subscription() + .map(Message::KeyboardNav) + .map(super::Message::Cosmic), + ); + } + + Subscription::batch(subscriptions) } #[cfg(not(any(feature = "multi-window", feature = "wayland")))]