diff --git a/assets/settings/default.json b/assets/settings/default.json index 249100135bc..294511e8861 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -626,6 +626,8 @@ "show_sign_in": true, // Whether to show the menus in the titlebar. "show_menus": false, + // Whether to open the menus in the titlebar on hover. + "open_menus_on_hover": false, // The layout of window control buttons in the title bar (Linux only). "button_layout": "platform_default", }, diff --git a/crates/settings_content/src/title_bar.rs b/crates/settings_content/src/title_bar.rs index 74f406e8abe..d4fc6fe990d 100644 --- a/crates/settings_content/src/title_bar.rs +++ b/crates/settings_content/src/title_bar.rs @@ -119,6 +119,10 @@ pub struct TitleBarSettingsContent { /// /// Default: false pub show_menus: Option, + /// Whether to automatically open the menus in the title bar on hover. + /// + /// Default: false + pub open_menus_on_hover: Option, /// The layout of window control buttons in the title bar (Linux only). /// /// This can be set to "platform_default" to follow the system configuration, or diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index 2c5b4ef9e87..8e393c28bfc 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -4286,7 +4286,7 @@ fn window_and_layout_page() -> SettingsPage { ] } - fn title_bar_section() -> [SettingsPageItem; 11] { + fn title_bar_section() -> [SettingsPageItem; 12] { [ SettingsPageItem::SectionHeader("Title Bar"), SettingsPageItem::SettingItem(SettingItem { @@ -4602,6 +4602,25 @@ fn window_and_layout_page() -> SettingsPage { }) .collect(), }), + SettingsPageItem::SettingItem(SettingItem { + title: "Open Menus on Hover", + description: "Automatically open menus in the titlebar on hover.", + field: Box::new(SettingField { + organization_override: None, + json_path: Some("title_bar.open_menus_on_hover"), + pick: |settings_content| { + settings_content.title_bar.as_ref()?.open_menus_on_hover.as_ref() + }, + write: |settings_content, value, _| { + settings_content + .title_bar + .get_or_insert_default() + .open_menus_on_hover = value; + }, + }), + metadata: None, + files: USER, + }), ] } diff --git a/crates/title_bar/src/application_menu.rs b/crates/title_bar/src/application_menu.rs index 8ab7590b5b1..ced552d53ff 100644 --- a/crates/title_bar/src/application_menu.rs +++ b/crates/title_bar/src/application_menu.rs @@ -235,7 +235,11 @@ impl ApplicationMenu { .with_handle(current_handle.clone()), ) .on_hover(move |hover_enter, window, cx| { - if *hover_enter && !current_handle.is_deployed() { + if *hover_enter + && !current_handle.is_deployed() + && (open_menus_on_hover(cx) + || all_handles.iter().any(|handle| handle.is_deployed())) + { all_handles.iter().for_each(|h| h.hide(cx)); // We need to defer this so that this menu handle can take focus from the previous menu @@ -315,6 +319,10 @@ pub(crate) fn show_menus(cx: &mut App) -> bool { && (cfg!(not(target_os = "macos")) || option_env!("ZED_USE_CROSS_PLATFORM_MENU").is_some()) } +pub(crate) fn open_menus_on_hover(cx: &mut App) -> bool { + TitleBarSettings::get_global(cx).open_menus_on_hover +} + impl Render for ApplicationMenu { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let all_menus_shown = self.all_menus_shown(cx); diff --git a/crates/title_bar/src/title_bar_settings.rs b/crates/title_bar/src/title_bar_settings.rs index fac95319487..7821dff303c 100644 --- a/crates/title_bar/src/title_bar_settings.rs +++ b/crates/title_bar/src/title_bar_settings.rs @@ -12,6 +12,7 @@ pub struct TitleBarSettings { pub show_sign_in: bool, pub show_user_menu: bool, pub show_menus: bool, + pub open_menus_on_hover: bool, pub button_layout: Option, } @@ -28,6 +29,7 @@ impl Settings for TitleBarSettings { show_sign_in: content.show_sign_in.unwrap(), show_user_menu: content.show_user_menu.unwrap(), show_menus: content.show_menus.unwrap(), + open_menus_on_hover: content.open_menus_on_hover.unwrap(), button_layout: content.button_layout.unwrap_or_default().into_layout(), } } diff --git a/docs/src/reference/all-settings.md b/docs/src/reference/all-settings.md index 29d4609ec3c..9ce09d7ea51 100644 --- a/docs/src/reference/all-settings.md +++ b/docs/src/reference/all-settings.md @@ -5473,6 +5473,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a "show_user_menu": true, "show_sign_in": true, "show_menus": false, + "open_menus_on_hover": false, "button_layout": "platform_default" } } @@ -5489,6 +5490,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a - `show_user_menu`: Whether to show the user menu button in the titlebar (the one that displays your avatar by default and contains options like Settings, Keymap, Themes, etc.) - `show_sign_in`: Whether to show the sign in button in the titlebar - `show_menus`: Whether to show the menus in the titlebar +- `open_menus_on_hover`: Whether to open title-bar menus on hover. Once a menu is open, hovering always switches between menus. - `button_layout`: The layout of window control buttons in the title bar (Linux only). Can be set to `"platform_default"` to follow the system setting, `"standard"` to use Zed's built-in layout, or a custom format like `"close:minimize,maximize"` ## Window Title Format diff --git a/docs/src/visual-customization.md b/docs/src/visual-customization.md index 2ecb58d210e..c727ee4f175 100644 --- a/docs/src/visual-customization.md +++ b/docs/src/visual-customization.md @@ -136,14 +136,15 @@ To disable this behavior use: // Control which items are shown/hidden in the title bar "title_bar": { "show_branch_status_icon": false, // Show git status on branch icon - "show_branch_name": true, // Show/hide branch name - "show_worktree_name": true, // Show/hide worktree name - "show_project_items": true, // Show/hide project host and name - "show_onboarding_banner": true, // Show/hide onboarding banners - "show_user_picture": true, // Show/hide user avatar - "show_user_menu": true, // Show/hide app user button - "show_sign_in": true, // Show/hide sign-in button - "show_menus": false // Show/hide menus + "show_branch_name": true, // Show/hide branch name + "show_worktree_name": true, // Show/hide worktree name + "show_project_items": true, // Show/hide project host and name + "show_onboarding_banner": true, // Show/hide onboarding banners + "show_user_picture": true, // Show/hide user avatar + "show_user_menu": true, // Show/hide app user button + "show_sign_in": true, // Show/hide sign-in button + "show_menus": false, // Show/hide menus + "open_menus_on_hover": false // Automatically open menus on hover }, ```