gui: the Mac's title bar drags while a dialog is open, and the bar's middle does everywhere (ssuuuuooo on X)

v0.1.3624 added the .modal-grip strip but it could not work on the Mac:
there the scrim begins under the bar (body.window.mac .modal top: 50px),
so the strip sat below the bar, while the bar itself (header, sidebar top)
is inert whilst a dialog is open (modalBackground), and an inert element
is not hit, so nothing there carried --wails-draggable. On Windows and
Linux the strip worked only at the sides: the dialog's 16-28px top padding
let a tall dialog (the provider editor) lie over the strip's middle.

Now on the Mac the strip reaches up over the bar (top: -grip height; a
fixed child would not do, the scrim's backdrop-filter is its containing
block), and off the Mac the scrim's top padding is at least the strip's
height so no dialog lies over it. docs/subsystems/gui-shell.md updated.

Run (mote-run, chromium and webkit): modal-title-drag.test.cjs gains
"the middle of the title bar drags with a tall dialog open" (web and mac
classes, 5 x 3 points along the bar, header inert): 0 of 4 on the old css,
4 of 4 now. With modal-*, dialog-*, add-sheet*, signin-closes-sheet,
sidebar*, click-scroll, panel-drag-linux, title-bar-tools, i18n-keys,
popover-mac-chrome, editor-roomy: 351 pass; the 3 reds of that run
(modal-centred-late, sidebar-overlay-scrollbar webkit, title-bar-tools
zh-TW webkit) pass 36 of 36 rerun alone at this tree, and
sidebar-overlay-scrollbar webkit also failed once on the base (load).
Not tried: a real drag in the signed macOS app (the test checks the
--wails-draggable value under the pointer, which Wails reads); the
confirmation (action-confirm, top layer) still has no strip.
This commit is contained in:
yetone
2026-11-11 04:09:07 +08:00
parent 36b02474e0
commit 47e30d0e97
3 changed files with 49 additions and 6 deletions
+1 -1
View File
@@ -669,7 +669,7 @@ covers it in both engines, every language and a narrow window.
- Every dialog in `#modal` is 600px wide (`.modal .dialog`), a long text's editor 880 (`.wide`). A provider's editor (`drawEditor`, its accounts, meters and many rows) is `.roomy` and grows with a large window as a Mac sheet takes the room its content needs: 600 up to a 1071px window, then 56% of it, at most 880 (5046312 on Discord). `openModal` copies both classes from the content, so a question that takes the editor's place (Sign out's) stays 600. Its height already follows the content up to the window. See `editor-roomy.test.cjs`.
- The page must work in Chromium (Windows' WebView2) and WebKit (macOS, and WebKitGTK on Linux). GUI tests run in both engines.
- In the design of macOS 26 the main window has the corners of a window with a plain title bar, and its lights stay where the toolbar had them. `TestMainWindowCorners` ([`titlebar_darwin_test.go`](../../internal/gui/titlebar_darwin_test.go)) measures this in a process of its own, with package `windowshape`: after a new title and size and a new system appearance, as AppKit draws that appearance, where a first press with another app in front begins a window drag, and where a sheet begins. It runs that process as linked against the macOS 26 SDK and against macOS 15's, whatever SDK the toolchain has (`runAppKitSDK` and `stampSDK` give the copy it runs that SDK, and sign it again). Where a toolbar doesn't change the corners (the earlier design, on an older macOS or with macOS 15's SDK, and macOS 27 with either SDK), it checks that the window keeps its toolbar (#3949); `TestMainWindowRightToLeft` checks that it keeps it with the lights on the right. Both run in CI's macOS job. No test covers `UIDesignRequiresCompatibility`: AppKit reads it from an app bundle's Info.plist, LaunchServices registers each bundle that runs, and a press sent within a process run from one doesn't always begin a window drag.
- While a dialog (`#modal`) is open its scrim covers the title bar, so the dialog's last child `.modal-grip` is a drag strip as high as the bar (`--wails-draggable: drag`) and the dialog lies over it; a click on the strip still closes the dialog (ssuuuuooo on X, `modal-title-drag.test.cjs`). The browser's own confirmation (`action-confirm`, top layer) has no such strip.
- While a dialog (`#modal`) is open the header and sidebar are inert (`modalBackground`) and, off the Mac, the scrim covers the title bar, so the dialog's last child `.modal-grip` is a drag strip as high as the bar (`--wails-draggable: drag`), the dialog lies over it and the scrim's padding keeps the dialog below it, so the bar's middle drags too; on the Mac the scrim begins under the bar and the strip reaches up over it (v0.1.3624 left the Mac's bar inert, ssuuuuooo on X again); a click on the strip still closes the dialog (ssuuuuooo on X, `modal-title-drag.test.cjs`). The browser's own confirmation (`action-confirm`, top layer) has no such strip.
- On Linux the panel is frameless and the main window has a hidden title bar (`plainTitlebar`). GTK 3 asks KDE's Wayland session (KWin's decoration protocol) for a frame drawn by KWin on any window without client-side decorations, an undecorated one too, so `ownFrame` tells KWin the panel draws its own on each realize (#1283). GTK 4 builds ask for none themselves. With no KWin title bar, and with a Wayland window placed by the compositor rather than by the icon, the panel's header is its drag handle on Linux, as the window's is (`--wails-draggable` in `app.js`; `panel-drag-linux.test.cjs`); on the Mac and Windows the panel isn't dragged (#1430).
- On Linux the panel is a solid window, as the main window is, and its page paints `--bg` whole (`panelOptions`, `body.linux.panel` in `app.css`). The Mac's and Windows' panels stay translucent. A see-through panel is an RGBA, app-paintable GTK window under a transparent webview, and on KDE Plasma 6 its page, painted at 93%, left a fainter copy of the old scroll position as it scrolled (Wayland and XWayland, compositing mode on or off) while the main window never did (#1803, `TestPanelSolidOnLinux`, `panel-linux-opaque.test.cjs`). Xvfb with picom on WebKitGTK 2.54 doesn't show the ghost either way, so the fix rests on the reporter's machine.
- A Wayland window can't place itself, so under Hyprland and niri the compositor is asked to put the panel under the bar. Under Hyprland `placePanel` gives it a window rule at the cursor (`omarchy.PlacePanel`) and closes it on a click outside (`omarchy.ReportClicks`). The rule names the monitor under the cursor and moves the panel to x, y from that monitor's corner (`omarchy.PanelAt`): Hyprland adds the window's monitor's place to a `move`, so a position across the whole layout put the panel off a monitor not at 0,0 (#1785, `TestPanelAtMonitorOffScreenOrigin`). The cursor and the clients' places that `omarchy.ClickedOutside` compares are both across the layout. niri (`omarchy.Niri`, `NIRI_SOCKET` set) takes no rules at runtime and doesn't report the cursor. There `omarchy.NiriPanel` watches niri's event stream and moves the panel each time it opens: the window of magpie's pid titled `panelTitle`, moved with `MoveFloatingWindow` (after `MoveWindowToFloating` if it was tiled). It goes 6 px under the working area's top, centred on the x the tray host passed to `Activate(x, y)`. Wails keeps that x in its Linux tray (`trayClick`, `TestTrayClickIsWails`), and it is taken across the bar, since that's all a Wayland bar knows. With no click (`magpie panel`), or with one off the output, it goes top right. Wails' `HideOnFocusLost` closes it, since a click on another window takes niri's focus. It still opens in the middle and slides up, and a bar at the bottom or the side isn't accounted for (#1670).
+14 -5
View File
@@ -4261,7 +4261,8 @@ html.theming, html.theming *, html.theming *::before, html.theming *::after {
/* ---------- modal ---------- */
.modal {
position: fixed; inset: 0; z-index: 20;
display: flex; align-items: center; justify-content: center; padding: 28px 24px;
--grip-h: var(--top-h, 46px);
display: flex; align-items: center; justify-content: center; padding: max(28px, var(--grip-h)) 24px;
background: rgba(0, 0, 0, .28);
-webkit-backdrop-filter: blur(8px) saturate(1.1); backdrop-filter: blur(8px) saturate(1.1);
}
@@ -4277,9 +4278,17 @@ html.theming, html.theming *, html.theming *::before, html.theming *::after {
.modal .dialog { position: relative; z-index: 1; }
/* the scrim covers the title bar, so the window is still dragged from the
top strip while a dialog is open; the dialog lies over it and stays no-drag
(the strip is after it in the markup, app.js keeps the dialog the first child) */
.modal-grip { position: absolute; z-index: 0; top: 0; left: 0; right: 0; height: var(--top-h, 46px); }
body.window.mac .modal-grip { height: calc(50px / var(--zoom, 1)); }
(the strip is after it in the markup, app.js keeps the dialog the first child).
The modal's padding is at least the strip's height, so a tall dialog never
lies over the strip's middle (the strip was only free at the sides, and the
bar's middle is where a window is taken). */
.modal-grip { position: absolute; z-index: 0; top: 0; left: 0; right: 0; height: var(--grip-h); }
body.window.mac .modal { --grip-h: calc(50px / var(--zoom, 1)); }
/* On the Mac the scrim begins under the bar, and the bar itself (the header,
the sidebar's top) is inert while a dialog is open (modalBackground), so
nothing there drags: the strip reaches up over it. (A fixed child wouldn't:
the scrim's backdrop-filter is its containing block.) */
body.window.mac .modal-grip { top: calc(-1 * var(--grip-h)); }
.modal .dialog {
width: min(600px, 100%); min-width: 0; max-height: 100%; overflow-y: auto;
border-radius: 14px; background: var(--card);
@@ -4332,7 +4341,7 @@ body.window.mac .modal-grip { height: calc(50px / var(--zoom, 1)); }
/* Keep native window chrome outside the scrim and dialog. In particular, the
macOS traffic lights must never sit on top of modal content. */
body.window.mac .modal { top: calc(50px / var(--zoom, 1)); padding: 16px 24px 24px; }
body.window .modal { padding: 16px 24px 24px; }
body.window .modal { padding: max(16px, var(--grip-h)) 24px 24px; }
body.panel .modal { padding: 16px 12px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes content-in { from { opacity: .5; transform: translateY(2px); } }
@@ -92,3 +92,37 @@ for (const engine of process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
}
}
// ssuuuuooo again (v0.1.3631): the strip was free only at the sides; a tall
// dialog (the provider editor in a short window) lay over its middle, where a
// window is taken. Every point along the bar must drag, the middle too.
for (const engine of process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"]) {
for (const mac of [false, true]) {
test(`${engine} ${mac ? "mac" : "web"}: the middle of the title bar drags with a tall dialog open`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await browser.newPage({ viewport: { width: 1000, height: 520 }, reducedMotion: "reduce" });
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
await page.route("**/*", fixture("en"));
await page.goto("http://magpie.test/?view=providers");
await page.evaluate((mac) => { document.body.classList.remove("web"); document.body.classList.add("window"); if (mac) document.body.classList.add("mac"); }, mac);
await page.locator('#providers .row.provider[data-id="relay"]').click();
await page.getByRole("dialog").first().waitFor();
await page.waitForTimeout(400);
const grip = await page.evaluate(() => document.querySelector("#modal .modal-grip").getBoundingClientRect().height);
const d = await page.locator("#modal .dialog").boundingBox();
const m = await page.locator("#modal").boundingBox();
assert.ok(d.y >= m.y + (mac ? 0 : grip) - 0.5, `the dialog starts at ${d.y}, below the strip`);
// the header and sidebar are inert behind a dialog: the title bar's drag is the strip's
assert.ok(await page.evaluate(() => document.querySelector("header.top").inert), "the header is inert");
const top = 0; // the bar's rows from the window's top edge
for (const x of [4, 250, 500, 750, 996]) {
for (const y of [top + 4, top + grip / 2, top + grip - 3]) {
const r = await probe(page, x, y);
assert.equal(r.v, "drag", `(${x}, ${y}) drags the window`);
}
}
});
}
}