Browse Source

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
pull/2/head
Ali Hatami Tajik 2 years ago
parent
commit
dc9db72e57
  1. 8
      src/scripts/python/changemouse.py
  2. 6
      src/scripts/python/xutil/pointer.py

8
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:

6
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')

Loading…
Cancel
Save