|
13 | 13 | import time |
14 | 14 | import tkinter as tk |
15 | 15 | from collections.abc import Callable |
16 | | -from typing import Iterable |
| 16 | +from typing import Iterable, TYPE_CHECKING |
| 17 | +if TYPE_CHECKING: |
| 18 | + from typing_extensions import TypedDict |
| 19 | +else: |
| 20 | + # Only needed if the import from typing_extensions is used outside of annotations |
| 21 | + from typing import TypedDict |
17 | 22 |
|
18 | 23 | import ewmh |
19 | 24 | import Xlib.display |
|
22 | 27 | import Xlib.X |
23 | 28 | import Xlib.Xatom |
24 | 29 | import Xlib.Xutil |
25 | | -from typing_extensions import TypedDict |
26 | 30 | from Xlib.xobject.drawable import Window |
27 | 31 |
|
28 | 32 | from pywinctl import BaseWindow, Point, Re, Rect, Size, _WinWatchDog, pointInRect |
29 | 33 |
|
30 | 34 | DISP = Xlib.display.Display() |
31 | 35 | SCREEN = DISP.screen() |
32 | | -ROOT = SCREEN.root |
| 36 | +ROOT: Window = SCREEN.root |
33 | 37 | EWMH = ewmh.EWMH(_display=DISP, root=ROOT) |
34 | 38 |
|
35 | 39 | # WARNING: Changes are not immediately applied, specially for hide/show (unmap/map) |
@@ -93,6 +97,10 @@ def getActiveWindow(): |
93 | 97 | win_id = EWMH.getActiveWindow() |
94 | 98 | if win_id: |
95 | 99 | return LinuxWindow(win_id) |
| 100 | + # ret = ROOT.get_full_property(DISP.get_atom('_NET_ACTIVE_WINDOW', False), Xlib.X.AnyPropertyType) |
| 101 | + # if ret and ret.value: |
| 102 | + # win_id = ret.value[0] |
| 103 | + # return LinuxWindow(win_id) |
96 | 104 | return None |
97 | 105 |
|
98 | 106 |
|
@@ -128,6 +136,7 @@ def getAllWindows(): |
128 | 136 | """ |
129 | 137 | windows = EWMH.getClientListStacking() |
130 | 138 | return [window for window in __remove_bad_windows(windows)] |
| 139 | + # return [window for window in __remove_bad_windows(ROOT.get_full_property(DISP.get_atom('_NET_CLIENT_LIST_STACKING', False), Xlib.X.AnyPropertyType).value)] |
131 | 140 |
|
132 | 141 |
|
133 | 142 | def getAllTitles() -> list[str]: |
@@ -424,6 +433,7 @@ def _rect(self): |
424 | 433 |
|
425 | 434 | def __init__(self, hWnd: Window | int | str): |
426 | 435 | super().__init__() |
| 436 | + print(type(hWnd)) |
427 | 437 | if isinstance(hWnd, int): |
428 | 438 | self._hWnd = DISP.create_resource_object('window', hWnd) |
429 | 439 | elif isinstance(hWnd, str): |
|
0 commit comments