Skip to content

Commit d011545

Browse files
committed
LINUX: Added experimental Wayland support (only if unsafe mode enabled and only for some apps). Fixed Xlib's get_wm_name() not working for some apps/windows.
MACOS: Tested OK in multi-monitor setups (based on PyWinBox and PyMonCtl features). ALL: getDisplay() method returns a list of monitors
1 parent 1529a9a commit d011545

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

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

94 Bytes
Binary file not shown.

src/ewmhlib/_ewmhlib.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ def changeProperty(self, prop: Union[str, int], data: Union[List[int], str],
10491049
:param prop: Property/atom of the event in int or str format
10501050
:param data: Data related to the event. It can be a string or a list of up to 5 integers
10511051
:param prop_type: Property type (e.g. X.AnyPropertyType or Xatom.STRING)
1052-
:param propMode: whether to Replace/Append/Prepend (Mode.*) the property in relation to the rest of
1052+
:param propMode: whether to Replace/Append/Prepend (Mode.*) the property in respect to the rest of
10531053
existing properties
10541054
"""
10551055
changeProperty(self.xWindow, prop, data, prop_type, propMode, self.display)
@@ -1076,7 +1076,7 @@ def setName(self, name: str):
10761076
10771077
:param name: new name as string
10781078
"""
1079-
self.xWindow.set_wm_name(name)
1079+
self.changeProperty(Window.NAME, name)
10801080

10811081
def getVisibleName(self) -> Optional[str]:
10821082
"""
@@ -2617,6 +2617,7 @@ def findit(hwnd: XWindow) -> None:
26172617
children = []
26182618
for child in children:
26192619
try:
2620+
# This returns empty name in some cases... must use getProperty!!!!
26202621
ret: Optional[str] = child.get_wm_name()
26212622
except:
26222623
ret = None

src/pywinctl/_pywinctl_linux.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import Xlib.ext
2424
from Xlib.xobject.drawable import Window as XWindow
2525

26-
from pywinctl._main import BaseWindow, Re, _WatchDog, _findMonitorName, getAllScreens, getScreenSize, getWorkArea, displayWindowsUnderMouse
26+
from ._main import BaseWindow, Re, _WatchDog, _findMonitorName, getAllScreens, getScreenSize, getWorkArea, displayWindowsUnderMouse
2727
from pywinbox import Box, Size, Point, Rect, pointInBox
2828
from ewmhlib import Props, RootWindow, EwmhWindow, defaultRootWindow
2929
from ewmhlib._ewmhlib import _xlibGetAllWindows
@@ -50,12 +50,14 @@ def getActiveWindow() -> Optional[LinuxWindow]:
5050
"""
5151
Get the currently active (focused) Window in default root
5252
53+
WAYLAND
5354
This will not work on Wayland unless you activate unsafe_mode:
5455
- Press alt + f2
5556
- write "lg" (without the quotation marks) and press Enter
5657
- In the command entry box (at the bottom of the window), write "global.context.unsafe_mode = true" (without the quotation marks) and press Enter
5758
- To exit the "lg" program, click on any of the options in the upper right corner, then press Escape (it seems a lg bug!)
5859
- You can set unsafe_mode off again by following the same steps, but in this case, using "global.context.unsafe_mode = false"
60+
Anyway, it will not work with all windows (especially built-in/"official" apps do not populate xid nor X-Window object)
5961
6062
:return: Window object or None
6163
"""
@@ -94,12 +96,14 @@ def getAllWindows():
9496
"""
9597
Get the list of Window objects for all visible windows in default root
9698
99+
WAYLAND
97100
This will not work on Wayland unless you activate unsafe_mode:
98101
- Press alt + f2
99102
- write "lg" (without the quotation marks) and press Enter
100103
- In the command entry box (at the bottom of the window), write "global.context.unsafe_mode = true" (without the quotation marks) and press Enter
101-
- To exit the "lg" program, click on any of the options in the upper right corner, and press Escape (it seems a lg bug!)
104+
- To exit the "lg" program, click on any of the options in the upper right corner, then press Escape (it seems a lg bug!)
102105
- You can set unsafe_mode off again by following the same steps, but in this case, using "global.context.unsafe_mode = false"
106+
Anyway, it will not work with all windows (especially built-in/"official" apps do not populate xid nor X-Window object)
103107
104108
:return: list of Window objects
105109
"""

0 commit comments

Comments
 (0)