mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 15:19:16 +00:00
* fix(windows): restore frameless rounded corners and tray transparency (#2505) Windows frameless windows used a solid host backgroundColor under DWM rounding, which showed as a dark rim, while the tray popup kept the default opaque backdrop under CSS border-radius (square tips / 冒尖). Use a clear transparent host with native roundedCorners for app windows, and disable OS rounding for the CSS-shaped tray overlay. Keep html/body transparent on the tray route so corner pixels stay see-through. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(windows): require chrome helpers outside with(ctx) createMainWindowApi injects require from windowManager.cjs, so a relative require inside with(ctx) resolved to electron/bridges/windowsWindowChrome.cjs and crashed every main-window create (MODULE_NOT_FOUND). Load the helpers at module scope in each factory so paths stay file-local. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(windows): keep resizable app windows opaque Codex P2: Electron documents transparent BrowserWindows as not resizable, and enabling resizable can break them. App content windows now only set roundedCorners: true with a solid theme backdrop; the tray overlay stays transparent because it is already non-resizable. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(tray): hide opaque splash on tray overlay route Codex P2: the shared splash screen still painted an opaque full-window fill when the tray panel showed before React mounted, recreating the square-corner flash. Mark tray-window early, CSS-hide the splash, and remove the splash node on DOM ready / tray render. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(tray): defer first show until ready; keep chrome comments ASCII Wait to show the tray BrowserWindow until did-finish-load so the shared opaque splash cannot flash as a square underlay. Also rewrite the new helper file header in ASCII-only English per AGENTS.md. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(tray): cancel pending first-load show on second toggle If the user toggles the tray again while the first renderer load is still pending, clear trayPanelShowWhenReady so did-finish-load cannot open the panel after an intentional dismiss. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(tray): keep shared splash transparent by default Move the opaque splash fill behind html:not(.tray-window) so the tray overlay route never inherits a solid full-window background from the shared splash markup. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
105 lines
4.1 KiB
JavaScript
105 lines
4.1 KiB
JavaScript
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const path = require("node:path");
|
|
const { readFileSync } = require("node:fs");
|
|
|
|
const {
|
|
CLEAR_BACKGROUND,
|
|
isWindowsPlatform,
|
|
windowsFramelessContentChromeOptions,
|
|
windowsCssRoundedOverlayChromeOptions,
|
|
} = require("./windowsWindowChrome.cjs");
|
|
|
|
test("CLEAR_BACKGROUND is fully transparent ARGB", () => {
|
|
assert.equal(CLEAR_BACKGROUND, "#00000000");
|
|
});
|
|
|
|
test("isWindowsPlatform detects win32 only", () => {
|
|
assert.equal(isWindowsPlatform("win32"), true);
|
|
assert.equal(isWindowsPlatform("darwin"), false);
|
|
assert.equal(isWindowsPlatform("linux"), false);
|
|
});
|
|
|
|
test("content chrome is a no-op outside Windows", () => {
|
|
assert.deepEqual(windowsFramelessContentChromeOptions("darwin"), {});
|
|
assert.deepEqual(windowsFramelessContentChromeOptions("linux"), {});
|
|
});
|
|
|
|
test("content chrome enables native rounding without transparency on Windows", () => {
|
|
assert.deepEqual(windowsFramelessContentChromeOptions("win32"), {
|
|
roundedCorners: true,
|
|
});
|
|
assert.equal(
|
|
Object.hasOwn(windowsFramelessContentChromeOptions("win32"), "transparent"),
|
|
false,
|
|
"resizable app windows must not use transparent hosts",
|
|
);
|
|
});
|
|
|
|
test("CSS overlay chrome clears the opaque backdrop on every platform", () => {
|
|
assert.deepEqual(windowsCssRoundedOverlayChromeOptions("darwin"), {
|
|
transparent: true,
|
|
backgroundColor: CLEAR_BACKGROUND,
|
|
});
|
|
assert.deepEqual(windowsCssRoundedOverlayChromeOptions("linux"), {
|
|
transparent: true,
|
|
backgroundColor: CLEAR_BACKGROUND,
|
|
});
|
|
});
|
|
|
|
test("CSS overlay chrome disables OS rounding on Windows", () => {
|
|
assert.deepEqual(windowsCssRoundedOverlayChromeOptions("win32"), {
|
|
transparent: true,
|
|
backgroundColor: CLEAR_BACKGROUND,
|
|
roundedCorners: false,
|
|
});
|
|
});
|
|
|
|
test("main/settings/tray call sites wire Windows chrome helpers", () => {
|
|
const here = __dirname;
|
|
const main = readFileSync(path.join(here, "mainWindow.cjs"), "utf8");
|
|
const settings = readFileSync(path.join(here, "settingsWindow.cjs"), "utf8");
|
|
const popup = readFileSync(path.join(here, "terminalPopupWindow.cjs"), "utf8");
|
|
const tray = readFileSync(path.join(here, "../globalShortcutBridge.cjs"), "utf8");
|
|
const css = readFileSync(path.join(here, "../../../index.css"), "utf8");
|
|
const html = readFileSync(path.join(here, "../../../index.html"), "utf8");
|
|
const helper = readFileSync(path.join(here, "windowsWindowChrome.cjs"), "utf8");
|
|
|
|
for (const [label, source] of [
|
|
["mainWindow", main],
|
|
["settingsWindow", settings],
|
|
["terminalPopupWindow", popup],
|
|
]) {
|
|
assert.match(source, /require\("\.\/windowsWindowChrome\.cjs"\)/, `${label} must require chrome helpers`);
|
|
assert.match(source, /windowsFramelessContentChromeOptions/, `${label} must use content chrome helper`);
|
|
assert.doesNotMatch(source, /resolveFramelessHostBackgroundColor/, `${label} should not clear host backdrop`);
|
|
const requireIndex = source.indexOf('require("./windowsWindowChrome.cjs")');
|
|
const withIndex = source.indexOf("with (ctx)");
|
|
assert.ok(
|
|
requireIndex !== -1 && withIndex !== -1 && requireIndex < withIndex,
|
|
`${label}: require chrome helpers before with(ctx) so injected require cannot remount the path`,
|
|
);
|
|
}
|
|
assert.match(tray, /windowsCssRoundedOverlayChromeOptions/);
|
|
assert.match(tray, /#2505/);
|
|
assert.match(css, /html\.tray-window/);
|
|
assert.match(css, /html\.tray-window \.splash-screen/);
|
|
assert.match(html, /tray-window/);
|
|
assert.match(html, /removeTraySplash|splash\.remove\(\)/);
|
|
assert.match(tray, /trayPanelShowWhenReady|trayPanelReady/);
|
|
assert.match(tray, /isOpenOrPending/);
|
|
assert.match(helper, /square tips under a rounded panel/);
|
|
assert.match(helper, /not resizable/);
|
|
assert.doesNotMatch(helper, /[^\x00-\x7F]/, "helper comments must stay ASCII-only");
|
|
const contentHelperMatch = helper.match(
|
|
/function windowsFramelessContentChromeOptions\([\s\S]*?\n\}/,
|
|
);
|
|
assert.ok(contentHelperMatch, "content chrome helper must exist");
|
|
assert.match(contentHelperMatch[0], /roundedCorners:\s*true/);
|
|
assert.doesNotMatch(
|
|
contentHelperMatch[0],
|
|
/transparent/,
|
|
"content chrome must stay opaque/resizable",
|
|
);
|
|
});
|