diff --git a/cosmic-comp-config/src/lib.rs b/cosmic-comp-config/src/lib.rs index 204b3890..1f42346d 100644 --- a/cosmic-comp-config/src/lib.rs +++ b/cosmic-comp-config/src/lib.rs @@ -109,7 +109,7 @@ fn default_repeat_delay() -> u32 { 600 } -#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize)] pub struct StackBehavior { pub close_tab_on_middle_click: bool, } diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index e36ea38e..f6a4d899 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -881,7 +881,7 @@ impl CosmicMapped { pub fn update_stack_behavior(&mut self, behavior: &StackBehavior) { if let CosmicMappedInternal::Stack(stack) = &mut self.element { let mut inner = stack.0 .0.lock().unwrap(); - inner.program_mut().update_behavior(behavior.clone()); + inner.update_stack_behavior(behavior); } } } diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index ee4df1bf..0a750715 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -731,6 +731,7 @@ pub enum Message { Menu, TabMenu(usize), PotentialTabDragStart(usize), + UpdateStackBehavior(StackBehavior), Activate(usize), Close(usize), ScrollForward, diff --git a/src/utils/iced.rs b/src/utils/iced.rs index a9de38b3..9858edce 100644 --- a/src/utils/iced.rs +++ b/src/utils/iced.rs @@ -19,12 +19,14 @@ use cosmic::{ }, iced_core::{clipboard::Null as NullClipboard, id::Id, renderer::Style, Color, Length, Pixels}, iced_runtime::{ + self, program::{Program as IcedProgram, State}, task::into_stream, Action, Debug, }, Theme, }; +use cosmic_comp_config::StackBehavior; use iced_tiny_skia::{ graphics::{damage, Viewport}, Layer, @@ -68,6 +70,8 @@ use smithay::{ }, }; +use crate::shell::element::stack::CosmicStackInternal; + static ID: Lazy = Lazy::new(|| Id::new("Program")); pub struct IcedElement(pub(crate) Arc>>); @@ -406,9 +410,15 @@ impl IcedElementInternal

{ } Vec::new() } +} - pub fn program_mut(&mut self) -> &mut P { - &mut self.state.program_mut().0 +impl IcedElementInternal { + pub fn update_stack_behavior(&mut self, behavior: &StackBehavior) { + self.state.queue_message( + ::Message::UpdateStackBehavior( + behavior.clone(), + ), + ); } }