python-libei 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libei/__init__.py +31 -0
- libei/_capi/__init__.py +6 -0
- libei/_capi/libei.py +247 -0
- libei/_capi/libeis.py +285 -0
- libei/_capi/liboeffis.py +29 -0
- libei/_capi/loader.py +112 -0
- libei/_cobject.py +252 -0
- libei/ei.py +1244 -0
- libei/eis.py +1234 -0
- libei/oeffis.py +238 -0
- libei/py.typed +0 -0
- python_libei-0.1.0.dist-info/METADATA +770 -0
- python_libei-0.1.0.dist-info/RECORD +16 -0
- python_libei-0.1.0.dist-info/WHEEL +5 -0
- python_libei-0.1.0.dist-info/licenses/LICENSE +21 -0
- python_libei-0.1.0.dist-info/top_level.txt +1 -0
libei/__init__.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Python bindings for libei, libeis and liboeffis (Wayland Emulated Input).
|
|
2
|
+
|
|
3
|
+
Move the pointer, click, type, scroll or touch on a Wayland desktop from
|
|
4
|
+
Python -- the automation, remote-desktop and accessibility jobs that used
|
|
5
|
+
``xdotool`` on X11 -- or implement the compositor side of the same protocol.
|
|
6
|
+
|
|
7
|
+
This package is import-safe even when none of the native libraries are
|
|
8
|
+
installed -- loading is deferred to first use (see ``_capi/loader.py``).
|
|
9
|
+
Use the submodules directly:
|
|
10
|
+
|
|
11
|
+
- :mod:`libei.ei` -- the EI client library (inject or receive input)
|
|
12
|
+
- :mod:`libei.eis` -- the EIS server library (implement a compositor, or
|
|
13
|
+
drive a test harness for the ``ei`` module without a real compositor)
|
|
14
|
+
- :mod:`libei.oeffis` -- negotiate an EI connection through the
|
|
15
|
+
``org.freedesktop.portal.RemoteDesktop`` XDG desktop portal
|
|
16
|
+
|
|
17
|
+
Scope, in short: this needs a compositor speaking EI/EIS -- there is no X11
|
|
18
|
+
fallback. Pointer (relative and absolute), button, keyboard, scroll, touch
|
|
19
|
+
and text are driveable; the gesture and stylus capabilities are present in
|
|
20
|
+
the enums for a future libei -- they exist on upstream's main branch but in
|
|
21
|
+
no released version -- and have no send methods or event accessors. Keyboard input is
|
|
22
|
+
evdev keycodes -- key positions, not characters -- though ``text_utf8()``
|
|
23
|
+
sends characters directly where libei 1.6 is available. See the README for
|
|
24
|
+
the full breakdown, including which features need which libei version.
|
|
25
|
+
|
|
26
|
+
Alpha: the API is not frozen.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
__version__ = "0.1.0"
|
|
30
|
+
|
|
31
|
+
__all__ = ["__version__"]
|
libei/_capi/__init__.py
ADDED
libei/_capi/libei.py
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"""ctypes bindings for libei (the EI client library).
|
|
2
|
+
|
|
3
|
+
Signatures are hand-declared against the libei API documentation
|
|
4
|
+
(https://libinput.pages.freedesktop.org/libei/api/group__libei.html) rather
|
|
5
|
+
than parsed from C declaration strings, so a wrong argument count or type is
|
|
6
|
+
a visible diff here instead of a runtime surprise the first time the
|
|
7
|
+
function is actually called.
|
|
8
|
+
|
|
9
|
+
Names here drop the ``ei_`` prefix the C symbols carry:
|
|
10
|
+
``ei_unref()`` is bound as ``unref`` and called as
|
|
11
|
+
``_capi.libei.unref()``. The module already says which library it is.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from ctypes import (
|
|
17
|
+
CFUNCTYPE,
|
|
18
|
+
POINTER,
|
|
19
|
+
c_bool,
|
|
20
|
+
c_char_p,
|
|
21
|
+
c_double,
|
|
22
|
+
c_int,
|
|
23
|
+
c_int32,
|
|
24
|
+
c_size_t,
|
|
25
|
+
c_uint32,
|
|
26
|
+
c_uint64,
|
|
27
|
+
c_void_p,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
from .loader import LazyLibrary
|
|
31
|
+
|
|
32
|
+
lib = LazyLibrary("libei.so.1")
|
|
33
|
+
|
|
34
|
+
log_handler_t = CFUNCTYPE(None, c_void_p, c_int, c_char_p, c_void_p)
|
|
35
|
+
|
|
36
|
+
log_set_handler = lib.function("ei_log_set_handler", (c_void_p, c_void_p), None)
|
|
37
|
+
log_set_priority = lib.function("ei_log_set_priority", (c_void_p, c_int), None)
|
|
38
|
+
|
|
39
|
+
new_sender = lib.function("ei_new_sender", (c_void_p,), c_void_p)
|
|
40
|
+
new_receiver = lib.function("ei_new_receiver", (c_void_p,), c_void_p)
|
|
41
|
+
unref = lib.function("ei_unref", (c_void_p,), c_void_p)
|
|
42
|
+
configure_name = lib.function("ei_configure_name", (c_void_p, c_char_p), None)
|
|
43
|
+
setup_backend_fd = lib.function("ei_setup_backend_fd", (c_void_p, c_int), c_int)
|
|
44
|
+
setup_backend_socket = lib.function(
|
|
45
|
+
"ei_setup_backend_socket", (c_void_p, c_char_p), c_int
|
|
46
|
+
)
|
|
47
|
+
get_fd = lib.function("ei_get_fd", (c_void_p,), c_int)
|
|
48
|
+
dispatch = lib.function("ei_dispatch", (c_void_p,), None)
|
|
49
|
+
get_event = lib.function("ei_get_event", (c_void_p,), c_void_p)
|
|
50
|
+
now = lib.function("ei_now", (c_void_p,), c_uint64)
|
|
51
|
+
is_sender = lib.function("ei_is_sender", (c_void_p,), c_bool)
|
|
52
|
+
# Returns an owned reference that the caller must unref, and calling
|
|
53
|
+
# ei_get_event() while still holding it is undefined behavior -- see
|
|
54
|
+
# ei.Context.peek_event_type(), which never lets that reference escape.
|
|
55
|
+
peek_event = lib.function("ei_peek_event", (c_void_p,), c_void_p)
|
|
56
|
+
disconnect = lib.function("ei_disconnect", (c_void_p,), None) # libei 1.4+
|
|
57
|
+
|
|
58
|
+
seat_get_name = lib.function("ei_seat_get_name", (c_void_p,), c_char_p)
|
|
59
|
+
seat_has_capability = lib.function("ei_seat_has_capability", (c_void_p, c_int), c_bool)
|
|
60
|
+
# ei_seat_bind_capabilities(seat, cap, cap, ..., 0) is variadic; ctypes
|
|
61
|
+
# converts the trailing plain-int args using default rules as long as they
|
|
62
|
+
# aren't listed in argtypes, so only the fixed prefix is declared here.
|
|
63
|
+
seat_bind_capabilities = lib.function("ei_seat_bind_capabilities", (c_void_p,), None)
|
|
64
|
+
seat_unbind_capabilities = lib.function(
|
|
65
|
+
"ei_seat_unbind_capabilities", (c_void_p,), None
|
|
66
|
+
)
|
|
67
|
+
# Variadic and sentinel-terminated like ei_seat_bind_capabilities above.
|
|
68
|
+
seat_request_device_with_capabilities = lib.function( # libei 1.6+
|
|
69
|
+
"ei_seat_request_device_with_capabilities", (c_void_p,), None
|
|
70
|
+
)
|
|
71
|
+
seat_ref = lib.function("ei_seat_ref", (c_void_p,), c_void_p)
|
|
72
|
+
seat_unref = lib.function("ei_seat_unref", (c_void_p,), c_void_p)
|
|
73
|
+
|
|
74
|
+
event_unref = lib.function("ei_event_unref", (c_void_p,), c_void_p)
|
|
75
|
+
event_get_type = lib.function("ei_event_get_type", (c_void_p,), c_int)
|
|
76
|
+
event_get_seat = lib.function("ei_event_get_seat", (c_void_p,), c_void_p)
|
|
77
|
+
event_get_device = lib.function("ei_event_get_device", (c_void_p,), c_void_p)
|
|
78
|
+
event_get_time = lib.function("ei_event_get_time", (c_void_p,), c_uint64)
|
|
79
|
+
event_emulating_get_sequence = lib.function(
|
|
80
|
+
"ei_event_emulating_get_sequence", (c_void_p,), c_uint32
|
|
81
|
+
)
|
|
82
|
+
event_keyboard_get_xkb_mods_depressed = lib.function(
|
|
83
|
+
"ei_event_keyboard_get_xkb_mods_depressed", (c_void_p,), c_uint32
|
|
84
|
+
)
|
|
85
|
+
event_keyboard_get_xkb_mods_latched = lib.function(
|
|
86
|
+
"ei_event_keyboard_get_xkb_mods_latched", (c_void_p,), c_uint32
|
|
87
|
+
)
|
|
88
|
+
event_keyboard_get_xkb_mods_locked = lib.function(
|
|
89
|
+
"ei_event_keyboard_get_xkb_mods_locked", (c_void_p,), c_uint32
|
|
90
|
+
)
|
|
91
|
+
event_keyboard_get_xkb_group = lib.function(
|
|
92
|
+
"ei_event_keyboard_get_xkb_group", (c_void_p,), c_uint32
|
|
93
|
+
)
|
|
94
|
+
event_keyboard_get_key = lib.function(
|
|
95
|
+
"ei_event_keyboard_get_key", (c_void_p,), c_uint32
|
|
96
|
+
)
|
|
97
|
+
event_keyboard_get_key_is_press = lib.function(
|
|
98
|
+
"ei_event_keyboard_get_key_is_press", (c_void_p,), c_bool
|
|
99
|
+
)
|
|
100
|
+
event_button_get_button = lib.function(
|
|
101
|
+
"ei_event_button_get_button", (c_void_p,), c_uint32
|
|
102
|
+
)
|
|
103
|
+
event_button_get_is_press = lib.function(
|
|
104
|
+
"ei_event_button_get_is_press", (c_void_p,), c_bool
|
|
105
|
+
)
|
|
106
|
+
event_pointer_get_dx = lib.function("ei_event_pointer_get_dx", (c_void_p,), c_double)
|
|
107
|
+
event_pointer_get_dy = lib.function("ei_event_pointer_get_dy", (c_void_p,), c_double)
|
|
108
|
+
event_pointer_get_absolute_x = lib.function(
|
|
109
|
+
"ei_event_pointer_get_absolute_x", (c_void_p,), c_double
|
|
110
|
+
)
|
|
111
|
+
event_pointer_get_absolute_y = lib.function(
|
|
112
|
+
"ei_event_pointer_get_absolute_y", (c_void_p,), c_double
|
|
113
|
+
)
|
|
114
|
+
event_scroll_get_dx = lib.function("ei_event_scroll_get_dx", (c_void_p,), c_double)
|
|
115
|
+
event_scroll_get_dy = lib.function("ei_event_scroll_get_dy", (c_void_p,), c_double)
|
|
116
|
+
event_scroll_get_stop_x = lib.function(
|
|
117
|
+
"ei_event_scroll_get_stop_x", (c_void_p,), c_bool
|
|
118
|
+
)
|
|
119
|
+
event_scroll_get_stop_y = lib.function(
|
|
120
|
+
"ei_event_scroll_get_stop_y", (c_void_p,), c_bool
|
|
121
|
+
)
|
|
122
|
+
event_scroll_get_discrete_dx = lib.function(
|
|
123
|
+
"ei_event_scroll_get_discrete_dx", (c_void_p,), c_int32
|
|
124
|
+
)
|
|
125
|
+
event_scroll_get_discrete_dy = lib.function(
|
|
126
|
+
"ei_event_scroll_get_discrete_dy", (c_void_p,), c_int32
|
|
127
|
+
)
|
|
128
|
+
event_touch_get_id = lib.function("ei_event_touch_get_id", (c_void_p,), c_uint32)
|
|
129
|
+
event_touch_get_x = lib.function("ei_event_touch_get_x", (c_void_p,), c_double)
|
|
130
|
+
event_touch_get_y = lib.function("ei_event_touch_get_y", (c_void_p,), c_double)
|
|
131
|
+
event_touch_get_is_cancel = lib.function(
|
|
132
|
+
"ei_event_touch_get_is_cancel", (c_void_p,), c_bool
|
|
133
|
+
)
|
|
134
|
+
event_text_get_utf8 = lib.function( # libei 1.6+
|
|
135
|
+
"ei_event_text_get_utf8", (c_void_p,), c_char_p
|
|
136
|
+
)
|
|
137
|
+
event_text_get_keysym = lib.function( # libei 1.6+
|
|
138
|
+
"ei_event_text_get_keysym", (c_void_p,), c_uint32
|
|
139
|
+
)
|
|
140
|
+
event_text_get_keysym_is_press = lib.function( # libei 1.6+
|
|
141
|
+
"ei_event_text_get_keysym_is_press", (c_void_p,), c_bool
|
|
142
|
+
)
|
|
143
|
+
# Borrowed reference -- the event still owns it, so wrap() rather than adopt().
|
|
144
|
+
event_pong_get_ping = lib.function("ei_event_pong_get_ping", (c_void_p,), c_void_p)
|
|
145
|
+
|
|
146
|
+
device_ref = lib.function("ei_device_ref", (c_void_p,), c_void_p)
|
|
147
|
+
device_unref = lib.function("ei_device_unref", (c_void_p,), c_void_p)
|
|
148
|
+
device_get_seat = lib.function("ei_device_get_seat", (c_void_p,), c_void_p)
|
|
149
|
+
device_get_context = lib.function("ei_device_get_context", (c_void_p,), c_void_p)
|
|
150
|
+
device_get_name = lib.function("ei_device_get_name", (c_void_p,), c_char_p)
|
|
151
|
+
device_get_type = lib.function("ei_device_get_type", (c_void_p,), c_int)
|
|
152
|
+
device_get_width = lib.function("ei_device_get_width", (c_void_p,), c_uint32)
|
|
153
|
+
device_get_height = lib.function("ei_device_get_height", (c_void_p,), c_uint32)
|
|
154
|
+
device_has_capability = lib.function(
|
|
155
|
+
"ei_device_has_capability", (c_void_p, c_int), c_bool
|
|
156
|
+
)
|
|
157
|
+
device_get_region = lib.function("ei_device_get_region", (c_void_p, c_size_t), c_void_p)
|
|
158
|
+
device_close = lib.function("ei_device_close", (c_void_p,), None)
|
|
159
|
+
device_start_emulating = lib.function(
|
|
160
|
+
"ei_device_start_emulating", (c_void_p, c_uint32), None
|
|
161
|
+
)
|
|
162
|
+
device_stop_emulating = lib.function("ei_device_stop_emulating", (c_void_p,), None)
|
|
163
|
+
device_frame = lib.function("ei_device_frame", (c_void_p, c_uint64), None)
|
|
164
|
+
device_pointer_motion = lib.function(
|
|
165
|
+
"ei_device_pointer_motion", (c_void_p, c_double, c_double), None
|
|
166
|
+
)
|
|
167
|
+
device_pointer_motion_absolute = lib.function(
|
|
168
|
+
"ei_device_pointer_motion_absolute", (c_void_p, c_double, c_double), None
|
|
169
|
+
)
|
|
170
|
+
device_button_button = lib.function(
|
|
171
|
+
"ei_device_button_button", (c_void_p, c_uint32, c_bool), None
|
|
172
|
+
)
|
|
173
|
+
device_scroll_delta = lib.function(
|
|
174
|
+
"ei_device_scroll_delta", (c_void_p, c_double, c_double), None
|
|
175
|
+
)
|
|
176
|
+
device_scroll_discrete = lib.function(
|
|
177
|
+
"ei_device_scroll_discrete", (c_void_p, c_int32, c_int32), None
|
|
178
|
+
)
|
|
179
|
+
device_scroll_stop = lib.function(
|
|
180
|
+
"ei_device_scroll_stop", (c_void_p, c_bool, c_bool), None
|
|
181
|
+
)
|
|
182
|
+
device_scroll_cancel = lib.function(
|
|
183
|
+
"ei_device_scroll_cancel", (c_void_p, c_bool, c_bool), None
|
|
184
|
+
)
|
|
185
|
+
device_keyboard_key = lib.function(
|
|
186
|
+
"ei_device_keyboard_key", (c_void_p, c_uint32, c_bool), None
|
|
187
|
+
)
|
|
188
|
+
device_touch_new = lib.function("ei_device_touch_new", (c_void_p,), c_void_p)
|
|
189
|
+
device_keyboard_get_keymap = lib.function(
|
|
190
|
+
"ei_device_keyboard_get_keymap", (c_void_p,), c_void_p
|
|
191
|
+
)
|
|
192
|
+
device_get_region_at = lib.function( # libei 1.1+
|
|
193
|
+
"ei_device_get_region_at", (c_void_p, c_double, c_double), c_void_p
|
|
194
|
+
)
|
|
195
|
+
# The _with_length form, not plain ei_device_text_utf8(): a c_char_p stops at
|
|
196
|
+
# the first NUL, so a Python str containing one would be silently truncated.
|
|
197
|
+
device_text_utf8_with_length = lib.function( # libei 1.6+
|
|
198
|
+
"ei_device_text_utf8_with_length", (c_void_p, c_char_p, c_size_t), None
|
|
199
|
+
)
|
|
200
|
+
device_text_keysym = lib.function( # libei 1.6+
|
|
201
|
+
"ei_device_text_keysym", (c_void_p, c_uint32, c_bool), None
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
region_ref = lib.function("ei_region_ref", (c_void_p,), c_void_p)
|
|
205
|
+
region_unref = lib.function("ei_region_unref", (c_void_p,), c_void_p)
|
|
206
|
+
region_get_x = lib.function("ei_region_get_x", (c_void_p,), c_uint32)
|
|
207
|
+
region_get_y = lib.function("ei_region_get_y", (c_void_p,), c_uint32)
|
|
208
|
+
region_get_width = lib.function("ei_region_get_width", (c_void_p,), c_uint32)
|
|
209
|
+
region_get_height = lib.function("ei_region_get_height", (c_void_p,), c_uint32)
|
|
210
|
+
region_get_physical_scale = lib.function(
|
|
211
|
+
"ei_region_get_physical_scale", (c_void_p,), c_double
|
|
212
|
+
)
|
|
213
|
+
region_contains = lib.function(
|
|
214
|
+
"ei_region_contains", (c_void_p, c_double, c_double), c_bool
|
|
215
|
+
)
|
|
216
|
+
region_get_mapping_id = lib.function( # libei 1.1+
|
|
217
|
+
"ei_region_get_mapping_id", (c_void_p,), c_char_p
|
|
218
|
+
)
|
|
219
|
+
# x and y are in/out parameters, overwritten only when the point is inside.
|
|
220
|
+
region_convert_point = lib.function( # libei 1.1+
|
|
221
|
+
"ei_region_convert_point",
|
|
222
|
+
(c_void_p, POINTER(c_double), POINTER(c_double)),
|
|
223
|
+
c_bool,
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
keymap_ref = lib.function("ei_keymap_ref", (c_void_p,), c_void_p)
|
|
227
|
+
keymap_unref = lib.function("ei_keymap_unref", (c_void_p,), c_void_p)
|
|
228
|
+
keymap_get_type = lib.function("ei_keymap_get_type", (c_void_p,), c_int)
|
|
229
|
+
keymap_get_size = lib.function("ei_keymap_get_size", (c_void_p,), c_size_t)
|
|
230
|
+
keymap_get_fd = lib.function("ei_keymap_get_fd", (c_void_p,), c_int)
|
|
231
|
+
keymap_get_device = lib.function("ei_keymap_get_device", (c_void_p,), c_void_p)
|
|
232
|
+
|
|
233
|
+
touch_ref = lib.function("ei_touch_ref", (c_void_p,), c_void_p)
|
|
234
|
+
touch_unref = lib.function("ei_touch_unref", (c_void_p,), c_void_p)
|
|
235
|
+
touch_get_device = lib.function("ei_touch_get_device", (c_void_p,), c_void_p)
|
|
236
|
+
touch_down = lib.function("ei_touch_down", (c_void_p, c_double, c_double), None)
|
|
237
|
+
touch_motion = lib.function("ei_touch_motion", (c_void_p, c_double, c_double), None)
|
|
238
|
+
touch_up = lib.function("ei_touch_up", (c_void_p,), None)
|
|
239
|
+
touch_cancel = lib.function("ei_touch_cancel", (c_void_p,), None)
|
|
240
|
+
|
|
241
|
+
# ei_new_ping() returns an owned reference; ei_ping() then triggers the round
|
|
242
|
+
# trip that comes back as an EI_EVENT_PONG.
|
|
243
|
+
new_ping = lib.function("ei_new_ping", (c_void_p,), c_void_p) # libei 1.4+
|
|
244
|
+
ping = lib.function("ei_ping", (c_void_p,), None) # libei 1.4+
|
|
245
|
+
ping_get_id = lib.function("ei_ping_get_id", (c_void_p,), c_uint64) # libei 1.4+
|
|
246
|
+
ping_ref = lib.function("ei_ping_ref", (c_void_p,), c_void_p) # libei 1.4+
|
|
247
|
+
ping_unref = lib.function("ei_ping_unref", (c_void_p,), c_void_p) # libei 1.4+
|
libei/_capi/libeis.py
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"""ctypes bindings for libeis (the EIS server library).
|
|
2
|
+
|
|
3
|
+
See https://libinput.pages.freedesktop.org/libei/api/group__libeis.html
|
|
4
|
+
(mirror: https://gitlab.freedesktop.org/libinput/libei/-/blob/main/src/libeis.h).
|
|
5
|
+
|
|
6
|
+
``eis_setup_backend_fd(ctx)`` and ``eis_backend_fd_add_client(ctx)`` both
|
|
7
|
+
take *only* the context -- there is no fd parameter. The latter *returns* a
|
|
8
|
+
new fd (to be handed to a client's ``ei_setup_backend_fd(ei, fd)``); it
|
|
9
|
+
doesn't accept one. This is easy to get backwards from the name alone --
|
|
10
|
+
see docs/vs-snegg.md for how that showed up in practice while this was
|
|
11
|
+
being worked out.
|
|
12
|
+
|
|
13
|
+
Names here drop the ``eis_`` prefix the C symbols carry:
|
|
14
|
+
``eis_unref()`` is bound as ``unref`` and called as
|
|
15
|
+
``_capi.libeis.unref()``. The module already says which library it is.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
from ctypes import (
|
|
21
|
+
c_bool,
|
|
22
|
+
c_char_p,
|
|
23
|
+
c_double,
|
|
24
|
+
c_int,
|
|
25
|
+
c_int32,
|
|
26
|
+
c_size_t,
|
|
27
|
+
c_uint32,
|
|
28
|
+
c_uint64,
|
|
29
|
+
c_void_p,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
from .loader import LazyLibrary
|
|
33
|
+
|
|
34
|
+
lib = LazyLibrary("libeis.so.1")
|
|
35
|
+
|
|
36
|
+
log_set_handler = lib.function("eis_log_set_handler", (c_void_p, c_void_p), None)
|
|
37
|
+
log_set_priority = lib.function("eis_log_set_priority", (c_void_p, c_int), None)
|
|
38
|
+
|
|
39
|
+
new = lib.function("eis_new", (c_void_p,), c_void_p)
|
|
40
|
+
unref = lib.function("eis_unref", (c_void_p,), c_void_p)
|
|
41
|
+
setup_backend_socket = lib.function(
|
|
42
|
+
"eis_setup_backend_socket", (c_void_p, c_char_p), c_int
|
|
43
|
+
)
|
|
44
|
+
setup_backend_fd = lib.function("eis_setup_backend_fd", (c_void_p,), c_int)
|
|
45
|
+
# Returns a new fd for one client connection (or a negative errno); it does
|
|
46
|
+
# not take one. See module docstring.
|
|
47
|
+
backend_fd_add_client = lib.function("eis_backend_fd_add_client", (c_void_p,), c_int)
|
|
48
|
+
get_fd = lib.function("eis_get_fd", (c_void_p,), c_int)
|
|
49
|
+
dispatch = lib.function("eis_dispatch", (c_void_p,), None)
|
|
50
|
+
# Same contract as ei_peek_event(): an owned reference the caller must
|
|
51
|
+
# unref, and calling eis_get_event() while holding it is undefined
|
|
52
|
+
# behavior -- see eis.Eis.peek_event_type().
|
|
53
|
+
peek_event = lib.function("eis_peek_event", (c_void_p,), c_void_p)
|
|
54
|
+
set_flag = lib.function("eis_set_flag", (c_void_p, c_int), c_int) # libei 1.6+
|
|
55
|
+
get_event = lib.function("eis_get_event", (c_void_p,), c_void_p)
|
|
56
|
+
now = lib.function("eis_now", (c_void_p,), c_uint64)
|
|
57
|
+
|
|
58
|
+
event_unref = lib.function("eis_event_unref", (c_void_p,), c_void_p)
|
|
59
|
+
event_get_type = lib.function("eis_event_get_type", (c_void_p,), c_int)
|
|
60
|
+
event_get_client = lib.function("eis_event_get_client", (c_void_p,), c_void_p)
|
|
61
|
+
event_get_seat = lib.function("eis_event_get_seat", (c_void_p,), c_void_p)
|
|
62
|
+
event_get_device = lib.function("eis_event_get_device", (c_void_p,), c_void_p)
|
|
63
|
+
event_get_time = lib.function("eis_event_get_time", (c_void_p,), c_uint64)
|
|
64
|
+
event_seat_has_capability = lib.function(
|
|
65
|
+
"eis_event_seat_has_capability", (c_void_p, c_int), c_bool
|
|
66
|
+
)
|
|
67
|
+
event_emulating_get_sequence = lib.function(
|
|
68
|
+
"eis_event_emulating_get_sequence", (c_void_p,), c_uint32
|
|
69
|
+
)
|
|
70
|
+
event_keyboard_get_key = lib.function(
|
|
71
|
+
"eis_event_keyboard_get_key", (c_void_p,), c_uint32
|
|
72
|
+
)
|
|
73
|
+
event_keyboard_get_key_is_press = lib.function(
|
|
74
|
+
"eis_event_keyboard_get_key_is_press", (c_void_p,), c_bool
|
|
75
|
+
)
|
|
76
|
+
event_button_get_button = lib.function(
|
|
77
|
+
"eis_event_button_get_button", (c_void_p,), c_uint32
|
|
78
|
+
)
|
|
79
|
+
event_button_get_is_press = lib.function(
|
|
80
|
+
"eis_event_button_get_is_press", (c_void_p,), c_bool
|
|
81
|
+
)
|
|
82
|
+
event_pointer_get_dx = lib.function("eis_event_pointer_get_dx", (c_void_p,), c_double)
|
|
83
|
+
event_pointer_get_dy = lib.function("eis_event_pointer_get_dy", (c_void_p,), c_double)
|
|
84
|
+
event_pointer_get_absolute_x = lib.function(
|
|
85
|
+
"eis_event_pointer_get_absolute_x", (c_void_p,), c_double
|
|
86
|
+
)
|
|
87
|
+
event_pointer_get_absolute_y = lib.function(
|
|
88
|
+
"eis_event_pointer_get_absolute_y", (c_void_p,), c_double
|
|
89
|
+
)
|
|
90
|
+
event_scroll_get_dx = lib.function("eis_event_scroll_get_dx", (c_void_p,), c_double)
|
|
91
|
+
event_scroll_get_dy = lib.function("eis_event_scroll_get_dy", (c_void_p,), c_double)
|
|
92
|
+
event_scroll_get_stop_x = lib.function(
|
|
93
|
+
"eis_event_scroll_get_stop_x", (c_void_p,), c_bool
|
|
94
|
+
)
|
|
95
|
+
event_scroll_get_stop_y = lib.function(
|
|
96
|
+
"eis_event_scroll_get_stop_y", (c_void_p,), c_bool
|
|
97
|
+
)
|
|
98
|
+
event_scroll_get_discrete_dx = lib.function(
|
|
99
|
+
"eis_event_scroll_get_discrete_dx", (c_void_p,), c_int32
|
|
100
|
+
)
|
|
101
|
+
event_scroll_get_discrete_dy = lib.function(
|
|
102
|
+
"eis_event_scroll_get_discrete_dy", (c_void_p,), c_int32
|
|
103
|
+
)
|
|
104
|
+
event_touch_get_id = lib.function("eis_event_touch_get_id", (c_void_p,), c_uint32)
|
|
105
|
+
event_touch_get_x = lib.function("eis_event_touch_get_x", (c_void_p,), c_double)
|
|
106
|
+
event_touch_get_y = lib.function("eis_event_touch_get_y", (c_void_p,), c_double)
|
|
107
|
+
event_touch_get_is_cancel = lib.function(
|
|
108
|
+
"eis_event_touch_get_is_cancel", (c_void_p,), c_bool
|
|
109
|
+
)
|
|
110
|
+
event_text_get_utf8 = lib.function( # libei 1.6+
|
|
111
|
+
"eis_event_text_get_utf8", (c_void_p,), c_char_p
|
|
112
|
+
)
|
|
113
|
+
event_text_get_keysym = lib.function( # libei 1.6+
|
|
114
|
+
"eis_event_text_get_keysym", (c_void_p,), c_uint32
|
|
115
|
+
)
|
|
116
|
+
event_text_get_keysym_is_press = lib.function( # libei 1.6+
|
|
117
|
+
"eis_event_text_get_keysym_is_press", (c_void_p,), c_bool
|
|
118
|
+
)
|
|
119
|
+
# Borrowed reference -- the event still owns it, so wrap() rather than adopt().
|
|
120
|
+
event_pong_get_ping = lib.function("eis_event_pong_get_ping", (c_void_p,), c_void_p)
|
|
121
|
+
|
|
122
|
+
client_ref = lib.function("eis_client_ref", (c_void_p,), c_void_p)
|
|
123
|
+
client_unref = lib.function("eis_client_unref", (c_void_p,), c_void_p)
|
|
124
|
+
client_is_sender = lib.function("eis_client_is_sender", (c_void_p,), c_bool)
|
|
125
|
+
# pid_t, i.e. a 32-bit signed int on Linux. Socket backend only, and
|
|
126
|
+
# negative errno on failure.
|
|
127
|
+
backend_socket_get_client_pid = lib.function(
|
|
128
|
+
"eis_backend_socket_get_client_pid", (c_void_p,), c_int32
|
|
129
|
+
)
|
|
130
|
+
client_get_name = lib.function("eis_client_get_name", (c_void_p,), c_char_p)
|
|
131
|
+
client_connect = lib.function("eis_client_connect", (c_void_p,), None)
|
|
132
|
+
client_disconnect = lib.function("eis_client_disconnect", (c_void_p,), None)
|
|
133
|
+
client_new_seat = lib.function("eis_client_new_seat", (c_void_p, c_char_p), c_void_p)
|
|
134
|
+
# Owned reference; eis_ping() then triggers the round trip that comes back
|
|
135
|
+
# as an EIS_EVENT_PONG.
|
|
136
|
+
client_new_ping = lib.function( # libei 1.4+
|
|
137
|
+
"eis_client_new_ping", (c_void_p,), c_void_p
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
seat_ref = lib.function("eis_seat_ref", (c_void_p,), c_void_p)
|
|
141
|
+
seat_unref = lib.function("eis_seat_unref", (c_void_p,), c_void_p)
|
|
142
|
+
seat_get_name = lib.function("eis_seat_get_name", (c_void_p,), c_char_p)
|
|
143
|
+
seat_get_client = lib.function("eis_seat_get_client", (c_void_p,), c_void_p)
|
|
144
|
+
seat_has_capability = lib.function("eis_seat_has_capability", (c_void_p, c_int), c_bool)
|
|
145
|
+
seat_configure_capability = lib.function(
|
|
146
|
+
"eis_seat_configure_capability", (c_void_p, c_int), None
|
|
147
|
+
)
|
|
148
|
+
seat_add = lib.function("eis_seat_add", (c_void_p,), None)
|
|
149
|
+
seat_remove = lib.function("eis_seat_remove", (c_void_p,), None)
|
|
150
|
+
seat_new_device = lib.function("eis_seat_new_device", (c_void_p,), c_void_p)
|
|
151
|
+
|
|
152
|
+
device_ref = lib.function("eis_device_ref", (c_void_p,), c_void_p)
|
|
153
|
+
device_unref = lib.function("eis_device_unref", (c_void_p,), c_void_p)
|
|
154
|
+
device_get_context = lib.function("eis_device_get_context", (c_void_p,), c_void_p)
|
|
155
|
+
device_get_client = lib.function("eis_device_get_client", (c_void_p,), c_void_p)
|
|
156
|
+
device_get_seat = lib.function("eis_device_get_seat", (c_void_p,), c_void_p)
|
|
157
|
+
device_get_name = lib.function("eis_device_get_name", (c_void_p,), c_char_p)
|
|
158
|
+
device_get_type = lib.function("eis_device_get_type", (c_void_p,), c_int)
|
|
159
|
+
device_get_width = lib.function("eis_device_get_width", (c_void_p,), c_uint32)
|
|
160
|
+
device_get_height = lib.function("eis_device_get_height", (c_void_p,), c_uint32)
|
|
161
|
+
device_has_capability = lib.function(
|
|
162
|
+
"eis_device_has_capability", (c_void_p, c_int), c_bool
|
|
163
|
+
)
|
|
164
|
+
device_get_region = lib.function(
|
|
165
|
+
"eis_device_get_region", (c_void_p, c_size_t), c_void_p
|
|
166
|
+
)
|
|
167
|
+
device_configure_name = lib.function(
|
|
168
|
+
"eis_device_configure_name", (c_void_p, c_char_p), None
|
|
169
|
+
)
|
|
170
|
+
device_configure_type = lib.function(
|
|
171
|
+
"eis_device_configure_type", (c_void_p, c_int), None
|
|
172
|
+
)
|
|
173
|
+
device_configure_capability = lib.function(
|
|
174
|
+
"eis_device_configure_capability", (c_void_p, c_int), None
|
|
175
|
+
)
|
|
176
|
+
device_configure_size = lib.function(
|
|
177
|
+
"eis_device_configure_size", (c_void_p, c_uint32, c_uint32), None
|
|
178
|
+
)
|
|
179
|
+
device_new_region = lib.function("eis_device_new_region", (c_void_p,), c_void_p)
|
|
180
|
+
device_new_keymap = lib.function(
|
|
181
|
+
"eis_device_new_keymap", (c_void_p, c_int, c_int, c_size_t), c_void_p
|
|
182
|
+
)
|
|
183
|
+
device_keyboard_get_keymap = lib.function(
|
|
184
|
+
"eis_device_keyboard_get_keymap", (c_void_p,), c_void_p
|
|
185
|
+
)
|
|
186
|
+
device_keyboard_send_xkb_modifiers = lib.function(
|
|
187
|
+
"eis_device_keyboard_send_xkb_modifiers",
|
|
188
|
+
(c_void_p, c_uint32, c_uint32, c_uint32, c_uint32),
|
|
189
|
+
None,
|
|
190
|
+
)
|
|
191
|
+
device_add = lib.function("eis_device_add", (c_void_p,), None)
|
|
192
|
+
device_remove = lib.function("eis_device_remove", (c_void_p,), None)
|
|
193
|
+
device_pause = lib.function("eis_device_pause", (c_void_p,), None)
|
|
194
|
+
device_resume = lib.function("eis_device_resume", (c_void_p,), None)
|
|
195
|
+
device_start_emulating = lib.function(
|
|
196
|
+
"eis_device_start_emulating", (c_void_p, c_uint32), None
|
|
197
|
+
)
|
|
198
|
+
device_stop_emulating = lib.function("eis_device_stop_emulating", (c_void_p,), None)
|
|
199
|
+
device_frame = lib.function("eis_device_frame", (c_void_p, c_uint64), None)
|
|
200
|
+
device_pointer_motion = lib.function(
|
|
201
|
+
"eis_device_pointer_motion", (c_void_p, c_double, c_double), None
|
|
202
|
+
)
|
|
203
|
+
device_pointer_motion_absolute = lib.function(
|
|
204
|
+
"eis_device_pointer_motion_absolute", (c_void_p, c_double, c_double), None
|
|
205
|
+
)
|
|
206
|
+
device_button_button = lib.function(
|
|
207
|
+
"eis_device_button_button", (c_void_p, c_uint32, c_bool), None
|
|
208
|
+
)
|
|
209
|
+
device_scroll_delta = lib.function(
|
|
210
|
+
"eis_device_scroll_delta", (c_void_p, c_double, c_double), None
|
|
211
|
+
)
|
|
212
|
+
device_scroll_discrete = lib.function(
|
|
213
|
+
"eis_device_scroll_discrete", (c_void_p, c_int32, c_int32), None
|
|
214
|
+
)
|
|
215
|
+
device_scroll_stop = lib.function(
|
|
216
|
+
"eis_device_scroll_stop", (c_void_p, c_bool, c_bool), None
|
|
217
|
+
)
|
|
218
|
+
device_scroll_cancel = lib.function(
|
|
219
|
+
"eis_device_scroll_cancel", (c_void_p, c_bool, c_bool), None
|
|
220
|
+
)
|
|
221
|
+
device_keyboard_key = lib.function(
|
|
222
|
+
"eis_device_keyboard_key", (c_void_p, c_uint32, c_bool), None
|
|
223
|
+
)
|
|
224
|
+
device_touch_new = lib.function("eis_device_touch_new", (c_void_p,), c_void_p)
|
|
225
|
+
device_get_region_at = lib.function( # libei 1.1+
|
|
226
|
+
"eis_device_get_region_at", (c_void_p, c_double, c_double), c_void_p
|
|
227
|
+
)
|
|
228
|
+
# The _with_length form, not plain eis_device_text_utf8(): a c_char_p stops at
|
|
229
|
+
# the first NUL, so a Python str containing one would be silently truncated.
|
|
230
|
+
device_text_utf8_with_length = lib.function( # libei 1.6+
|
|
231
|
+
"eis_device_text_utf8_with_length", (c_void_p, c_char_p, c_size_t), None
|
|
232
|
+
)
|
|
233
|
+
device_text_keysym = lib.function( # libei 1.6+
|
|
234
|
+
"eis_device_text_keysym", (c_void_p, c_uint32, c_bool), None
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
region_ref = lib.function("eis_region_ref", (c_void_p,), c_void_p)
|
|
238
|
+
region_unref = lib.function("eis_region_unref", (c_void_p,), c_void_p)
|
|
239
|
+
region_get_x = lib.function("eis_region_get_x", (c_void_p,), c_uint32)
|
|
240
|
+
region_get_y = lib.function("eis_region_get_y", (c_void_p,), c_uint32)
|
|
241
|
+
region_get_width = lib.function("eis_region_get_width", (c_void_p,), c_uint32)
|
|
242
|
+
region_get_height = lib.function("eis_region_get_height", (c_void_p,), c_uint32)
|
|
243
|
+
region_get_physical_scale = lib.function(
|
|
244
|
+
"eis_region_get_physical_scale", (c_void_p,), c_double
|
|
245
|
+
)
|
|
246
|
+
region_set_size = lib.function(
|
|
247
|
+
"eis_region_set_size", (c_void_p, c_uint32, c_uint32), None
|
|
248
|
+
)
|
|
249
|
+
region_set_offset = lib.function(
|
|
250
|
+
"eis_region_set_offset", (c_void_p, c_uint32, c_uint32), None
|
|
251
|
+
)
|
|
252
|
+
region_set_physical_scale = lib.function(
|
|
253
|
+
"eis_region_set_physical_scale", (c_void_p, c_double), None
|
|
254
|
+
)
|
|
255
|
+
region_add = lib.function("eis_region_add", (c_void_p,), None)
|
|
256
|
+
region_contains = lib.function(
|
|
257
|
+
"eis_region_contains", (c_void_p, c_double, c_double), c_bool
|
|
258
|
+
)
|
|
259
|
+
region_get_mapping_id = lib.function( # libei 1.1+
|
|
260
|
+
"eis_region_get_mapping_id", (c_void_p,), c_char_p
|
|
261
|
+
)
|
|
262
|
+
region_set_mapping_id = lib.function( # libei 1.1+
|
|
263
|
+
"eis_region_set_mapping_id", (c_void_p, c_char_p), None
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
keymap_ref = lib.function("eis_keymap_ref", (c_void_p,), c_void_p)
|
|
267
|
+
keymap_unref = lib.function("eis_keymap_unref", (c_void_p,), c_void_p)
|
|
268
|
+
keymap_add = lib.function("eis_keymap_add", (c_void_p,), None)
|
|
269
|
+
keymap_get_type = lib.function("eis_keymap_get_type", (c_void_p,), c_int)
|
|
270
|
+
keymap_get_size = lib.function("eis_keymap_get_size", (c_void_p,), c_size_t)
|
|
271
|
+
keymap_get_fd = lib.function("eis_keymap_get_fd", (c_void_p,), c_int)
|
|
272
|
+
keymap_get_device = lib.function("eis_keymap_get_device", (c_void_p,), c_void_p)
|
|
273
|
+
|
|
274
|
+
touch_ref = lib.function("eis_touch_ref", (c_void_p,), c_void_p)
|
|
275
|
+
touch_unref = lib.function("eis_touch_unref", (c_void_p,), c_void_p)
|
|
276
|
+
touch_get_device = lib.function("eis_touch_get_device", (c_void_p,), c_void_p)
|
|
277
|
+
touch_down = lib.function("eis_touch_down", (c_void_p, c_double, c_double), None)
|
|
278
|
+
touch_motion = lib.function("eis_touch_motion", (c_void_p, c_double, c_double), None)
|
|
279
|
+
touch_up = lib.function("eis_touch_up", (c_void_p,), None)
|
|
280
|
+
touch_cancel = lib.function("eis_touch_cancel", (c_void_p,), None)
|
|
281
|
+
|
|
282
|
+
ping = lib.function("eis_ping", (c_void_p,), None) # libei 1.4+
|
|
283
|
+
ping_get_id = lib.function("eis_ping_get_id", (c_void_p,), c_uint64) # libei 1.4+
|
|
284
|
+
ping_ref = lib.function("eis_ping_ref", (c_void_p,), c_void_p) # libei 1.4+
|
|
285
|
+
ping_unref = lib.function("eis_ping_unref", (c_void_p,), c_void_p) # libei 1.4+
|
libei/_capi/liboeffis.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""ctypes bindings for liboeffis (portal RemoteDesktop -> EIS fd negotiation).
|
|
2
|
+
|
|
3
|
+
See https://libinput.pages.freedesktop.org/libei/api/group__liboeffis.html.
|
|
4
|
+
|
|
5
|
+
Names here drop the ``oeffis_`` prefix the C symbols carry:
|
|
6
|
+
``oeffis_unref()`` is bound as ``unref`` and called as
|
|
7
|
+
``_capi.liboeffis.unref()``. The module already says which library it is.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from ctypes import c_char_p, c_int, c_uint32, c_void_p
|
|
13
|
+
|
|
14
|
+
from .loader import LazyLibrary
|
|
15
|
+
|
|
16
|
+
lib = LazyLibrary("liboeffis.so.1")
|
|
17
|
+
|
|
18
|
+
new = lib.function("oeffis_new", (c_void_p,), c_void_p)
|
|
19
|
+
ref = lib.function("oeffis_ref", (c_void_p,), c_void_p)
|
|
20
|
+
unref = lib.function("oeffis_unref", (c_void_p,), c_void_p)
|
|
21
|
+
get_fd = lib.function("oeffis_get_fd", (c_void_p,), c_int)
|
|
22
|
+
get_eis_fd = lib.function("oeffis_get_eis_fd", (c_void_p,), c_int)
|
|
23
|
+
create_session = lib.function("oeffis_create_session", (c_void_p, c_uint32), None)
|
|
24
|
+
create_session_on_bus = lib.function(
|
|
25
|
+
"oeffis_create_session_on_bus", (c_void_p, c_char_p, c_uint32), None
|
|
26
|
+
)
|
|
27
|
+
dispatch = lib.function("oeffis_dispatch", (c_void_p,), None)
|
|
28
|
+
get_event = lib.function("oeffis_get_event", (c_void_p,), c_int)
|
|
29
|
+
get_error_message = lib.function("oeffis_get_error_message", (c_void_p,), c_char_p)
|