Skip to content

Commit

Permalink
LINUX: Added experimental Wayland support (only if unsafe mode enable…
Browse files Browse the repository at this point in the history
…d 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
  • Loading branch information
Kalmat committed Sep 6, 2023
1 parent 1529a9a commit d011545
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Binary file modified dist/PyWinCtl-0.1-py3-none-any.whl
Binary file not shown.
5 changes: 3 additions & 2 deletions src/ewmhlib/_ewmhlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ def changeProperty(self, prop: Union[str, int], data: Union[List[int], str],
:param prop: Property/atom of the event in int or str format
:param data: Data related to the event. It can be a string or a list of up to 5 integers
:param prop_type: Property type (e.g. X.AnyPropertyType or Xatom.STRING)
:param propMode: whether to Replace/Append/Prepend (Mode.*) the property in relation to the rest of
:param propMode: whether to Replace/Append/Prepend (Mode.*) the property in respect to the rest of
existing properties
"""
changeProperty(self.xWindow, prop, data, prop_type, propMode, self.display)
Expand All @@ -1076,7 +1076,7 @@ def setName(self, name: str):
:param name: new name as string
"""
self.xWindow.set_wm_name(name)
self.changeProperty(Window.NAME, name)

def getVisibleName(self) -> Optional[str]:
"""
Expand Down Expand Up @@ -2617,6 +2617,7 @@ def findit(hwnd: XWindow) -> None:
children = []
for child in children:
try:
# This returns empty name in some cases... must use getProperty!!!!
ret: Optional[str] = child.get_wm_name()
except:
ret = None
Expand Down
8 changes: 6 additions & 2 deletions src/pywinctl/_pywinctl_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import Xlib.ext
from Xlib.xobject.drawable import Window as XWindow

from pywinctl._main import BaseWindow, Re, _WatchDog, _findMonitorName, getAllScreens, getScreenSize, getWorkArea, displayWindowsUnderMouse
from ._main import BaseWindow, Re, _WatchDog, _findMonitorName, getAllScreens, getScreenSize, getWorkArea, displayWindowsUnderMouse
from pywinbox import Box, Size, Point, Rect, pointInBox
from ewmhlib import Props, RootWindow, EwmhWindow, defaultRootWindow
from ewmhlib._ewmhlib import _xlibGetAllWindows
Expand All @@ -50,12 +50,14 @@ def getActiveWindow() -> Optional[LinuxWindow]:
"""
Get the currently active (focused) Window in default root
WAYLAND
This will not work on Wayland unless you activate unsafe_mode:
- Press alt + f2
- write "lg" (without the quotation marks) and press Enter
- In the command entry box (at the bottom of the window), write "global.context.unsafe_mode = true" (without the quotation marks) and press Enter
- To exit the "lg" program, click on any of the options in the upper right corner, then press Escape (it seems a lg bug!)
- You can set unsafe_mode off again by following the same steps, but in this case, using "global.context.unsafe_mode = false"
Anyway, it will not work with all windows (especially built-in/"official" apps do not populate xid nor X-Window object)
:return: Window object or None
"""
Expand Down Expand Up @@ -94,12 +96,14 @@ def getAllWindows():
"""
Get the list of Window objects for all visible windows in default root
WAYLAND
This will not work on Wayland unless you activate unsafe_mode:
- Press alt + f2
- write "lg" (without the quotation marks) and press Enter
- In the command entry box (at the bottom of the window), write "global.context.unsafe_mode = true" (without the quotation marks) and press Enter
- To exit the "lg" program, click on any of the options in the upper right corner, and press Escape (it seems a lg bug!)
- To exit the "lg" program, click on any of the options in the upper right corner, then press Escape (it seems a lg bug!)
- You can set unsafe_mode off again by following the same steps, but in this case, using "global.context.unsafe_mode = false"
Anyway, it will not work with all windows (especially built-in/"official" apps do not populate xid nor X-Window object)
:return: list of Window objects
"""
Expand Down

0 comments on commit d011545

Please sign in to comment.