diff --git a/dist/PyWinCtl-dev0.1-py3-none-any.whl b/dist/PyWinCtl-dev0.1-py3-none-any.whl deleted file mode 100644 index c9f1e9e..0000000 Binary files a/dist/PyWinCtl-dev0.1-py3-none-any.whl and /dev/null differ diff --git a/setup.py b/setup.py index fe4642d..c8759fd 100644 --- a/setup.py +++ b/setup.py @@ -38,11 +38,11 @@ install_requires=[ "pywin32>=302; sys_platform == 'win32'", "python-xlib>=0.21; sys_platform == 'linux'", - "ewmhlib>=0.1; sys_platform == 'linux'", + "ewmhlib>=0.2; sys_platform == 'linux'", "pyobjc>=8.1; sys_platform == 'darwin'", "typing_extensions>=4.4.0", "pywinbox>=0.7", - "pymonctl>=0.8" + "pymonctl>=0.92" ], extras_require={ 'dev': [ diff --git a/src/pywinctl/_pywinctl_macos.py b/src/pywinctl/_pywinctl_macos.py index b0088b1..f5b385b 100644 --- a/src/pywinctl/_pywinctl_macos.py +++ b/src/pywinctl/_pywinctl_macos.py @@ -909,11 +909,15 @@ def lowerWindow(self): try tell application "System Events" set procList to name of every application process whose background only is false + set frontAppName to name of first application process whose frontmost is true end tell repeat with procName in procList if procName is not equal to appName then try activate application procName + if frontAppName is not equal to appName then + activate application frontAppName + end if end try end if end repeat @@ -1856,11 +1860,6 @@ def run(self): while not self._kill.is_set(): if self._hWnd.isActive: self._hWnd.lowerWindow() - for app in self._apps: - try: - app.activateWithOptions_(Quartz.NSApplicationActivateIgnoringOtherApps) - except: - continue self._kill.wait(self._interval) def kill(self): diff --git a/tests/test_pywinctl.py b/tests/test_pywinctl.py index 5e386ae..5ab2a79 100644 --- a/tests/test_pywinctl.py +++ b/tests/test_pywinctl.py @@ -5,7 +5,6 @@ import subprocess import sys import time -from typing import Any, cast import pywinctl @@ -204,12 +203,12 @@ def activeCB(isActive): test_moveresize('centerx', 900) print("MOVE CENTERY", 600) test_moveresize('centery', 600) - print("RESIZE WIDTH", 500) - test_moveresize('width', 500) - print("RESIZE HEIGHT", 400) - test_moveresize('height', 400) - print("RESIZE", 540, 410) - test_moveresize('size', (540, 410)) + print("RESIZE WIDTH", 620) + test_moveresize('width', 620) + print("RESIZE HEIGHT", 410) + test_moveresize('height', 410) + print("RESIZE", 640, 420) + test_moveresize('size', (640, 420)) # Test window stacking print("LOWER WINDOW") @@ -254,26 +253,30 @@ def activeCB(isActive): assert npw.isChild(parent) children = npw.getChildren() for child in children: - if child: - if isinstance(child, int): - print("WINDOW CHILD:", child, npw.isParent(child)) - else: - print("WINDOW CHILD:", child.id, npw.isParent(child)) + if child and isinstance(child, int): + print("WINDOW CHILD:", child, npw.isParent(child)) # Test menu options print("MENU INFO (WORKING IN WINDOWS 10 AND MACOS, BUT NOT IN WINDOWS 11 NOR LINUX)") if sys.platform in ("win32", "darwin"): + # Show "About" dialog. Using numbers instead of menu/option names since they are language-dependent + if sys.platform == "darwin": + targetSubmenu = 1 + targetOption = 0 + else: + targetSubmenu = 4 + targetOption = 2 menu = npw.menu.getMenu() submenu = {} for i, key in enumerate(menu): - if i == 1: + if i == targetSubmenu: submenu = menu[key].get("entries", {}) break - option: dict[str, Any] | None = None + option = {} for i, key in enumerate(submenu): - if i == 0: - option = cast("dict[str, Any]", submenu[key]) - + if i == targetOption: + option = submenu[key] + break if option: print("CLICK OPTION") npw.menu.clickMenuItem(wID=option.get("wID", ""))