From 8ab7b158078eaafeee381487ad8267c459df859b Mon Sep 17 00:00:00 2001 From: leyoda Date: Thu, 23 Apr 2026 18:43:52 +0200 Subject: [PATCH] yoda-v2: color_picker Theme ref + context_menu/menu ungate winit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two perf + correctness wins packaged as +yoda-v2 (version bump 0.1.0-yoda -> 0.1.0-yoda.2): 1. color_picker::draw() — use the theme: &Theme parameter already passed to draw() instead of THEME.lock().unwrap().clone() which cloned the whole Theme on every redraw (src/widget/color_picker/mod.rs:622). Upstreamable. 2. Dropped feature = "winit" from 21 combined cfg attrs in context_menu.rs, menu/menu_bar.rs, menu/menu_inner.rs. These triple-gates (wayland + winit + surface-message) were silently disabling all context-menu and menubar popup creation in yoda apps (which don't activate the winit feature). Now the code only gates on wayland + surface-message, which is our actual runtime path. Matches the ungate we already did on surface/action.rs in Phase 3d. cargo check --lib passes. All 4 consumer apps rebuilt + installed as +yoda-v2 (backup of previous yoda binaries in .pre-yoda-v2 siblings). --- Cargo.toml | 2 +- src/widget/color_picker/mod.rs | 6 ++++-- src/widget/context_menu.rs | 6 ------ src/widget/menu/menu_bar.rs | 9 --------- src/widget/menu/menu_inner.rs | 6 +----- 5 files changed, 6 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 13adfd7..a5707e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ # that used to ask for `libcosmic` are replaced by deps on our forks that ask # for `libcosmic-yoda`. name = "libcosmic-yoda" -version = "0.1.0-yoda" +version = "0.1.0-yoda.2" edition = "2024" rust-version = "1.90" diff --git a/src/widget/color_picker/mod.rs b/src/widget/color_picker/mod.rs index 318e943..85cfc16 100644 --- a/src/widget/color_picker/mod.rs +++ b/src/widget/color_picker/mod.rs @@ -619,8 +619,10 @@ where let bounds = canvas_layout.bounds(); // Draw the handle on the saturation value canvas - let t = THEME.lock().unwrap().clone(); - let t = t.cosmic(); + // Yoda: use the Theme passed into draw() instead of locking the global + // THEME Mutex and cloning the whole Theme. Fires on every color-picker + // redraw, so saving the Mutex lock + full Theme clone adds up. + let t = theme.cosmic(); let handle_radius = f32::from(t.space_xs()) / 2.0; let (x, y) = ( self.active_color diff --git a/src/widget/context_menu.rs b/src/widget/context_menu.rs index 3f35f04..5f52599 100644 --- a/src/widget/context_menu.rs +++ b/src/widget/context_menu.rs @@ -6,7 +6,6 @@ #[cfg(all( feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] use crate::app::cosmic::{WINDOWING_SYSTEM, WindowingSystem}; @@ -67,7 +66,6 @@ impl ContextMenu<'_, Message> { #[cfg(all( feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] #[allow(clippy::too_many_lines)] @@ -377,7 +375,6 @@ impl Widget #[cfg(all( feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) @@ -421,7 +418,6 @@ impl Widget #[cfg(all( feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) { @@ -443,7 +439,6 @@ impl Widget #[cfg(all( feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) @@ -482,7 +477,6 @@ impl Widget #[cfg(all( feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) diff --git a/src/widget/menu/menu_bar.rs b/src/widget/menu/menu_bar.rs index 981446e..02ac693 100644 --- a/src/widget/menu/menu_bar.rs +++ b/src/widget/menu/menu_bar.rs @@ -13,7 +13,6 @@ use super::{ feature = "multi-window", feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] use crate::app::cosmic::{WINDOWING_SYSTEM, WindowingSystem}; @@ -199,7 +198,6 @@ pub struct MenuBar { #[cfg(all( feature = "multi-window", feature = "wayland", - feature = "winit", target_os = "linux" ))] positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner, @@ -239,7 +237,6 @@ where #[cfg(all( feature = "multi-window", feature = "wayland", - feature = "winit", target_os = "linux" ))] positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner::default(), @@ -338,7 +335,6 @@ where #[cfg(all( feature = "multi-window", feature = "wayland", - feature = "winit", target_os = "linux" ))] pub fn with_positioner( @@ -376,7 +372,6 @@ where feature = "multi-window", feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] #[allow(clippy::too_many_lines)] @@ -647,7 +642,6 @@ where #[cfg(all( feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] { @@ -671,7 +665,6 @@ where feature = "multi-window", feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) { @@ -686,7 +679,6 @@ where feature = "multi-window", feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) { @@ -769,7 +761,6 @@ where feature = "multi-window", feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) diff --git a/src/widget/menu/menu_inner.rs b/src/widget/menu/menu_inner.rs index 74afe60..a8607d2 100644 --- a/src/widget/menu/menu_inner.rs +++ b/src/widget/menu/menu_inner.rs @@ -8,7 +8,6 @@ use super::{menu_bar::MenuBarState, menu_tree::MenuTree}; feature = "multi-window", feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] use crate::app::cosmic::{WINDOWING_SYSTEM, WindowingSystem}; @@ -682,7 +681,6 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> { feature = "multi-window", feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) @@ -967,7 +965,6 @@ impl Widget( feature = "multi-window", feature = "wayland", target_os = "linux", - feature = "winit", feature = "surface-message" ))] pub(super) fn init_root_popup_menu( @@ -1527,7 +1523,7 @@ where .as_ref() .is_some_and(|i| *i != new_index && !active_menu[*i].children.is_empty()); - #[cfg(all(feature = "multi-window", feature = "wayland",target_os = "linux", feature = "winit", feature = "surface-message"))] + #[cfg(all(feature = "multi-window", feature = "wayland", target_os = "linux", feature = "surface-message"))] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && remove { if let Some(id) = state.popup_id.remove(&menu.window_id) { state.active_root.truncate(menu.depth + 1);