Skip to content

Commit caa98e1

Browse files
committed
LINUX: Added experimental Wayland support (only if unsafe mode enabled and only for some apps). Fixed ewmhlib freezing in Wayland when connecting to display ":1", and added some performance improvements
1 parent d011545 commit caa98e1

23 files changed

+583
-438
lines changed

.github/workflows/type-checking.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
cache: "pip"
27-
cache-dependency-path: "docs/requirements.txt"
28-
- run: pip install -r "docs/requirements.txt"
27+
cache-dependency-path: "requirements.txt"
28+
- run: pip install -r "requirements.txt"
2929
- run: mypy . --python-version=${{ matrix.python-version }}

AUTHORS.txt

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PyWinCtl authors, contributors and maintainers:
1+
PyWinCtl authors, contributors and issues or bugs raisers:
22

33
Kalmat https://github.com/Kalmat
44
Rodrigo Silva (MestreLion) https://github.com/MestreLion
@@ -11,21 +11,7 @@ holychowders https://github.com/holychowders
1111
Anthony Molinaro (djnym) https://github.com/djnym
1212
Kyle King https://github.com/KyleKing
1313
Leonard Bruns https://github.com/roym899
14-
In general, all those who so generously share their work and knowledge on Internet (stackoverflow, github, ...) so I could find a solution or a string to pull!
14+
ReaperMantis https://github.com/ReaperMantis
1515

16-
PyGetWindow (original module): Here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS --
17-
people who have submitted patches, reported bugs, added translations, helped
18-
answer newbie questions, and generally made PyGetWindow that much better:
19-
20-
Al Sweigart https://github.com/asweigart/
21-
arkulinskis https://github.com/arkulinskis
22-
aweffr https://github.com/aweffr
23-
Demonthos https://github.com/Demonthos
24-
Duxxi https://github.com/sjhhh3
25-
EMOholcicka https://github.com/EMOholcicka
26-
Kudria https://github.com/Kudria
27-
lexxish https://github.com/lexxish
28-
李宏杰 https://github.com/lihongjie0209
29-
Randall White
30-
Ronald Oussoren
31-
Steve Newell https://github.com/newellista
16+
In general, all those who so generously share their work and knowledge on Internet (stackoverflow, github, ...)
17+
so I could find a solution or a string to pull!

CHANGES.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
0.1, 2023/02/03 -- LINUX: Added experimental Wayland support (only if unsafe mode enabled and only for some apps).
1+
0.2, 2023/09/09 -- LINUX: Added experimental Wayland support (only if unsafe mode enabled and only for some apps).
2+
Fixed ewmhlib freezing in Wayland when connecting to display ":1", and added some performance improvements
3+
0.1, 2023/09/06 -- LINUX: Fixed all title-related methods (title, getAllTitles, getAllAppsWindowTitles, etc.) returning empty values when using Xlib's get_wm_name()
24
MACOS: Tested OK in multi-monitor setups (based on PyWinBox and PyMonCtl features).
35
ALL: getDisplay() method returns a list of monitors.
46
0.0.50, 2023/02/03 -- ALL: Added PyMonCtl module to improve multi-monitor capabilities, added setParent() method. Reorganized to avoid IDEs showing external and / or private elements
57
WINDOWS: Simplified alwaysOnBottom(), found a smarter way to refresh window after bringing it back with sendBehind()
6-
MACOS: Tested in multi-monitor setups (based on PyWinBox and PyMonCtl features)
78
MACOSNSWINDOW: Added experimental acceptInput() method (not possible in AppleScript version)
89
0.0.45, 2023/08/21 -- ALL: Included PyWinBox module which hopefully better handles multi-monitor setups (macOS tests pending)
910
LINUX: Fixed geometry calculations (thanks to roym899), removed ewmh and pynput dependencies

LICENSE.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Original module (Windows support) Copyright (c) 2015, Al Sweigart
1+
Copyright (c) 2021, Kalmat <[email protected]>
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without
@@ -11,7 +11,7 @@ modification, are permitted provided that the following conditions are met:
1111
this list of conditions and the following disclaimer in the documentation
1212
and/or other materials provided with the distribution.
1313

14-
* Neither the name of the PyAutoGUI nor the names of its
14+
* Neither the name of the PyWinCtl nor the names of its
1515
contributors may be used to endorse or promote products derived from
1616
this software without specific prior written permission.
1717

@@ -26,9 +26,9 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2626
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
--------------------------------------------------------------------------------
29+
------------------------------------------------------------------------------
3030

31-
This fork (Linux and macOS support) Copyright (c) 2021, Kalmat (aka alef) <[email protected]>
31+
Original module (PyGetWindow, Windows support only) Copyright (c) 2015, Al Sweigart
3232
All rights reserved.
3333

3434
Redistribution and use in source and binary forms, with or without
@@ -54,4 +54,5 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5454
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5555
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5656
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58+

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Cross-Platform module to get info on and control windows on screen.
66

77
With PyWinCtl you can retrieve info or control windows from other open applications, as well as use it as a cross-platform toolkit to manipulate your own application windows.
88

