GregVido / mica-electron

Library to add mica effect of windows 11 in electron app
Apache License 2.0
126 stars 7 forks source link

When minimizing and maximizing right afterwards the app is blank #39

Open notAperson535 opened 3 months ago

notAperson535 commented 3 months ago

After maximizing the app after minimizing, there is no content on the screen (Electron version 29.3.3): image

const { app, BrowserWindow } = require('electron')
const { PARAMS, VALUE, MicaBrowserWindow, IS_WINDOWS_11, WIN10 } = require('mica-electron');
const path = require('node:path')

const createWindow = () => {
    const mainWindow = new MicaBrowserWindow({
        // titleBarStyle: "hidden",
        // titleBarOverlay: true,
        titleBarStyle: 'default',
        width: 800,
        height: 600,
        show: false,
        webPreferences: {
            webviewTag: true,
            preload: path.join(__dirname, 'preload.js'),
            sandbox: false
        }
    })

    mainWindow.setLightTheme()
    mainWindow.setMicaEffect()
    mainWindow.setRoundedCorner()
    mainWindow.alwaysFocused(true)

    mainWindow.webContents.once('dom-ready', () => {
        mainWindow.show();
    });

    mainWindow.webContents.on("did-attach-webview", (_, contents) => {
        contents.setWindowOpenHandler((details) => {
            mainWindow.webContents.send('open-url', details.url);
            return { action: 'deny' }
        })
    })

    mainWindow.loadFile('index.html')
}

app.whenReady().then(() => {
    createWindow()

    app.on('activate', () => {
        if (BrowserWindow.getAllWindows().length === 0) createWindow()
    })
})

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') app.quit()
})
notAperson535 commented 3 months ago

Also might be a different issue but when the window is first created it is really small, as you can see in the screenshot

GregVido commented 3 months ago

Hi ! I did an update which partially fixes the problem (there is still the problem with the large screen). I spent a lot of time on it and it's quite complex. I hope I find a solution in time.

notAperson535 commented 3 months ago

Ok, minimizing on small window is now fixed, but as you said the maximized window still glitches out when minimized