This commit is contained in:
Moses Miller 2025-08-25 12:20:36 -04:00 committed by GitHub
commit 2dce113986
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 8 deletions

View file

@ -253,14 +253,14 @@ impl ApplicationMenu {
cx.defer_in(window, move |_, window, cx| next_handle.show(window, cx)); cx.defer_in(window, move |_, window, cx| next_handle.show(window, cx));
} }
pub fn all_menus_shown(&self, cx: &mut Context<Self>) -> bool { pub fn all_menus_shown(&self, cx: &App) -> bool {
show_menus(cx) show_menus(cx)
|| self.entries.iter().any(|entry| entry.handle.is_deployed()) || self.entries.iter().any(|entry| entry.handle.is_deployed())
|| self.pending_menu_open.is_some() || self.pending_menu_open.is_some()
} }
} }
pub(crate) fn show_menus(cx: &mut App) -> bool { pub(crate) fn show_menus(cx: &App) -> bool {
TitleBarSettings::get_global(cx).show_menus TitleBarSettings::get_global(cx).show_menus
&& (cfg!(not(target_os = "macos")) || option_env!("ZED_USE_CROSS_PLATFORM_MENU").is_some()) && (cfg!(not(target_os = "macos")) || option_env!("ZED_USE_CROSS_PLATFORM_MENU").is_some())
} }

View file

@ -138,7 +138,9 @@ impl Render for TitleBar {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let title_bar_settings = *TitleBarSettings::get_global(cx); let title_bar_settings = *TitleBarSettings::get_global(cx);
let show_menus = show_menus(cx); let mut render_project_items =
title_bar_settings.show_branch_name || title_bar_settings.show_project_items;
let show_separate_menus = show_menus(cx) && render_project_items;
let mut children = Vec::new(); let mut children = Vec::new();
@ -146,14 +148,14 @@ impl Render for TitleBar {
h_flex() h_flex()
.gap_1() .gap_1()
.map(|title_bar| { .map(|title_bar| {
let mut render_project_items = title_bar_settings.show_branch_name
|| title_bar_settings.show_project_items;
title_bar title_bar
.when_some( .when_some(
self.application_menu.clone().filter(|_| !show_menus), self.application_menu
.clone()
.filter(|_| !show_separate_menus),
|title_bar, menu| { |title_bar, menu| {
render_project_items &= render_project_items &=
!menu.update(cx, |menu, cx| menu.all_menus_shown(cx)); !menu.read_with(cx, |menu, cx| menu.all_menus_shown(cx));
title_bar.child(menu) title_bar.child(menu)
}, },
) )
@ -200,7 +202,7 @@ impl Render for TitleBar {
.into_any_element(), .into_any_element(),
); );
if show_menus { if show_separate_menus {
self.platform_titlebar.update(cx, |this, _| { self.platform_titlebar.update(cx, |this, _| {
this.set_children( this.set_children(
self.application_menu self.application_menu