Changes behavior of the panel/dock size slider

- from: new size is committed as soon as the slider position is changed (triggers panel/dock restart),
- to: new size is committed only when slider is released.
This commit is contained in:
Lysander Treumann 2026-04-21 15:01:27 +02:00 • committed by Jacob Kauffmann
parent c06b184ecf
commit 95a82c0d69

View file

@ -24,6 +24,7 @@ pub struct PageInner {
pub(crate) panel_config: Option<CosmicPanelConfig>, pub(crate) panel_config: Option<CosmicPanelConfig>,
pub opacity: f32, pub opacity: f32,
pub opacity_changing: bool, pub opacity_changing: bool,
pub size: PanelSize,
pub outputs: Vec<String>, pub outputs: Vec<String>,
pub anchors: Vec<String>, pub anchors: Vec<String>,
pub backgrounds: Vec<String>, pub backgrounds: Vec<String>,
@ -41,6 +42,7 @@ impl Default for PageInner {
panel_config: Option::default(), panel_config: Option::default(),
opacity: 0.0, opacity: 0.0,
opacity_changing: false, opacity_changing: false,
size: PanelSize::M,
outputs: vec![fl!("all-displays")], outputs: vec![fl!("all-displays")],
anchors: vec![ anchors: vec![
Anchor(PanelAnchor::Left).to_string(), Anchor(PanelAnchor::Left).to_string(),
@ -207,7 +209,7 @@ pub(crate) fn style<
text::body(fl!("small")).into(), text::body(fl!("small")).into(),
slider( slider(
0..=4, 0..=4,
match panel_config.size { match inner.size {
PanelSize::XS => 0, PanelSize::XS => 0,
PanelSize::S => 1, PanelSize::S => 1,
PanelSize::M => 2, PanelSize::M => 2,
@ -229,6 +231,7 @@ pub(crate) fn style<
} }
}, },
) )
.on_release(Message::PanelSizeCommit)
.width(Length::Fill) .width(Length::Fill)
.apply(cosmic::widget::container) .apply(cosmic::widget::container)
.max_width(250) .max_width(250)
@ -420,6 +423,7 @@ pub enum Message {
Output(usize), Output(usize),
AnchorGap(bool), AnchorGap(bool),
PanelSize(PanelSize), PanelSize(PanelSize),
PanelSizeCommit,
Appearance(usize), Appearance(usize),
ExtendToEdge(bool), ExtendToEdge(bool),
OpacityRequest(f32), OpacityRequest(f32),
@ -500,6 +504,7 @@ impl PageInner {
if let Err(err) = default.write_entry(config) { if let Err(err) = default.write_entry(config) {
tracing::error!(?err, "Error resetting panel config."); tracing::error!(?err, "Error resetting panel config.");
} }
self.size.clone_from(&default.size);
self.system_default = Some(default.clone()); self.system_default = Some(default.clone());
self.panel_config.clone_from(&self.system_default); self.panel_config.clone_from(&self.system_default);
} else { } else {
@ -598,7 +603,10 @@ impl PageInner {
_ = panel_config.set_border_radius(helper, new_radius).unwrap(); _ = panel_config.set_border_radius(helper, new_radius).unwrap();
} }
Message::PanelSize(size) => { Message::PanelSize(size) => {
_ = panel_config.set_size(helper, size); self.size = size;
}
Message::PanelSizeCommit => {
_ = panel_config.set_size(helper, self.size.clone());
// Reset any size overrides the user might have set // Reset any size overrides the user might have set
_ = panel_config.set_size_center(helper, None); _ = panel_config.set_size_center(helper, None);
_ = panel_config.set_size_wings(helper, None); _ = panel_config.set_size_wings(helper, None);
@ -661,6 +669,7 @@ impl PageInner {
} }
} }
Message::PanelConfig(c) => { Message::PanelConfig(c) => {
self.size = c.size.clone();
self.panel_config = Some(*c); self.panel_config = Some(*c);
return Task::none(); return Task::none();
} }