Skip to content

Commit

Permalink
Propagate the update behavior event properly through the eventloop
Browse files Browse the repository at this point in the history
  • Loading branch information
William Calliari committed Dec 30, 2024
1 parent e3d94cc commit 59c34cf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cosmic-comp-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion src/shell/element/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/shell/element/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ pub enum Message {
Menu,
TabMenu(usize),
PotentialTabDragStart(usize),
UpdateStackBehavior(StackBehavior),
Activate(usize),
Close(usize),
ScrollForward,
Expand Down
14 changes: 12 additions & 2 deletions src/utils/iced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -68,6 +70,8 @@ use smithay::{
},
};

use crate::shell::element::stack::CosmicStackInternal;

static ID: Lazy<Id> = Lazy::new(|| Id::new("Program"));

pub struct IcedElement<P: Program + Send + 'static>(pub(crate) Arc<Mutex<IcedElementInternal<P>>>);
Expand Down Expand Up @@ -406,9 +410,15 @@ impl<P: Program + Send + 'static> IcedElementInternal<P> {
}
Vec::new()
}
}

pub fn program_mut(&mut self) -> &mut P {
&mut self.state.program_mut().0
impl IcedElementInternal<CosmicStackInternal> {
pub fn update_stack_behavior(&mut self, behavior: &StackBehavior) {
self.state.queue_message(
<CosmicStackInternal as crate::utils::iced::Program>::Message::UpdateStackBehavior(
behavior.clone(),
),
);
}
}

Expand Down

0 comments on commit 59c34cf

Please sign in to comment.