From 5aa42509db0fbda4d6235f557b377662236decfe Mon Sep 17 00:00:00 2001 From: Moses Miller Date: Thu, 10 Jul 2025 23:59:29 -0700 Subject: [PATCH 1/2] Merge the application menu and title bar when menus are always shown and project items are hidden --- crates/title_bar/src/application_menu.rs | 4 ++-- crates/title_bar/src/title_bar.rs | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/title_bar/src/application_menu.rs b/crates/title_bar/src/application_menu.rs index a5d5f154c9..5e04a068a6 100644 --- a/crates/title_bar/src/application_menu.rs +++ b/crates/title_bar/src/application_menu.rs @@ -245,14 +245,14 @@ impl ApplicationMenu { cx.defer_in(window, move |_, window, cx| next_handle.show(window, cx)); } - pub fn all_menus_shown(&self, cx: &mut Context) -> bool { + pub fn all_menus_shown(&self, cx: &App) -> bool { show_menus(cx) || self.entries.iter().any(|entry| entry.handle.is_deployed()) || 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 && (cfg!(not(target_os = "macos")) || option_env!("ZED_USE_CROSS_PLATFORM_MENU").is_some()) } diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 17c4c85b6d..c08149ca9d 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -138,7 +138,9 @@ impl Render for TitleBar { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { 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_seperate_menus = show_menus(cx) && render_project_items; let mut children = Vec::new(); @@ -146,14 +148,14 @@ impl Render for TitleBar { h_flex() .gap_1() .map(|title_bar| { - let mut render_project_items = title_bar_settings.show_branch_name - || title_bar_settings.show_project_items; title_bar .when_some( - self.application_menu.clone().filter(|_| !show_menus), + self.application_menu + .clone() + .filter(|_| !show_seperate_menus), |title_bar, menu| { 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) }, ) @@ -201,7 +203,7 @@ impl Render for TitleBar { .into_any_element(), ); - if show_menus { + if show_seperate_menus { self.platform_titlebar.update(cx, |this, _| { this.set_children( self.application_menu From 1c9d03aca61b27edd3b7ee6f0670432a5929c598 Mon Sep 17 00:00:00 2001 From: Moses Miller Date: Fri, 11 Jul 2025 00:51:44 -0700 Subject: [PATCH 2/2] Fix typo --- crates/title_bar/src/title_bar.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index c08149ca9d..809ee58c15 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -140,7 +140,7 @@ impl Render for TitleBar { let mut render_project_items = title_bar_settings.show_branch_name || title_bar_settings.show_project_items; - let show_seperate_menus = show_menus(cx) && render_project_items; + let show_separate_menus = show_menus(cx) && render_project_items; let mut children = Vec::new(); @@ -152,7 +152,7 @@ impl Render for TitleBar { .when_some( self.application_menu .clone() - .filter(|_| !show_seperate_menus), + .filter(|_| !show_separate_menus), |title_bar, menu| { render_project_items &= !menu.read_with(cx, |menu, cx| menu.all_menus_shown(cx)); @@ -203,7 +203,7 @@ impl Render for TitleBar { .into_any_element(), ); - if show_seperate_menus { + if show_separate_menus { self.platform_titlebar.update(cx, |this, _| { this.set_children( self.application_menu