|
|
@ -1,9 +1,7 @@ |
|
|
|
import util.x as xutil |
|
|
|
from enum import Enum |
|
|
|
|
|
|
|
|
|
|
|
class XInputState(Enum): |
|
|
|
SLAVE, MASTER, FLOATING = range(3) |
|
|
|
# Pointer states |
|
|
|
SLAVE, MASTER, FLOATING = range(3) |
|
|
|
|
|
|
|
|
|
|
|
class XInput: |
|
|
@ -46,14 +44,14 @@ class Pointer(XInput): |
|
|
|
|
|
|
|
@property |
|
|
|
def slave(self): |
|
|
|
return self.state == XInputState.SLAVE |
|
|
|
return self.state == SLAVE |
|
|
|
|
|
|
|
@property |
|
|
|
def master(self): |
|
|
|
return self.state == XInputState.MASTER |
|
|
|
return self.state == MASTER |
|
|
|
|
|
|
|
def floating(self): |
|
|
|
return self.state == XInputState.FLOATING |
|
|
|
return self.state == FLOATING |
|
|
|
|
|
|
|
|
|
|
|
def get_short_pointer(id) -> Pointer: |
|
|
@ -69,14 +67,14 @@ def get_short_pointer(id) -> Pointer: |
|
|
|
ValueError: if id is not reistered with xinput |
|
|
|
ValueError: if id is not a pointer id |
|
|
|
""" |
|
|
|
desc = xutil.get_list_short(id) |
|
|
|
desc = xutil.get_list_short_with(id) |
|
|
|
name, props = desc.rsplit("id=", 1) |
|
|
|
if "pointer" in props: |
|
|
|
state = XInputState.FLOATING |
|
|
|
state = FLOATING |
|
|
|
if "master" in props: |
|
|
|
state = XInputState.MASTER |
|
|
|
state = MASTER |
|
|
|
elif "slave" in props: |
|
|
|
state = XInputState.SLAVE |
|
|
|
state = SLAVE |
|
|
|
return Pointer(name.strip(), props.split(maxsplit=1)[0], state) |
|
|
|
else: |
|
|
|
raise TypeError(f"id[{id}] is not a pointer id") |
|
|
|