diff --git a/docs/source/conf.py b/docs/source/conf.py index 2172349..7121443 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -8,6 +8,7 @@ import re import time +from urllib.request import urlretrieve project = 'EWMHlib' year = time.strftime("%Y") @@ -42,8 +43,6 @@ # -- Copy the modules documentation ------------------------------------------ # https://stackoverflow.com/questions/66495200/is-it-possible-to-include-external-rst-files-in-my-documentation -from urllib.request import urlretrieve - urlretrieve( "https://raw.githubusercontent.com/kalmat/ewmhlib/master/README.md", "index.md" diff --git a/src/ewmhlib/Props/__init__.py b/src/ewmhlib/Props/__init__.py index e05ec79..b6ac315 100644 --- a/src/ewmhlib/Props/__init__.py +++ b/src/ewmhlib/Props/__init__.py @@ -1,4 +1,4 @@ #!/usr/bin/python -from ._props import (Root, DesktopLayout, Window, WindowType, State, StateAction, - MoveResize, DataFormat, Mode, StackMode, HintAction) +from ._props import (Root as Root, DesktopLayout as DesktopLayout, Window as Window, WindowType as WindowType, State as State, StateAction as StateAction, + MoveResize as MoveResize, DataFormat as DataFormat, Mode as Mode, StackMode as StackMode, HintAction as HintAction) diff --git a/src/ewmhlib/Structs/__init__.py b/src/ewmhlib/Structs/__init__.py index aec0fd5..679121f 100644 --- a/src/ewmhlib/Structs/__init__.py +++ b/src/ewmhlib/Structs/__init__.py @@ -1,3 +1,3 @@ #!/usr/bin/python -from ._structs import (ScreensInfo, DisplaysInfo, WmHints, Aspect, WmNormalHints) +from ._structs import (ScreensInfo as ScreensInfo, DisplaysInfo as DisplaysInfo, WmHints as WmHints, Aspect as Aspect, WmNormalHints as WmNormalHints) diff --git a/src/ewmhlib/__init__.py b/src/ewmhlib/__init__.py index 389454e..3bc4d2f 100644 --- a/src/ewmhlib/__init__.py +++ b/src/ewmhlib/__init__.py @@ -1,6 +1,15 @@ #!/usr/bin/python from importlib.metadata import version as _importlib_version +from ._main import (displaysCount, getDisplays, getDisplaysInfo, getRoots, + defaultDisplay, defaultScreen, defaultRoot, defaultEwmhRoot, + getDisplayFromRoot, getScreenFromRoot, + getDisplayFromWindow, getScreenFromWindow, getRootFromWindow, + getProperty, getPropertyValue, changeProperty, sendMessage, + EwmhRoot, EwmhWindow, + Props, Structs + ) + __all__ = [ "version", "displaysCount", "getDisplays", "getDisplaysInfo", "getRoots", "defaultDisplay", "defaultScreen", "defaultRoot", "defaultEwmhRoot", @@ -14,16 +23,7 @@ __version__ = _importlib_version("ewmhlib") -def version(numberOnly: bool = True): +def version(numberOnly: bool = True) -> str: """Returns the current version of ewmhlib module, in the form ''x.x.xx'' as string""" return ("" if numberOnly else "EWMHlib-")+__version__ - -from ._main import (displaysCount, getDisplays, getDisplaysInfo, getRoots, - defaultDisplay, defaultScreen, defaultRoot, defaultEwmhRoot, - getDisplayFromRoot, getScreenFromRoot, - getDisplayFromWindow, getScreenFromWindow, getRootFromWindow, - getProperty, getPropertyValue, changeProperty, sendMessage, - EwmhRoot, EwmhWindow, - Props, Structs - ) diff --git a/src/ewmhlib/_ewmhlib.py b/src/ewmhlib/_ewmhlib.py index 8ffea58..4482bef 100644 --- a/src/ewmhlib/_ewmhlib.py +++ b/src/ewmhlib/_ewmhlib.py @@ -2,7 +2,9 @@ from __future__ import annotations import sys -assert sys.platform == "linux" + +if sys.platform != "linux": + raise OSError(f"Cannot import {__name__} on {sys.platform}") import array import os @@ -14,14 +16,26 @@ import Xlib.protocol import Xlib.X import Xlib.Xatom -import Xlib.Xutil -import Xlib.ext import Xlib.xobject +import Xlib.Xutil from Xlib.xobject.drawable import Window as XWindow -from .Props import (Root, DesktopLayout, Window, WindowType, State, StateAction, - MoveResize, DataFormat, Mode, HintAction) -from .Structs import DisplaysInfo, ScreensInfo, WmHints, Aspect, WmNormalHints +from .Props import ( + DataFormat, + DesktopLayout, + HintAction, + Mode, + MoveResize, + Root, + State, + StateAction, + Window, + WindowType, +) +from .Structs import Aspect, DisplaysInfo, ScreensInfo, WmHints, WmNormalHints + +if TYPE_CHECKING: + from Xlib.protocol.rq import Struct if TYPE_CHECKING: from Xlib.protocol.rq import Struct @@ -2713,7 +2727,7 @@ def findit(hwnd: XWindow) -> None: # input_pm: Xlib.xobject.drawable.Pixmap = xWin.create_pixmap(width, height, 1) # gc: Xlib.xobject.fontable.GC = input_pm.create_gc(foreground=0, background=0) # input_pm.fill_rectangle(gc.id, 0, 0, width, height) -# xWin.shape_mask(Xlib.ext.shape.SO.Set, Xlib.ext.shape.SK.Input, 0, 0, input_pm) # type: ignore[attr-defined] # pyright: ignore[reportGeneralTypeIssues, reportUnknownMemberType] +# xWin.shape_mask(Xlib.ext.shape.SO.Set, Xlib.ext.shape.SK.Input, 0, 0, input_pm) # # xWin.shape_select_input(0) # # xWin.map() diff --git a/src/ewmhlib/_main.py b/src/ewmhlib/_main.py index fb787d3..1460421 100644 --- a/src/ewmhlib/_main.py +++ b/src/ewmhlib/_main.py @@ -1,11 +1,13 @@ #!/usr/bin/python -from ._ewmhlib import (displaysCount, getDisplays, getDisplaysInfo, getRoots, - defaultDisplay, defaultScreen, defaultRoot, defaultEwmhRoot, - getDisplayFromRoot, getScreenFromRoot, - getDisplayFromWindow, getScreenFromWindow, getRootFromWindow, - getProperty, getPropertyValue, changeProperty, sendMessage, - EwmhRoot, EwmhWindow +#!/usr/bin/python + +from ._ewmhlib import (displaysCount as displaysCount, getDisplays as getDisplays, getDisplaysInfo as getDisplaysInfo, getRoots as getRoots, + defaultDisplay as defaultDisplay, defaultScreen as defaultScreen, defaultRoot as defaultRoot, defaultEwmhRoot as defaultEwmhRoot, + getDisplayFromRoot as getDisplayFromRoot, getScreenFromRoot as getScreenFromRoot, + getDisplayFromWindow as getDisplayFromWindow, getScreenFromWindow as getScreenFromWindow, getRootFromWindow as getRootFromWindow, + getProperty as getProperty, getPropertyValue as getPropertyValue, changeProperty as changeProperty, sendMessage as sendMessage, + EwmhRoot as EwmhRoot, EwmhWindow as EwmhWindow ) -from . import Props -from . import Structs +from . import Props as Props +from . import Structs as Structs