@@ -33,6 +33,12 @@ def is_window_maximized(hwnd) -> bool:
3333 def is_window_fullscreen (hwnd ) -> bool :
3434 if not win32gui .IsWindowVisible (hwnd ):
3535 return False
36+ # A standard maximized window can have the same bounds as the monitor,
37+ # but borderless fullscreen applications may also report SW_MAXIMIZE.
38+ style = win32gui .GetWindowLong (hwnd , win32con .GWL_STYLE )
39+ has_standard_frame = style & (win32con .WS_CAPTION | win32con .WS_THICKFRAME )
40+ if is_window_maximized (hwnd ) and has_standard_frame :
41+ return False
3642 rect = win32gui .GetWindowRect (hwnd )
3743 screen_width = ctypes .windll .user32 .GetSystemMetrics (0 )
3844 screen_height = ctypes .windll .user32 .GetSystemMetrics (1 )
@@ -49,6 +55,7 @@ def __init__(self, app_central: "AppCentral") -> None:
4955
5056 self ._window_states : dict [int , dict [str , bool ]] = {}
5157 self .previous_state : bool = False
58+ self ._fullscreen_window : int | None = None
5259
5360 # Check initial state on startup
5461 if self .app_central .configs .interactions .hide .in_class :
@@ -82,17 +89,29 @@ def update(self) -> None:
8289 any_fullscreen = False
8390
8491 if self .app_central .configs .interactions .hide .maximized :
85- # 最大化检测仍检查所有可见的应用窗口。
92+ # Maximum state is global and still checks all visible windows.
8693 self ._window_states .clear ()
8794 win32gui .EnumWindows (self ._enum_windows_callback , None )
95+
96+ if self .app_central .configs .interactions .hide .maximized :
8897 any_maximized = any (state ['maximized' ] for state in self ._window_states .values ())
8998
9099 if self .app_central .configs .interactions .hide .fullscreen :
91100 foreground_window = win32gui .GetForegroundWindow ()
92101 try :
93102 class_name = win32gui .GetClassName (foreground_window )
94103 if class_name not in SYSTEM_WINDOW_CLASSES :
95- any_fullscreen = is_window_fullscreen (foreground_window )
104+ if is_window_fullscreen (foreground_window ):
105+ self ._fullscreen_window = foreground_window
106+
107+ # Moving focus to another window does not make the fullscreen
108+ # window leave fullscreen. Clear the state only when the
109+ # tracked window actually leaves fullscreen or disappears.
110+ if self ._fullscreen_window is not None :
111+ if is_window_fullscreen (self ._fullscreen_window ):
112+ any_fullscreen = True
113+ else :
114+ self ._fullscreen_window = None
96115 except Exception as e :
97116 logger .debug (f"Check foreground window { foreground_window } failed: { e } " )
98117
0 commit comments