From f5fc392ba4064be5287c0f86d6d74db70e698b72 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 8 Jun 2026 16:49:09 -0400 Subject: [PATCH] fix: opaque menu for overlay --- src/theme/style/menu_bar.rs | 10 +++++----- src/widget/menu/menu_bar.rs | 16 +++++++++++++++- src/widget/menu/menu_inner.rs | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/theme/style/menu_bar.rs b/src/theme/style/menu_bar.rs index c6f40c52..50263b14 100644 --- a/src/theme/style/menu_bar.rs +++ b/src/theme/style/menu_bar.rs @@ -31,7 +31,7 @@ pub trait StyleSheet { type Style: Default; /// Produces the [`Appearance`] of a menu bar and its menus. - fn appearance(&self, style: &Self::Style) -> Appearance; + fn appearance(&self, style: &Self::Style, is_overlay: bool) -> Appearance; } /// The style of a menu bar and its menus @@ -54,7 +54,7 @@ impl From Appearance> for MenuBarStyle { impl StyleSheet for fn(&Theme) -> Appearance { type Style = Theme; - fn appearance(&self, style: &Self::Style) -> Appearance { + fn appearance(&self, style: &Self::Style, _is_overlay: bool) -> Appearance { (self)(style) } } @@ -62,9 +62,9 @@ impl StyleSheet for fn(&Theme) -> Appearance { impl StyleSheet for Theme { type Style = MenuBarStyle; - fn appearance(&self, style: &Self::Style) -> Appearance { + fn appearance(&self, style: &Self::Style, is_overlay: bool) -> Appearance { let cosmic = self.cosmic(); - let component = &cosmic.background(self.transparent).component; + let component = &cosmic.background(!is_overlay && self.transparent).component; let mut bg = component.base; match style { @@ -77,7 +77,7 @@ impl StyleSheet for Theme { background_expand: [1; 4], path: component.hover.into(), }, - MenuBarStyle::Custom(c) => c.appearance(self), + MenuBarStyle::Custom(c) => c.appearance(self, is_overlay), } } } diff --git a/src/widget/menu/menu_bar.rs b/src/widget/menu/menu_bar.rs index facdfb85..e9d25dd8 100644 --- a/src/widget/menu/menu_bar.rs +++ b/src/widget/menu/menu_bar.rs @@ -715,7 +715,21 @@ where // draw path highlight if self.path_highlight.is_some() { - let styling = theme.appearance(&self.style); + let mut is_overlay = true; + #[cfg(all( + feature = "multi-window", + feature = "wayland", + target_os = "linux", + feature = "winit", + feature = "surface-message" + ))] + if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) + && self.on_surface_action.is_some() + && self.window_id != window::Id::NONE + { + is_overlay = true; + }; + let styling = theme.appearance(&self.style, is_overlay); if let Some(active) = state.active_root.first() { let active_bounds = layout .children() diff --git a/src/widget/menu/menu_inner.rs b/src/widget/menu/menu_inner.rs index b2e7fd9d..b7595ba5 100644 --- a/src/widget/menu/menu_inner.rs +++ b/src/widget/menu/menu_inner.rs @@ -742,7 +742,7 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> { Rectangle::new(Point::ORIGIN, Size::INFINITE) }; - let styling = theme.appearance(&self.style); + let styling = theme.appearance(&self.style, self.is_overlay); let roots = active_root.iter().skip(1).fold( &self.menu_roots[active_root[0]].children, |mt, next_active_root| &mt[*next_active_root].children,