Menu popup: visibility, zoom sync, and tab fixes
Track menu popup visibility and propagate zoom level to the popup. Add menu_popup_visible_ flag, SendMenuPopupZoom(), and call it when creating/showing the popup and when adjusting zoom. Make CreateNewTab accept an optional URL and route popup/new-tab flows to it. Prevent per-tab child closes from triggering app shutdown by tracking closing_tab_browsers_ and adding ForgetClosingTabBrowser(). Treat MenuPopup role specially when enabling frame hit-testing. Platform: remove usage of ApplyRoundedBrowserRegion and switch menu popup sizing to use resized client_size helpers (consolidate calculations across Win/Mac/Linux). UI: update menu-popup CSS/JS (new styling, font, zoom formatting API via NebulaMenuPopup.setZoomLevel), wire settings to use nebulaNative.postMessage for new-tab, and remove the static menu-popup.html. Misc: small chrome CSS/JS tweaks and ensure chrome state includes zoomLevel.
This commit is contained in:
+11
-19
@@ -18,37 +18,29 @@ function applyTheme(theme) {
|
||||
}
|
||||
|
||||
function sendMenuCommand(cmd) {
|
||||
if (window.electronAPI?.send) {
|
||||
window.electronAPI.send('menu-popup-command', { cmd });
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.nebulaNative?.postMessage) {
|
||||
window.nebulaNative.postMessage(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshZoom() {
|
||||
if (!window.electronAPI?.invoke || !zoomPercentEl) return;
|
||||
try {
|
||||
const z = await window.electronAPI.invoke('get-zoom-factor');
|
||||
zoomPercentEl.textContent = `${Math.round(z * 100)}%`;
|
||||
} catch {}
|
||||
function formatZoomPercent(zoomLevel) {
|
||||
const level = Number.isFinite(zoomLevel) ? zoomLevel : 0;
|
||||
return `${Math.round(Math.pow(1.2, level) * 100)}%`;
|
||||
}
|
||||
|
||||
window.electronAPI?.on?.('menu-popup-init', (payload) => {
|
||||
applyTheme(payload?.theme);
|
||||
refreshZoom();
|
||||
});
|
||||
function setZoomLevel(zoomLevel) {
|
||||
if (zoomPercentEl) {
|
||||
zoomPercentEl.textContent = formatZoomPercent(zoomLevel);
|
||||
}
|
||||
}
|
||||
|
||||
window.NebulaMenuPopup = { applyTheme, setZoomLevel };
|
||||
|
||||
window.addEventListener('click', (e) => {
|
||||
const btn = e.target.closest('button[data-cmd]');
|
||||
if (!btn) return;
|
||||
const cmd = btn.getAttribute('data-cmd');
|
||||
sendMenuCommand(cmd);
|
||||
if (cmd === 'zoom-in' || cmd === 'zoom-out') {
|
||||
setTimeout(refreshZoom, 50);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('keydown', (e) => {
|
||||
@@ -57,4 +49,4 @@ window.addEventListener('keydown', (e) => {
|
||||
}
|
||||
});
|
||||
|
||||
refreshZoom();
|
||||
setZoomLevel(0);
|
||||
|
||||
Reference in New Issue
Block a user