From 9638fda582b7c2068280c12dd5fb5ef7391021b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sun, 14 Apr 2024 14:37:49 +0800 Subject: [PATCH] fix --- .../LunaTranslator/gui/translatorUI.py | 23 ++++++------------- .../LunaTranslator/myutils/utils.py | 23 ++++++++++++------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 27b33669..318b7183 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -562,24 +562,15 @@ class QUnFrameWindow(resizableframeless): windows.SWP_NOACTIVATE | windows.SWP_NOSIZE | windows.SWP_NOMOVE, ) - def settop(self): - if ( + def istopmost(self): + return bool( windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE) & windows.WS_EX_TOPMOST - ) == 0: - windows.SetWindowPos( - int(self.winId()), - windows.HWND_NOTOPMOST, - 0, - 0, - 0, - 0, - windows.SWP_NOACTIVATE | windows.SWP_NOSIZE | windows.SWP_NOMOVE, - ) - HWNDStyleEx = windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE) - windows.SetWindowLong( - int(self.winId()), windows.GWL_EXSTYLE, HWNDStyleEx & ~windows.WS_EX_TOPMOST - ) + ) + + def settop(self): + if not self.istopmost(): + self.canceltop() HWNDStyleEx = windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE) windows.SetWindowLong( int(self.winId()), windows.GWL_EXSTYLE, HWNDStyleEx | windows.WS_EX_TOPMOST diff --git a/LunaTranslator/LunaTranslator/myutils/utils.py b/LunaTranslator/LunaTranslator/myutils/utils.py index 63318053..16308d73 100644 --- a/LunaTranslator/LunaTranslator/myutils/utils.py +++ b/LunaTranslator/LunaTranslator/myutils/utils.py @@ -425,15 +425,22 @@ def minmaxmoveobservefunc(self): if globalconfig["keepontop"] and globalconfig["focusnotop"]: if _focusp == os.getpid(): pass - elif ( - len(gobject.baseobject.textsource.pids) == 0 - or _focusp in gobject.baseobject.textsource.pids - ): - gobject.baseobject.translation_ui.thistimenotsetop = False - gobject.baseobject.translation_ui.settop() else: - gobject.baseobject.translation_ui.thistimenotsetop = True - gobject.baseobject.translation_ui.canceltop() + hwndmagpie = windows.FindWindow( + "Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", None + ) + hwndlossless = windows.FindWindow("LosslessScaling", None) + if ( + len(gobject.baseobject.textsource.pids) == 0 + or _focusp in gobject.baseobject.textsource.pids + or hwnd == hwndmagpie + or hwnd == hwndlossless + ): + gobject.baseobject.translation_ui.thistimenotsetop = False + gobject.baseobject.translation_ui.settop() + else: + gobject.baseobject.translation_ui.thistimenotsetop = True + gobject.baseobject.translation_ui.canceltop() if _focusp != windows.GetWindowThreadProcessId( gobject.baseobject.textsource.hwnd ):