This commit is contained in:
恍兮惚兮 2024-04-14 14:37:49 +08:00
parent 4994d6248d
commit 9638fda582
2 changed files with 22 additions and 24 deletions

View File

@ -562,24 +562,15 @@ class QUnFrameWindow(resizableframeless):
windows.SWP_NOACTIVATE | windows.SWP_NOSIZE | windows.SWP_NOMOVE, windows.SWP_NOACTIVATE | windows.SWP_NOSIZE | windows.SWP_NOMOVE,
) )
def settop(self): def istopmost(self):
if ( return bool(
windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE) windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE)
& windows.WS_EX_TOPMOST & windows.WS_EX_TOPMOST
) == 0: )
windows.SetWindowPos(
int(self.winId()), def settop(self):
windows.HWND_NOTOPMOST, if not self.istopmost():
0, self.canceltop()
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
)
HWNDStyleEx = windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE) HWNDStyleEx = windows.GetWindowLong(int(self.winId()), windows.GWL_EXSTYLE)
windows.SetWindowLong( windows.SetWindowLong(
int(self.winId()), windows.GWL_EXSTYLE, HWNDStyleEx | windows.WS_EX_TOPMOST int(self.winId()), windows.GWL_EXSTYLE, HWNDStyleEx | windows.WS_EX_TOPMOST

View File

@ -425,15 +425,22 @@ def minmaxmoveobservefunc(self):
if globalconfig["keepontop"] and globalconfig["focusnotop"]: if globalconfig["keepontop"] and globalconfig["focusnotop"]:
if _focusp == os.getpid(): if _focusp == os.getpid():
pass 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: else:
gobject.baseobject.translation_ui.thistimenotsetop = True hwndmagpie = windows.FindWindow(
gobject.baseobject.translation_ui.canceltop() "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( if _focusp != windows.GetWindowThreadProcessId(
gobject.baseobject.textsource.hwnd gobject.baseobject.textsource.hwnd
): ):