Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit14db841

Browse files
committed
fix(bar): improve fullscreen detection logic and visibility handling
1 parentc5a5801 commit14db841

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

‎src/core/bar.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importlogging
2+
frommathimportceil
23
fromsettingsimportAPP_BAR_TITLE
34
fromPyQt6.QtWidgetsimportQWidget,QHBoxLayout,QGridLayout,QFrame
45
fromPyQt6.QtGuiimportQScreen
@@ -212,20 +213,17 @@ def showEvent(self, event):
212213

213214

214215
defis_foreground_fullscreen(self):
215-
# Get the active window's handle using win32gui
216+
"""Check if the activeforegroundwindow is in fullscreen mode."""
216217
hwnd=win32gui.GetForegroundWindow()
217218
ifnothwnd:
218219
return
219-
hwnd_class_name=win32gui.GetClassName(hwnd)
220-
221-
# Check if the foreground window is the desktop
222-
ifhwnd_class_namein ["Progman","WorkerW"]:
220+
221+
class_name=win32gui.GetClassName(hwnd)
222+
ifclass_namein ("Progman","WorkerW","XamlWindow"):
223223
return
224-
# Get the window rectangle: (left, top, right, bottom) then convert to (x, y, width, height)
225-
rect=win32gui.GetWindowRect(hwnd)
226-
window_rect= (rect[0],rect[1],rect[2]-rect[0],rect[3]-rect[1])
227-
228-
# Get the primary screen geometry
224+
left,top,right,bottom=win32gui.GetWindowRect(hwnd)
225+
window_rect= (left,top,right-left,bottom-top)
226+
229227
screen_geometry=self.screen().geometry()
230228
screen_rect= (
231229
screen_geometry.x(),
@@ -234,19 +232,17 @@ def is_foreground_fullscreen(self):
234232
screen_geometry.height()
235233
)
236234

237-
# Determine fullscreen state
238-
is_fullscreen=(window_rect==screen_rect)
239-
# Cache the previous state so we only update if it changes
240-
ifhasattr(self,"_prev_fullscreen_state")andself._prev_fullscreen_state==is_fullscreen:
235+
self.dpi=self.screen().devicePixelRatio()
236+
scaled_screen_rect=screen_rect[:2]+tuple(round(dim*self.dpi)fordiminscreen_rect[2:])
237+
is_fullscreen= (window_rect==scaled_screen_rect)
238+
ifgetattr(self,"_prev_fullscreen_state",None)==is_fullscreen:
241239
return
240+
242241
self._prev_fullscreen_state=is_fullscreen
243-
# Update visibility only when necessary
244-
ifis_fullscreen:
245-
ifself.isVisible():
246-
self.hide()
247-
else:
248-
ifnotself.isVisible():
249-
self.show()
242+
ifis_fullscreenandself.isVisible():
243+
self.hide()
244+
elifnotis_fullscreenandnotself.isVisible():
245+
self.show()
250246

251247

252248
defdetect_os_theme(self)->bool:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp