]> git.mar77i.info Git - zenbook_conf/commitdiff
also call event-specific event handlers on UIParent subclasses, drag along Stylus...
authormar77i <mar77i@protonmail.ch>
Fri, 27 Dec 2024 09:24:47 +0000 (10:24 +0100)
committermar77i <mar77i@protonmail.ch>
Fri, 27 Dec 2024 09:24:47 +0000 (10:24 +0100)
ui.py
xinput.py

diff --git a/ui.py b/ui.py
index 5f8f2084494704ce4bfd9f28594852d1d364d9b2..c4300ddd1d7bee53d0ac071bb78053584412a458 100644 (file)
--- a/ui.py
+++ b/ui.py
@@ -29,7 +29,7 @@ class UIParent:
                 self.running = False
                 return False
         method_name = f"handle_{pygame.event.event_name(ev.type).lower()}"
-        for child in self.children:
+        for child in (self, *self.children):
             if not hasattr(child, method_name):
                 continue
             getattr(child, method_name)(ev)
index 6a78d0db57e5d128c581d12f7c9261b522f77752..5c6f4ef4e4bd9b516f67db31ccdf7b168a4abaad 100644 (file)
--- a/xinput.py
+++ b/xinput.py
@@ -13,6 +13,11 @@ class XinputConf:
             "output": "eDP-1",
             "type": "touchpad",
         },
+        "ELAN9008:00 04F3:425B Stylus": {
+            "output": "eDP-1",
+            "type": "stylus",
+            "ignore_result": True,
+        },
         "ELAN9008:00 04F3:425B Stylus Pen (0)": {
             "output": "eDP-1",
             "type": "stylus",
@@ -25,6 +30,11 @@ class XinputConf:
             "output": "eDP-2",
             "type": "touchpad",
         },
+        "ELAN9009:00 04F3:425A Stylus": {
+            "output": "eDP-2",
+            "type": "stylus",
+            "ignore_result": True,
+        },
         "ELAN9009:00 04F3:425A Stylus Pen (0)": {
             "output": "eDP-2",
             "type": "stylus",
@@ -63,7 +73,10 @@ class XinputConf:
             enable = device["enabled"]
         if enable:
             subprocess.run(["xinput", "enable", device["id"]])
-            subprocess.run(["xinput", "map-to-output", device["id"], device["output"]])
+            subprocess.run(
+                ["xinput", "map-to-output", device["id"], device["output"]],
+                stderr=subprocess.DEVNULL if device.get("ignore_result") else None,
+            )
         else:
             subprocess.run(["xinput", "disable", device["id"]])
         self.conf = self.get_conf()
@@ -91,7 +104,11 @@ class XinputConf:
         outputs = {o["name"]: o for o in self.xrandr_conf.get_relevant_outputs()}
         state = None
         for device in self.conf:
-            if device["type"] != device_type or not outputs[device["output"]]["active"]:
+            if (
+                device["type"] != device_type
+                or not outputs[device["output"]]["active"]
+                or device.get("ignore_result")
+            ):
                 continue
             new_state = device["enabled"]
             if state is not None and new_state != state: