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

Commit1b608d0

Browse files
committed
Fixed some typing, get info of all visible windows to make sure all appears on icons list.
1 parent8e2b32e commit1b608d0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

‎src/core/widgets/yasb/taskbar.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importlogging
2+
fromtypingimportOptional
23
fromsettingsimportDEBUG
34
fromcore.widgets.baseimportBaseWidget
45
fromcore.utils.win32.windowsimportWinEvent
@@ -21,7 +22,9 @@
2122
SystemEventListener=None
2223
logging.warning("Failed to load Win32 System Event Listener")
2324

24-
25+
# Missing from win32con
26+
WS_EX_NOREDIRECTIONBITMAP=0x20_0000
27+
2528
classTaskbarWidget(BaseWidget):
2629
validation_schema=VALIDATION_SCHEMA
2730
update_event=pyqtSignal(int,WinEvent)
@@ -187,10 +190,8 @@ def _update_label(self, hwnd: int, win_info: dict, event: WinEvent) -> None:
187190
ifself._animation['enabled']:
188191
self._animate_icon(icon_label,start_width=0,end_width=icon_label.sizeHint().width())
189192

190-
def_get_app_icon(self,hwnd:int,title:str,process:dict,event:WinEvent)->None:
193+
def_get_app_icon(self,hwnd:int,title:str,process:dict,event:WinEvent)->Optional[QPixmap]:
191194
try:
192-
ifhwnd!=win32gui.GetForegroundWindow():
193-
return
194195
pid=process["pid"]
195196

196197
ifevent!=WinEvent.WinEventOutOfContext:
@@ -201,7 +202,7 @@ def _get_app_icon(self, hwnd: int, title:str, process: dict, event: WinEvent) ->
201202
else:
202203
icon_img=get_window_icon(hwnd,self.dpi)
203204
ificon_img:
204-
icon_img=icon_img.resize((int(self._label_icon_size*self.dpi),int(self._label_icon_size*self.dpi)),Image.LANCZOS).convert("RGBA")
205+
icon_img=icon_img.resize((int(self._label_icon_size*self.dpi),int(self._label_icon_size*self.dpi)),Image.Resampling.LANCZOS).convert("RGBA")
205206
else:
206207
# UWP apps I hate it
207208
ifprocess["name"]=="ApplicationFrameHost.exe":
@@ -211,9 +212,9 @@ def _get_app_icon(self, hwnd: int, title:str, process: dict, event: WinEvent) ->
211212
return
212213
else:
213214
self._update_retry_count=0
215+
ificon_img:
214216
ifnotDEBUG:
215217
self._icon_cache[(hwnd,title,pid)]=icon_img
216-
ificon_img:
217218
qimage=QImage(icon_img.tobytes(),icon_img.width,icon_img.height,QImage.Format.Format_RGBA8888)
218219
pixmap=QPixmap.fromImage(qimage)
219220
else:
@@ -223,22 +224,23 @@ def _get_app_icon(self, hwnd: int, title:str, process: dict, event: WinEvent) ->
223224
ifDEBUG:
224225
logging.exception(f"Failed to get icons for window with HWND{hwnd} emitted by event{event}")
225226

226-
defget_visible_windows(self,hwnd:int,win_info:dict,event:WinEvent)->None:
227+
defget_visible_windows(self,_:int,win_info:dict,event:WinEvent)->list[tuple[str,int,Optional[QPixmap],WinEvent]]:
227228
process=win_info['process']
228229
defis_window_visible_on_taskbar(hwnd):
229-
ifwin32gui.IsWindowVisible(hwnd)andwin32gui.GetWindowText(hwnd):
230+
ifwin32gui.IsWindowVisible(hwnd):
230231
ex_style=win32gui.GetWindowLong(hwnd,win32con.GWL_EXSTYLE)
231-
ifnot (ex_style&win32con.WS_EX_TOOLWINDOW):
232+
ifnot (ex_style&win32con.WS_EX_TOOLWINDOWorex_style==WS_EX_NOREDIRECTIONBITMAP):
232233
returnTrue
233234
returnFalse
234235

235236
visible_windows= []
236237

237-
defenum_windows_proc(hwnd,lParam):
238+
defenum_windows_proc(hwnd,_):
238239
ifis_window_visible_on_taskbar(hwnd):
239240
title=win32gui.GetWindowText(hwnd)
240241
icon=self._get_app_icon(hwnd,title,process,event)
241-
visible_windows.append((title,hwnd,icon ,process))
242+
iftitleandicon:
243+
visible_windows.append((title,hwnd,icon,process))
242244
returnTrue
243245
win32gui.EnumWindows(enum_windows_proc,None)
244246
returnvisible_windows

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp