snegg.eis module

Wrapper module around the libeis C library. This is a thin API wrapper with most of the semantics of the underlying C library preserved. See the libeis documentation for details on each API.

Warning

Most objects in this module are refcounted and automatically destroy the underlying C object when the Python reference is dropped. This may cause all sub-objects in the underlying C object to be destroyed as well. Care must be taken to preserve the Python object across multiple invocations.

class snegg.eis.ButtonEvent(button: int, is_press: bool)

Bases: object

button: int
is_press: bool
class snegg.eis.Client(cobj)

Bases: CObjectWrapper

connect()
disconnect()
property is_sender: bool
property name: str
new_ping() Ping

Create a new Ping object to trigger a roundtrip to the client. Use Ping.ping() to issue the request.

The resulting EventType.PONG event will contain the associated Ping, accessible via Event.pong_ping.

new_seat(*, name: str = 'default seat', capabilities: tuple[~snegg.eis.DeviceCapability, ...] = (<DeviceCapability.POINTER: 1>, <DeviceCapability.POINTER_ABSOLUTE: 2>, <DeviceCapability.KEYBOARD: 4>, <DeviceCapability.TOUCH: 8>, <DeviceCapability.SCROLL: 16>, <DeviceCapability.BUTTON: 32>))
class snegg.eis.ConfigureKeymap(keymap_type: snegg.eis.KeymapType, fd: <class 'IO'>, size: int)

Bases: object

fd: IO
keymap_type: KeymapType
size: int
class snegg.eis.ConfigureRegion(dimension: snegg.eis.Dimension, position: snegg.eis.Position = <factory>, physical_scale: float = 1.0, mapping_id: str | None = None)

Bases: object

dimension: Dimension
mapping_id: str | None = None
physical_scale: float = 1.0
position: Position
class snegg.eis.Device(cobject)

Bases: CObjectWrapper

add()
button_button(button: int, is_press: bool) Device
property capabilities: tuple[DeviceCapability]
property device_type: DeviceType
frame(timestamp: int | None = None) Device
property height: int
property keyboard_get_keymap: Keymap | None
keyboard_key(key: int, is_press: bool) Device
keyboard_xkb_modifiers(mods: XkbModifiersEvent)
property name: str
pause()
pointer_motion(x: float, y: float) Device
pointer_motion_absolute(x: float, y: float) Device
property regions: tuple[Region]
remove()
resume()
property seat: Seat
start_emulating(sequence: int | None = None) Device
stop_emulating() Device
touch_new() Touch
property width: int
class snegg.eis.DeviceCapability(*values)

Bases: IntFlag

BUTTON = 32
KEYBOARD = 4
POINTER = 1
POINTER_ABSOLUTE = 2
SCROLL = 16
TOUCH = 8
static all() int
class snegg.eis.DeviceType(*values)

Bases: IntEnum

PHYSICAL = 2
VIRTUAL = 1
class snegg.eis.Dimension(width: int, height: int)

Bases: object

height: int
width: int
class snegg.eis.Eis

Bases: CObjectWrapper

add_client_fd(fd: IO)
classmethod create_for_fd(path: str | None) Eis
classmethod create_for_socket(path: Path) Eis
dispatch() None
property events: Iterator[Event]
property fd: int
property now: int
exception snegg.eis.Error(message: str, errno: int | None = None)

Bases: Exception

class snegg.eis.Event(cobj)

Bases: CObjectWrapper

property button_event: ButtonEvent
property client: Client
property device: Device | None
property emulating_sequence: int
property event_type: EventType
property key_event: KeyEvent
property pointer_absolute_event: PointerAbsoluteEvent
property pointer_event: PointerEvent
property pong_event: PongEvent

For events of type EventType.PONG, return the associated Ping object. For all other event types, return None.

property scroll_discrete_event: ScrollDiscreteEvent
property scroll_event: ScrollEvent
property scroll_stop_event: ScrollStopEvent
property seat: Seat | None
property seat_event: SeatEvent
property time: int
property touch_event: TouchEvent
class snegg.eis.EventType(*values)

Bases: IntEnum

BUTTON_BUTTON = 500
CLIENT_CONNECT = 1
CLIENT_DISCONNECT = 2
DEVICE_CLOSED = 4
DEVICE_START_EMULATING = 200
DEVICE_STOP_EMULATING = 201
FRAME = 100
KEYBOARD_KEY = 700
POINTER_MOTION = 300
POINTER_MOTION_ABSOLUTE = 400
PONG = 90
SCROLL_CANCEL = 602
SCROLL_DELTA = 600
SCROLL_DISCRETE = 603
SCROLL_STOP = 601
SEAT_BIND = 3
SYNC = 91
TOUCH_DOWN = 800
TOUCH_MOTION = 802
TOUCH_UP = 801
class snegg.eis.KeyEvent(key: int, is_press: bool)

Bases: object

is_press: bool
key: int
class snegg.eis.Keymap(cobj)

Bases: CObjectWrapper

property device: Device
property fd: IO
property keymap_type: KeymapType
property size: int
class snegg.eis.KeymapType(*values)

Bases: IntEnum

XKB = 1
class snegg.eis.Ping(cobj)

Bases: CObjectWrapper

A roundtrip synchronization object. Create with Client.new_ping() and issue with ping(). When the client has processed the roundtrip, an event of type EventType.PONG is returned.

property id: int

Return a unique, monotonically increasing ID for this ping.

ping()

Issue the roundtrip request. Results in an event of type EventType.PONG when processed by the client.

class snegg.eis.PointerAbsoluteEvent(x: float, y: float)

Bases: object

x: float
y: float
class snegg.eis.PointerEvent(dx: float, dy: float)

Bases: object

dx: float
dy: float
class snegg.eis.PongEvent(id: int)

Bases: object

id: int

The ID of the underlying Ping

class snegg.eis.Position(x: int, y: int)

Bases: object

x: int
y: int
class snegg.eis.Region(cobject)

Bases: CObjectWrapper

contains(x: float, y: float) bool
property dimension: Dimension
property mapping_id: str | None
property physical_scale: float
property position: Position
class snegg.eis.ScrollDiscreteEvent(dx: int, dy: int)

Bases: object

dx: int
dy: int
class snegg.eis.ScrollEvent(dx: float, dy: float)

Bases: object

dx: float
dy: float
class snegg.eis.ScrollStopEvent(x: bool, y: bool)

Bases: object

x: bool
y: bool
class snegg.eis.Seat(cobj)

Bases: CObjectWrapper

add()
property capabilities: tuple[DeviceCapability, ...]
property client: Client
property name: str
new_device(*, name: str | None = None, device_type: DeviceType = DeviceType.VIRTUAL, size: Dimension | None = None, capabilities: list[DeviceCapability] | None = None, regions: list[ConfigureRegion] = [], keymap: ConfigureKeymap | None = None) Device
remove()
class snegg.eis.SeatEvent(capabilities: list[snegg.eis.DeviceCapability])

Bases: object

capabilities: list[DeviceCapability]
class snegg.eis.Touch(cobj)

Bases: CObjectWrapper

cancel() Device

Cancel the touch (as opposed to lifting it with up()). Falls back to up() if the client does not support touch cancellation.

property device: Device
down(x: float, y: float) Device
motion(x: float, y: float) Device
up() Device
class snegg.eis.TouchEvent(touchid: int, x: float, y: float, is_cancel: bool = False)

Bases: object

is_cancel: bool = False
touchid: int
x: float
y: float
class snegg.eis.XkbModifiersEvent(depressed: int, latched: int, locked: int, group: int)

Bases: object

depressed: int
group: int
latched: int
locked: int