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