From dc9db72e5742de29d010e326952b98a551a6851e Mon Sep 17 00:00:00 2001 From: Ali Hatami Tajik Date: Mon, 27 Feb 2023 13:08:10 +0330 Subject: [PATCH] Fix mouse change bug BUG: script does not take effect when script is run --- Test Scenario: Two mouse are attached to the different masters and then we execute the script Expected Behavior: both mouses reattach to the Virtual core Problem: filter in the for-loop gathered all masters not slaves --- src/scripts/python/changemouse.py | 8 ++++---- src/scripts/python/xutil/pointer.py | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/scripts/python/changemouse.py b/src/scripts/python/changemouse.py index 2f18a7c..ec4eedc 100755 --- a/src/scripts/python/changemouse.py +++ b/src/scripts/python/changemouse.py @@ -2,15 +2,15 @@ """Change mouse script -Whenever a mouse is changed to the system, this script will be executed. These +Whenever a mouse is changed to the system, this script will be executed. These are the rules: - + All regular mouses should connect to the "Virtual core pointer" of the + + All regular mouses should connect to the "Virtual core pointer" of the system + Touchpanel should be connected to the master "touch-pointer" NOTE: master "touch-pointer" should be available on the event of adding the mouse. This could be reached by adding this master to the system on boot. - + Steps: + List all pointer as we don't know what pointer is added to the system + group them by their usage by name rules (As if the pointer is eGalax @@ -32,7 +32,7 @@ if __name__ == "__main__": pointers = xup.get_pointers() # TODO filter functionality inside utilities core_master = list(filter(lambda x: "Virtual core" in x.name, pointers))[0] - for pointer in filter(lambda x: not x.slave, pointers): + for pointer in filter(lambda x: x.slave, pointers): if not "eGalax" in pointer.name: com.reattach(pointer.id, core_master.id) else: diff --git a/src/scripts/python/xutil/pointer.py b/src/scripts/python/xutil/pointer.py index 8330b7a..a6afbe1 100644 --- a/src/scripts/python/xutil/pointer.py +++ b/src/scripts/python/xutil/pointer.py @@ -37,6 +37,10 @@ class Pointer(XInput): def __init__(self, name, id, is_master: bool) -> None: super().__init__(name, id, is_master) + @property + def slave(self): + return not self.is_master + def get_short_pointer(id) -> Pointer: """Generates Pointer object corresponding to id (short attrs) @@ -57,7 +61,7 @@ def get_short_pointer(id) -> Pointer: is_master = "master" in props return Pointer( name.strip(), - props.split(maxsplit=1), + props.split(maxsplit=1)[0], is_master) else: raise TypeError(f'id[{id}] is not a pointer id')