diff --git a/src/main/PoeWindow.ts b/src/main/PoeWindow.ts index 23566227..24daca2e 100644 --- a/src/main/PoeWindow.ts +++ b/src/main/PoeWindow.ts @@ -47,8 +47,8 @@ class PoeWindowClass extends EventEmitter { OW.attachTo(window, config.get('windowTitle')) } - onceAttached (cb: (hasAccess: boolean | undefined) => void) { - OW.once('attach', (e: AttachEvent) => { + onAttach (cb: (hasAccess: boolean | undefined) => void) { + OW.on('attach', (e: AttachEvent) => { cb(e.hasAccess) }) } diff --git a/src/main/overlay-window.ts b/src/main/overlay-window.ts index c9f450b3..cdbe1125 100644 --- a/src/main/overlay-window.ts +++ b/src/main/overlay-window.ts @@ -16,11 +16,20 @@ export const overlayReady = new Promise((resolve) => { }) export async function createOverlayWindow () { + if (process.platform === 'win32' && !systemPreferences.isAeroGlassEnabled()) { + dialog.showErrorBox( + 'Windows 7 - Aero', + // ---------------------- + 'You must enable Windows Aero in "Appearance and Personalization".\n' + + 'It is required to create a transparent overlay window.' + ) + } + ipcMain.once(ipc.OVERLAY_READY, _resolveOverlayReady) ipcMain.on(ipc.DPR_CHANGE, (_: any, dpr: number) => handleDprChange(dpr)) ipcMain.on(ipc.CLOSE_OVERLAY, assertPoEActive) PoeWindow.on('active-change', handlePoeWindowActiveChange) - PoeWindow.onceAttached(handleOverlayAttached) + PoeWindow.onAttach(handleOverlayAttached) overlayWindow = new BrowserWindow({ icon: path.join(__static, 'icon.png'), @@ -118,6 +127,8 @@ function focusPoE () { function handleOverlayAttached (hasAccess?: boolean) { if (hasAccess === false) { + logger.error('PoE is running with administrator rights', { source: 'overlay' }) + dialog.showErrorBox( 'PoE window - No access', // ---------------------- @@ -125,16 +136,6 @@ function handleOverlayAttached (hasAccess?: boolean) { '\n' + 'You need to restart Awakened PoE Trade with administrator rights.' ) - return - } - - if (process.platform === 'win32' && !systemPreferences.isAeroGlassEnabled()) { - dialog.showErrorBox( - 'Windows 7 - Aero', - // ---------------------- - 'You must enable Windows Aero in "Appearance and Personalization".\n' + - 'It is required to create a transparent overlay window.' - ) } }