From 78644a32e3741f8f80e9b8ce65c3550c85f9c1f8 Mon Sep 17 00:00:00 2001 From: Ashley Wulber <48420062+wash2@users.noreply.github.com> Date: Wed, 22 Apr 2026 16:33:37 -0400 Subject: [PATCH] =?UTF-8?q?Revert=20"Changes=20the=20PageInner.size=20fiel?= =?UTF-8?q?d=20to=20have=20no=20explicit=20default.=E2=80=A6=20(#1977)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … It is only initialized (not None) when PageInner.panel_config is initialized. This implementation fails faster and more verbose, when program is in an unintended state." This reverts commit ba5fb65b44302d2aae5d969917d9f3d7b04c8d1e. - [x] I have disclosed use of any AI generated code in my commit messages. - If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR. - In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment. - [x] I understand these changes in full and will be able to respond to review comments. - [x] My change is accurately described in the commit message. - [x] My contribution is tested and working as described. - [x] I have read the [Developer Certificate of Origin](https://developercertificate.org/) and certify my contribution under its conditions. Co-authored-by: Levi Portenier --- .../src/pages/desktop/panel/inner.rs | 22 ++++++------------- .../src/pages/desktop/panel/mod.rs | 2 -- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/cosmic-settings/src/pages/desktop/panel/inner.rs b/cosmic-settings/src/pages/desktop/panel/inner.rs index bcd7bb3..9974e54 100644 --- a/cosmic-settings/src/pages/desktop/panel/inner.rs +++ b/cosmic-settings/src/pages/desktop/panel/inner.rs @@ -22,9 +22,9 @@ use crate::pages::desktop::appearance::Roundness; pub struct PageInner { pub(crate) config_helper: Option, pub(crate) panel_config: Option, - pub size: Option, pub opacity: f32, pub opacity_changing: bool, + pub size: PanelSize, pub outputs: Vec, pub anchors: Vec, pub backgrounds: Vec, @@ -40,9 +40,9 @@ impl Default for PageInner { Self { config_helper: Option::default(), panel_config: Option::default(), - size: Option::default(), opacity: 0.0, opacity_changing: false, + size: PanelSize::M, outputs: vec![fl!("all-displays")], anchors: vec![ Anchor(PanelAnchor::Left).to_string(), @@ -209,9 +209,7 @@ pub(crate) fn style< text::body(fl!("small")).into(), slider( 0..=4, - match inner.size.as_ref().expect( - "PageInner.size is None even though PageInner.panel_config is Some", - ) { + match inner.size { PanelSize::XS => 0, PanelSize::S => 1, PanelSize::M => 2, @@ -506,7 +504,7 @@ impl PageInner { if let Err(err) = default.write_entry(config) { tracing::error!(?err, "Error resetting panel config."); } - self.size = Some(default.size.clone()); + self.size.clone_from(&default.size); self.system_default = Some(default.clone()); self.panel_config.clone_from(&self.system_default); } else { @@ -605,16 +603,10 @@ impl PageInner { _ = panel_config.set_border_radius(helper, new_radius).unwrap(); } Message::PanelSize(size) => { - self.size = Some(size); + self.size = size; } Message::PanelSizeCommit => { - _ = panel_config.set_size( - helper, - self.size - .as_ref() - .expect("PageInner.size is None even though it should be Some, since PageInner.panel_config is Some") - .clone() - ); + _ = panel_config.set_size(helper, self.size.clone()); // Reset any size overrides the user might have set _ = panel_config.set_size_center(helper, None); _ = panel_config.set_size_wings(helper, None); @@ -677,7 +669,7 @@ impl PageInner { } } Message::PanelConfig(c) => { - self.size = Some(c.size.clone()); + self.size = c.size.clone(); self.panel_config = Some(*c); return Task::none(); } diff --git a/cosmic-settings/src/pages/desktop/panel/mod.rs b/cosmic-settings/src/pages/desktop/panel/mod.rs index 7748618..4f98e64 100644 --- a/cosmic-settings/src/pages/desktop/panel/mod.rs +++ b/cosmic-settings/src/pages/desktop/panel/mod.rs @@ -79,7 +79,6 @@ impl Default for Page { // If the config is not present, it will be created with the default values and the name will not match (panel_config.name == "Panel").then_some(panel_config) }); - let size = panel_config.as_ref().map(|c| c.size.clone()); let system_default = cosmic::cosmic_config::Config::system( &format!("{}.Panel", cosmic_panel_config::NAME), CosmicPanelConfig::VERSION, @@ -99,7 +98,6 @@ impl Default for Page { inner: PageInner { config_helper, panel_config, - size, container_config, outputs_map: HashMap::new(), system_default,