Title bar: a double-click on the macOS app bar zooms the window (fixes #1932)

This commit is contained in:
Marco Arnulfo
2026-10-16 04:44:52 +07:00
committed by bflatastic
parent ba254a7481
commit 20325b1a89
2 changed files with 22 additions and 3 deletions
+5 -2
View File
@@ -22,7 +22,8 @@ const WIDGET_H: f32 = 22.0;
/// The application bar: brand mark, Home, menus, then Discord, search and the workspace switcher
/// at the right. With [`VectorcraftApp::custom_titlebar`] it is also the window's title bar
/// ([`titlebar`]): the caption buttons take the right end and the rest of the bar drags the window.
/// With the system title bar (Windows and Linux, `system_title_bar`) the OS draws its own icon and
/// On macOS, under the system's transparent title bar, its empty space drags and zooms the window
/// too ([`titlebar::drag_area`]). With the system title bar (Windows and Linux, `system_title_bar`) the OS draws its own icon and
/// title, so the in-app bar shows Home, menus and workspace controls only: no brand mark.
pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
let t = Tokens::get(ui.ctx());
@@ -31,7 +32,9 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
let left = app.titlebar_inset.clamp(8.0, f32::from(i8::MAX)) as i8;
let frame = egui::Frame::NONE.fill(t.app_bar).inner_margin(egui::Margin { left, right: if custom { 0 } else { 14 }, top: 0, bottom: 0 });
let bar = egui::Panel::top("app_bar").exact_size(APP_BAR_HEIGHT).frame(frame.stroke(Stroke::new(1.0, t.border))).show(ui, |ui| {
if custom {
// macOS draws the bar under its transparent title bar, so the bar gets the title bar's
// clicks: without this a double-click there zooms nothing (#1932).
if custom || cfg!(target_os = "macos") {
titlebar::drag_area(ui, ui.max_rect());
}
ui.horizontal_centered(|ui| {
+17 -1
View File
@@ -1,7 +1,8 @@
//! The window's own title bar on Windows and Linux, where the window has no OS decorations
//! ([`VectorcraftApp::custom_titlebar`]): empty space in the app bar drags the window and a
//! double-click there maximizes it, caption buttons at the far right minimize, maximize/restore and
//! close, and thin invisible zones along the window's edges resize it.
//! close, and thin invisible zones along the window's edges resize it. On macOS the app bar sits
//! under the system's transparent title bar and only its [`drag_area`] is used.
use egui::{CursorIcon, Id, LayerId, Order, PointerButton, Rect, ResizeDirection, Sense, Stroke, Ui, ViewportCommand, pos2, vec2};
use serde_json::json;
@@ -347,6 +348,21 @@ mod tests {
assert!(!cmds.iter().any(|c| matches!(c, ViewportCommand::StartDrag)), "{cmds:?}");
}
#[test]
fn a_double_click_on_the_macos_app_bar_zooms_the_window() {
// macOS keeps the system decorations, with the app bar under its transparent title bar
// (#1932); Windows and Linux with the system title bar leave it to the OS's bar.
let mut w = Win::new(1440.0);
w.app.custom_titlebar = false;
w.frame(vec![]);
let empty = pos2(700.0, 16.0);
assert!(w.bar_widgets().iter().all(|r| !r.contains(empty)), "the probe point must be empty bar space");
let mut cmds = w.click(empty);
cmds.extend(w.click(empty));
assert_eq!(cmds.contains(&ViewportCommand::Maximized(true)), cfg!(target_os = "macos"), "{cmds:?}");
assert!(!cmds.iter().any(|c| matches!(c, ViewportCommand::Maximized(false))), "{cmds:?}");
}
#[test]
fn edge_zones_resize_unless_maximized() {
use ResizeDirection::*;