fix(mica): apply correct mica when switching layouts

This commit is contained in:
Elian Doran 2024-12-07 03:15:39 +02:00
parent 407448476b
commit 57d2b0ebf5
No known key found for this signature in database
2 changed files with 17 additions and 6 deletions

View File

@ -48,14 +48,17 @@ function initOnElectron() {
const electron = utils.dynamicRequire('electron');
electron.ipcRenderer.on('globalShortcut', async (event, actionName) => appContext.triggerCommand(actionName));
const electronRemote = utils.dynamicRequire("@electron/remote");
const currentWindow = electronRemote.getCurrentWindow();
initTransparencyEffects(currentWindow);
if (options.get("nativeTitleBarVisible") !== "true") {
initTitleBarButtons();
}
initTitleBarButtons(currentWindow);
}
}
function initTitleBarButtons() {
const electronRemote = utils.dynamicRequire("@electron/remote");
const currentWindow = electronRemote.getCurrentWindow();
function initTitleBarButtons(currentWindow) {
const style = window.getComputedStyle(document.body);
if (window.glob.platform === "win32") {
@ -80,3 +83,11 @@ function initTitleBarButtons() {
currentWindow.setWindowButtonPosition({ x: xOffset, y: yOffset });
}
}
function initTransparencyEffects(currentWindow) {
if (window.glob.platform === "win32") {
const isHorizontalLayout = (options.get("layoutOrientation") === "horizontal");
const backgroundMaterial = isHorizontalLayout ? "tabbed" : "mica";
currentWindow.setBackgroundMaterial(backgroundMaterial);
}
}

View File

@ -132,7 +132,7 @@ function getWindowExtraOpts() {
}
// Window effects (Mica)
// TODO: Apply only on Windows and allow the user to choose whether to activate it or not.
// TODO: Deduplicate with src/public/app/desktop.js#initTransparencyEffects
const isHorizontalLayout = (optionService.getOption("layoutOrientation") === "horizontal");
extraOpts.backgroundMaterial = isHorizontalLayout ? "tabbed" : "mica";