дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
AppKit puts the title bar container and window buttons back at their defaults on every live resize step, title change and fullscreen exit. They were corrected from window notifications after that layout had been drawn, so the buttons bounced between positions, or stayed at the defaults when no notification followed. The frames are now corrected in a main run loop observer ordered just before the Core Animation commit, project windows are created hidden on macOS so the buttons are placed before the first frame, and repeated title bar height updates are skipped. Choosing This Window for a local project in a remote window was routed to the remote host or skipped when the path matched the remote root. open_project and light_edit_open now run on the local backend and leave remote mode once they succeed, project trust for these opens is checked locally, and a failed open cancels the pending close.
34 рядки
1.3 KiB
TypeScript
34 рядки
1.3 KiB
TypeScript
import { useEffect, useRef } from "react";
|
|
import { call, commands } from "@/platform/ipc";
|
|
import { usePlatform } from "@/platform/platformInfo";
|
|
import { useProject } from "@/platform/project";
|
|
import { clampZoom } from "@/platform/zoom";
|
|
|
|
export function useNativeTitlebar(bar: HTMLElement | null) {
|
|
const overlay = usePlatform((s) => s.overlayTitleBar);
|
|
const zoom = useProject((s) => (s.settings ? clampZoom(s.settings.appearance?.zoom) : null));
|
|
const lastHeight = useRef<number | null>(null);
|
|
useEffect(() => {
|
|
if (!overlay || !bar || zoom === null) return;
|
|
bar.style.setProperty("--titlebar-zoom", String(zoom / 100));
|
|
const update = () => {
|
|
// Webview zoom scales CSS pixels; Retina scale is already handled by AppKit.
|
|
const height = (bar.getBoundingClientRect().height * zoom) / 100;
|
|
if (height > 0 && height !== lastHeight.current) {
|
|
lastHeight.current = height;
|
|
void call(commands.windowSetTitlebarHeight(height)).catch((e) => {
|
|
if (lastHeight.current === height) lastHeight.current = null;
|
|
console.warn("cannot align window buttons", e);
|
|
});
|
|
}
|
|
};
|
|
update();
|
|
const observer = new ResizeObserver(update);
|
|
observer.observe(bar);
|
|
return () => {
|
|
observer.disconnect();
|
|
bar.style.removeProperty("--titlebar-zoom");
|
|
};
|
|
}, [bar, overlay, zoom]);
|
|
}
|