9-
This module is a Python 3 evolution from [asweigart's PyGetWindow module](https://github.com/asweigart/PyGetWindow), which adds Linux/X11 and macOS support to the MS Windows-only original module, experimental multi-monitor support, and many additional features; in the hope others can use it, test it or contribute.
9+
This module is a Python 3 evolution from [asweigart's PyGetWindow module](https://github.com/asweigart/PyGetWindow), which adds Linux/X11 and macOS support to the MS Windows-only original module, multi-monitor support, and many additional features; in the hope others can use it, test it or contribute.
1010

11-
My most sincere thanks and acknowledgement to [MestreLion](https://github.com/MestreLion), [super-ibby](https://github.com/super-ibby), [Avasam](https://github.com/Avasam), [macdeport](https://github.com/macdeport) and [holychowders](https://github.com/holychowders) for their help and moral boost.
11+
My most sincere thanks and acknowledgement. amongst many others (see AUTHORS.txt), to [MestreLion](https://github.com/MestreLion), [super-ibby](https://github.com/super-ibby), [Avasam](https://github.com/Avasam), [macdeport](https://github.com/macdeport) and [holychowders](https://github.com/holychowders) for their help and moral boost.
1212

1313
1. [Window Features](#window-features)
1414
1. [Important macOS notice](#macos-notice)
@@ -61,7 +61,7 @@ These functions are available at the moment, in all three platforms (Windows, Li
6161
***Important macOS notice <a name="macos-notice"></a>***
6262

6363
macOS doesn't "like" controlling windows from other apps, so there are two separate classes you can use:
64-
- To control your own application's windows: MacOSNSWindow() is based on NSWindow Objects (you have to pass the NSApp() Object reference).
64+
- To control your own application's windows: MacOSNSWindow() is based on NSWindow Objects (you have to pass the NSApp() and the NSWindow() objects reference).
6565
- To control other applications' windows: MacOSWindow() is based on Apple Script, so it is non-standard, slower and, in some cases, tricky (uses window name as reference, which may change or be duplicate), but it's working fine in most cases. You will likely need to grant permissions on Settings -> Security&Privacy -> Accessibility. ***Notice some applications will have limited Apple Script support or no support at all, so some or even all methods may fail!***
6666

6767
***Important Linux notice <a name="linux-notice"></a>***
@@ -70,7 +70,7 @@ The enormous variety of Linux distributions, Desktop Environments, Window Manage
7070

7171
This module has been tested OK in some X11 setups: Ubuntu/Gnome, Ubuntu/KDE, Ubuntu/Unity, Mint/Cinnamon and Raspbian/LXDE. Except for Mint/Cinnamon and Ubuntu 22.04+, `sendBehind()` method doesn't properly work!
7272

73-
In Wayland (the new GNOME compositor for Ubuntu 22.04+), it is not possible to retrieve the active window nor the list
73+
In Wayland (the new GNOME protocol for Ubuntu 22.04+), it is not possible to retrieve the active window nor the list
7474
of open windows, so `getActiveWindow()` and `getAllWindows()` will not work even though unsafe-mode is
7575
enabled (built-in and "official" applications do not populate their XID nor their X-Window object, so it may work for
7676
other applications like Chrome or your own application windows)
@@ -79,7 +79,7 @@ In case you find problems in other configs, please [open an issue](https://githu
7979

8080
## Window Change Notifications <a name="watchdog"></a>
8181

82-
Window watchdog sub-class, running in a separate Thread, will allow you to define hooks and its callbacks to be notified when some window states change. Accessible through 'watchdog' submodule.
82+
Window watchdog sub-class, running in a separate Thread, will allow to define hooks and its callbacks to be notified when some window states change. Accessible through 'watchdog' submodule.
8383

8484
The watchdog will automatically stop when window doesn't exist anymore or main program quits.
8585

@@ -217,7 +217,7 @@ Note not all windows/applications will have a menu accessible by these methods.
217217

218218
To install this module on your system, you can use pip:
219219

220-
pip install pywinctl
220+
pip3 install pywinctl
221221

222222
or
223223

@@ -244,17 +244,13 @@ If you want to use this code or contribute, you can either:
244244
* Create a fork of the [repository](https://github.com/Kalmat/PyWinCtl), or
245245
* [Download the repository](https://github.com/Kalmat/PyWinCtl/archive/refs/heads/master.zip), uncompress, and open it on your IDE of choice (e.g. PyCharm)
246246

247-
Be sure you install all dependencies described on "docs/requirements.txt" by using pip
247+
Be sure you install all dependencies described on "requirements.txt" by using pip
248248

249249
## TEST <a name="test"></a>
250250

251251
To test this module on your own system, cd to "tests" folder and run:
252252

253-
pytest -vv test_pywinctl.py
254-
255-
or, in case you get an import error, try this:
256-
257-
python3 -m pytest -vv test_pywinctl.py
253+
python3 test_pywinctl.py
258254

259255
MacOSNSWindow class and methods can be tested by running this, also on "tests" folder:
260256

dist/PyWinCtl-0.1-py3-none-any.whl

-98 KB
Binary file not shown.

dist/PyWinCtl-0.2-py3-none-any.whl

99.5 KB
Binary file not shown.

pyrightconfig.json

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Requirements needed for development
2-
# Run: `pip install -r docs/requirements.txt`
3-
# Build/Production requirements are found in ../setup.py
2+
# Run: `pip install -r requirements.txt`
3+
# Build/Production requirements are found in setup.py
44
# Run: `pip install -e .`
55
#
66
# installs dependencies from setup.py, and the package itself,

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
"pywin32>=302; sys_platform == 'win32'",
4040
"python-xlib>=0.21; sys_platform == 'linux'",
4141
"pyobjc>=8.1; sys_platform == 'darwin'",
42-
"pywinbox>=0.5",
43-
"pymonctl>=0.5"
42+
"typing_extensions>=4.4.0",
43+
"pywinbox>=0.6",
44+
"pymonctl>=0.6"
4445
],
4546
extras_require={
4647
'dev': [
4748
"types-setuptools>=65.5",
4849
"mypy>=0.990",
49-
"typing_extensions>=4.4.0",
5050
"types-pywin32>=305.0.0.3",
5151
"types-python-xlib>=0.32"
5252
]

0 commit comments

Comments
 (0)