Skip to content

Commit 9483058

Browse files
committed
ALL: Added getMonitor() as alias for getDisplay()
LINUX: Added ewmhlib as separate module. Fixed getAllMonitors() returns empty list if XDG_CURRENT_DESKTOP is not set. Improved getClientFrame() and getExtraFrameSize() by properly using _NET_EXTENTS and GTK_EXTENTS, Added a new Window.LEGACY_NAME="WM_NAME" property (for apps not setting _NET_WM_NAME) MACOS: Removed MacOSNSWindow. Fixed lowerWindow(), raiseWindow() and isAlive. Fixed test_pywinctl.py to avoid crashing in small screens
1 parent 7a985a7 commit 9483058

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed
-213 KB
Binary file not shown.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
install_requires=[
3939
"pywin32>=302; sys_platform == 'win32'",
4040
"python-xlib>=0.21; sys_platform == 'linux'",
41-
"ewmhlib>=0.1; sys_platform == 'linux'",
41+
"ewmhlib>=0.2; sys_platform == 'linux'",
4242
"pyobjc>=8.1; sys_platform == 'darwin'",
4343
"typing_extensions>=4.4.0",
4444
"pywinbox>=0.7",
45-
"pymonctl>=0.8"
45+
"pymonctl>=0.92"
4646
],
4747
extras_require={
4848
'dev': [

src/pywinctl/_pywinctl_macos.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -909,11 +909,15 @@ def lowerWindow(self):
909909
try
910910
tell application "System Events"
911911
set procList to name of every application process whose background only is false
912+
set frontAppName to name of first application process whose frontmost is true
912913
end tell
913914
repeat with procName in procList
914915
if procName is not equal to appName then
915916
try
916917
activate application procName
918+
if frontAppName is not equal to appName then
919+
activate application frontAppName
920+
end if
917921
end try
918922
end if
919923
end repeat
@@ -1856,11 +1860,6 @@ def run(self):
18561860
while not self._kill.is_set():
18571861
if self._hWnd.isActive:
18581862
self._hWnd.lowerWindow()
1859-
for app in self._apps:
1860-
try:
1861-
app.activateWithOptions_(Quartz.NSApplicationActivateIgnoringOtherApps)
1862-
except:
1863-
continue
18641863
self._kill.wait(self._interval)
18651864

18661865
def kill(self):

tests/test_pywinctl.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import subprocess
66
import sys
77
import time
8-
from typing import Any, cast
98

109
import pywinctl
1110

@@ -204,12 +203,12 @@ def activeCB(isActive):
204203
test_moveresize('centerx', 900)
205204
print("MOVE CENTERY", 600)
206205
test_moveresize('centery', 600)
207-
print("RESIZE WIDTH", 500)
208-
test_moveresize('width', 500)
209-
print("RESIZE HEIGHT", 400)
210-
test_moveresize('height', 400)
211-
print("RESIZE", 540, 410)
212-
test_moveresize('size', (540, 410))
206+
print("RESIZE WIDTH", 620)
207+
test_moveresize('width', 620)
208+
print("RESIZE HEIGHT", 410)
209+
test_moveresize('height', 410)
210+
print("RESIZE", 640, 420)
211+
test_moveresize('size', (640, 420))
213212

214213
# Test window stacking
215214
print("LOWER WINDOW")
@@ -254,26 +253,30 @@ def activeCB(isActive):
254253
assert npw.isChild(parent)
255254
children = npw.getChildren()
256255
for child in children:
257-
if child:
258-
if isinstance(child, int):
259-
print("WINDOW CHILD:", child, npw.isParent(child))
260-
else:
261-
print("WINDOW CHILD:", child.id, npw.isParent(child))
256+
if child and isinstance(child, int):
257+
print("WINDOW CHILD:", child, npw.isParent(child))
262258

263259
# Test menu options
264260
print("MENU INFO (WORKING IN WINDOWS 10 AND MACOS, BUT NOT IN WINDOWS 11 NOR LINUX)")
265261
if sys.platform in ("win32", "darwin"):
262+
# Show "About" dialog. Using numbers instead of menu/option names since they are language-dependent
263+
if sys.platform == "darwin":
264+
targetSubmenu = 1
265+
targetOption = 0
266+
else:
267+
targetSubmenu = 4
268+
targetOption = 2
266269
menu = npw.menu.getMenu()
267270
submenu = {}
268271
for i, key in enumerate(menu):
269-
if i == 1:
272+
if i == targetSubmenu:
270273
submenu = menu[key].get("entries", {})
271274
break
272-
option: dict[str, Any] | None = None
275+
option = {}
273276
for i, key in enumerate(submenu):
274-
if i == 0:
275-
option = cast("dict[str, Any]", submenu[key])
276-
277+
if i == targetOption:
278+
option = submenu[key]
279+
break
277280
if option:
278281
print("CLICK OPTION")
279282
npw.menu.clickMenuItem(wID=option.get("wID", ""))

0 commit comments

Comments
 (0)