From d2f9473a1c6c4076a8cc9c87c2423afbe3c4a831 Mon Sep 17 00:00:00 2001 From: fullex <106392080+0xfullex@users.noreply.github.com> Date: Mon, 16 Jun 2025 09:54:20 +0800 Subject: [PATCH] fix(SelectionService): Win10 showing problem & AlwaysOnTop level (#7215) refactor(SelectionService): enhance logging and adjust window behavior for Windows compatibility - Updated logInfo method to include a forceShow parameter for improved logging control. - Ensured toolbar window is set to always on top when shown. - Commented out setOpacity calls to prevent transparency issues on Windows 10. --- src/main/services/SelectionService.ts | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/services/SelectionService.ts b/src/main/services/SelectionService.ts index 89082ca68f..eba97179bc 100644 --- a/src/main/services/SelectionService.ts +++ b/src/main/services/SelectionService.ts @@ -285,7 +285,7 @@ export class SelectionService { this.processTriggerMode() this.started = true - this.logInfo('SelectionService Started') + this.logInfo('SelectionService Started', true) return true } @@ -319,7 +319,7 @@ export class SelectionService { this.closePreloadedActionWindows() this.started = false - this.logInfo('SelectionService Stopped') + this.logInfo('SelectionService Stopped', true) return true } @@ -335,7 +335,7 @@ export class SelectionService { this.selectionHook = null this.initStatus = false SelectionService.instance = null - this.logInfo('SelectionService Quitted') + this.logInfo('SelectionService Quitted', true) } /** @@ -456,8 +456,18 @@ export class SelectionService { x: posX, y: posY }) + + //set the window to always on top (highest level) + //should set every time the window is shown + this.toolbarWindow!.setAlwaysOnTop(true, 'screen-saver') this.toolbarWindow!.show() - this.toolbarWindow!.setOpacity(1) + + /** + * In Windows 10, setOpacity(1) will make the window completely transparent + * It's a strange behavior, so we don't use it for compatibility + */ + // this.toolbarWindow!.setOpacity(1) + this.startHideByMouseKeyListener() } @@ -467,7 +477,7 @@ export class SelectionService { public hideToolbar(): void { if (!this.isToolbarAlive()) return - this.toolbarWindow!.setOpacity(0) + // this.toolbarWindow!.setOpacity(0) this.toolbarWindow!.hide() this.stopHideByMouseKeyListener() @@ -1264,8 +1274,10 @@ export class SelectionService { this.isIpcHandlerRegistered = true } - private logInfo(message: string) { - isDev && Logger.info('[SelectionService] Info: ', message) + private logInfo(message: string, forceShow: boolean = false) { + if (isDev || forceShow) { + Logger.info('[SelectionService] Info: ', message) + } } private logError(...args: [...string[], Error]) {