From 0f2097ee6c09cf6b649ea9492084ad8f6f5fdd06 Mon Sep 17 00:00:00 2001 From: ReaperMantis <> Date: Sun, 10 Sep 2023 17:10:26 -0400 Subject: [PATCH 1/2] modified: src/ewmhlib/Props.py Added the new Window.LEGACY_NAME="WM_NAME" property. This can be used to retain compatibility with older programs that do not set _NET_WM_NAME. modified: src/ewmhlib/_ewmhlib.py Updated the logic for getName to now check for Window.LEGACY_NAME if the result of checking for Window.NAME does not return a value. --- src/ewmhlib/Props.py | 1 + src/ewmhlib/_ewmhlib.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/ewmhlib/Props.py b/src/ewmhlib/Props.py index 1efca2c..79baad1 100644 --- a/src/ewmhlib/Props.py +++ b/src/ewmhlib/Props.py @@ -40,6 +40,7 @@ class DesktopLayout(IntEnum): class Window: NAME = "_NET_WM_NAME" + LEGACY_NAME = "WM_NAME" VISIBLE_NAME = "_NET_WM_VISIBLE_NAME" ICON_NAME = "_NET_WM_ICON_NAME" VISIBLE_ICON_NAME = "_NET_WM_VISIBLE_ICON_NAME" diff --git a/src/ewmhlib/_ewmhlib.py b/src/ewmhlib/_ewmhlib.py index dc77e0f..5ab8976 100644 --- a/src/ewmhlib/_ewmhlib.py +++ b/src/ewmhlib/_ewmhlib.py @@ -1066,6 +1066,10 @@ def getName(self) -> Optional[str]: """ ret: Optional[Xlib.protocol.request.GetProperty] = self.getProperty(Window.NAME) res: Optional[Union[List[int], List[str]]] = getPropertyValue(ret, display=self.display) + if res: + return str(res[0]) + ret: Optional[Xlib.protocol.request.GetProperty] = self.getProperty(Window.LEGACY_NAME) + res: Optional[Union[List[int], List[str]]] = getPropertyValue(ret, display=self.display) if res: return str(res[0]) return None From a26c7f81007e16791203a6b5d753dc9a76acb377 Mon Sep 17 00:00:00 2001 From: anthony Date: Tue, 12 Sep 2023 08:56:49 -0400 Subject: [PATCH 2/2] Remove the second typing for ret and res vars. --- src/ewmhlib/_ewmhlib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ewmhlib/_ewmhlib.py b/src/ewmhlib/_ewmhlib.py index 5ab8976..457a87e 100644 --- a/src/ewmhlib/_ewmhlib.py +++ b/src/ewmhlib/_ewmhlib.py @@ -1068,8 +1068,8 @@ def getName(self) -> Optional[str]: res: Optional[Union[List[int], List[str]]] = getPropertyValue(ret, display=self.display) if res: return str(res[0]) - ret: Optional[Xlib.protocol.request.GetProperty] = self.getProperty(Window.LEGACY_NAME) - res: Optional[Union[List[int], List[str]]] = getPropertyValue(ret, display=self.display) + ret = self.getProperty(Window.LEGACY_NAME) + res = getPropertyValue(ret, display=self.display) if res: return str(res[0]) return None