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>, <DeviceCapability.TEXT: 64>, <DeviceCapability.GESTURES: 128>))
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
hold_abort() Device

Abort the current hold gesture, sending an aborted event to reject the sender client’s gesture.

This method is only available on an eis sender context.

Returns self for easy chaining of events.

hold_begin(nfingers: int) Device

Begin a hold gesture with the given number of fingers. Only one hold may be active at a time per device.

Returns self for easy chaining of events.

hold_cancel() Device

Cancel the current hold gesture. This ends the gesture with the is_cancelled flag set.

This method is only available on an eis receiver context.

Returns self for easy chaining of events.

hold_end() Device

End the current hold gesture normally.

Returns self for easy chaining of events.

property keyboard_get_keymap: Keymap | None
keyboard_key(key: int, is_press: bool) Device
keyboard_xkb_modifiers(mods: XkbModifiersEvent)
property name: str
pause()
pinch_abort() Device

Abort the current pinch gesture, sending an aborted event to reject the sender client’s gesture.

This method is only available on an eis sender context.

Returns self for easy chaining of events.

pinch_begin(nfingers: int) Device

Begin a pinch gesture with the given number of fingers. The number of fingers must be >= 2. Only one pinch may be active at a time per device.

Returns self for easy chaining of events.

pinch_cancel() Device

Cancel the current pinch gesture. This ends the gesture with the is_cancelled flag set.

This method is only available on an eis receiver context.

Returns self for easy chaining of events.

pinch_end() Device

End the current pinch gesture normally.

Returns self for easy chaining of events.

pinch_update(dx: float, dy: float, scale: float, rotation: float) Device

Update the current pinch gesture. The delta is in logical pixels or mm relative to the previous begin/update. The scale is absolute normalized (starts at 1.0). The rotation is relative angle in degrees (positive = clockwise).

Returns self for easy chaining of events.

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
swipe_abort() Device

Abort the current swipe gesture, sending an aborted event to reject the sender client’s gesture.

This method is only available on an eis sender context.

Returns self for easy chaining of events.

swipe_begin(nfingers: int) Device

Begin a swipe gesture with the given number of fingers. Only one swipe may be active at a time per device.

Returns self for easy chaining of events.

swipe_cancel() Device

Cancel the current swipe gesture. This ends the gesture with the is_cancelled flag set.

This method is only available on an eis receiver context.

Returns self for easy chaining of events.

swipe_end() Device

End the current swipe gesture normally.

Returns self for easy chaining of events.

swipe_update(dx: float, dy: float) Device

Update the current swipe gesture with the given delta. The delta is in logical pixels or mm relative to the previous begin/update.

Returns self for easy chaining of events.

text_keysym(keysym: int, is_press: bool) Device

Generate a keysym event on a device with the DeviceCapability.TEXT capability. Keysyms are XKB-compatible keysyms and are independent of any keymap – the keysym may not exist on any active keymap.

This method is only available on a receiver context.

Returns self for easy chaining of events.

text_utf8(text: str) Device

Generate a UTF-8 text event on a device with the DeviceCapability.TEXT capability.

This method is only available on a receiver context.

Returns self for easy chaining of events.

touch_new() Touch
property width: int
class snegg.eis.DeviceCapability(*values)

Bases: IntFlag

BUTTON = 32
GESTURES = 128
KEYBOARD = 4
POINTER = 1
POINTER_ABSOLUTE = 2
SCROLL = 16
TEXT = 64
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(flags: list[EisFlag] | None = None)

Bases: CObjectWrapper

add_client_fd(fd: IO)
classmethod create_for_fd(path: str | None, flags: list[EisFlag] | None = None) Eis
classmethod create_for_socket(path: Path, flags: list[EisFlag] | None = None) Eis
dispatch() None
property events: Iterator[Event]
property fd: int
property now: int
class snegg.eis.EisFlag(*values)

Bases: IntEnum

DEVICE_READY = 1
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 hold_event: HoldEvent
property key_event: KeyEvent
property pinch_event: PinchEvent
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 swipe_event: SwipeEvent
property text_keysym_event: TextKeysymEvent
property text_utf8_event: TextUtf8Event
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_READY = 5
DEVICE_START_EMULATING = 200
DEVICE_STOP_EMULATING = 201
FRAME = 100
HOLD_BEGIN = 1020
HOLD_END = 1021
KEYBOARD_KEY = 700
PINCH_BEGIN = 1010
PINCH_END = 1012
PINCH_UPDATE = 1011
POINTER_MOTION = 300
POINTER_MOTION_ABSOLUTE = 400
PONG = 90
SCROLL_CANCEL = 602
SCROLL_DELTA = 600
SCROLL_DISCRETE = 603
SCROLL_STOP = 601
SEAT_BIND = 3
SEAT_DEVICE_REQUESTED = 6
SWIPE_BEGIN = 1000
SWIPE_END = 1002
SWIPE_UPDATE = 1001
SYNC = 91
TEXT_KEYSYM = 900
TEXT_UTF8 = 901
TOUCH_DOWN = 800
TOUCH_MOTION = 802
TOUCH_UP = 801
class snegg.eis.HoldEvent(finger_count: int, is_cancelled: bool = False)

Bases: object

finger_count: int
is_cancelled: bool = False
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.PinchEvent(finger_count: int, dx: float = 0.0, dy: float = 0.0, scale: float = 1.0, rotation: float = 0.0, is_cancelled: bool = False)

Bases: object

dx: float = 0.0
dy: float = 0.0
finger_count: int
is_cancelled: bool = False
rotation: float = 0.0
scale: float = 1.0
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.SwipeEvent(finger_count: int, dx: float = 0.0, dy: float = 0.0, is_cancelled: bool = False)

Bases: object

dx: float = 0.0
dy: float = 0.0
finger_count: int
is_cancelled: bool = False
class snegg.eis.TextKeysymEvent(keysym: int, is_press: bool)

Bases: object

is_press: bool
keysym: int
class snegg.eis.TextUtf8Event(text: str)

Bases: object

text: str
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