Skip to content

Commit 91cee8a

Browse files
committed
Correct CI
1 parent 01e2a6c commit 91cee8a

4 files changed

Lines changed: 68 additions & 16 deletions

File tree

‎README.md‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,21 @@ renames before 1.0. What that qualifier covers, concretely:
143143
| Needs | For |
144144
| --- | --- |
145145
| 1.1 | `Region.mapping_id`, `Region.convert_point()`, `Device.region_at()` |
146-
| 1.4 | ping/pong round trips (`Context.new_ping()`), `Context.disconnect()` |
146+
| 1.4 | ping/pong round trips (`Context.new_ping()`), `Context.disconnect()`, touch cancellation (`Touch.cancel()`) |
147+
| 1.5 | `eis.Client.pid` |
147148
| 1.6 | `Device.text_utf8()` / `text_keysym()` and TEXT events, `Seat.request_device()`, `Eis.set_flag()` |
148149

149150
Nothing is resolved until it is called, so a build without one of these
150151
costs you only that call — it raises `LibraryNotFoundError` naming the
151-
missing symbol, while the rest of the package keeps working.
152+
missing symbol, while the rest of the package keeps working. The one
153+
exception is `Event.touch_up_event`, which degrades instead of raising:
154+
on libei older than 1.4 it reports `is_cancel=False`, since a library
155+
with no notion of cancellation genuinely never sends one.
156+
157+
These versions were established by building libei 1.2.1 and diffing its
158+
exported symbols against every binding here, not by reading `@since`
159+
annotations — three of them are missing upstream, and taking their
160+
absence to mean 1.0 got touch cancellation wrong by four releases.
152161

153162
## Install
154163

@@ -623,7 +632,18 @@ for one would hang to its timeout instead of skipping.
623632
CI runs the suite on Python 3.10-3.13 against Ubuntu's libei, which is
624633
1.2.1 -- deliberately older than the 1.6.0 used for development, so the
625634
1.0.0 core floor and the version gates both get exercised on a real build
626-
rather than only on paper. A separate job installs the package with no
635+
rather than only on paper. To reproduce that locally, build an old libei
636+
and point the loader at it:
637+
638+
```sh
639+
git clone --depth 1 --branch 1.2.1 \
640+
https://gitlab.freedesktop.org/libinput/libei.git
641+
cd libei && meson setup build -Dtests=disabled -Ddocumentation=[] \
642+
--prefix=$PWD/prefix && ninja -C build install
643+
LD_LIBRARY_PATH=$PWD/prefix/lib64 pytest -q -rs # from this checkout
644+
```
645+
646+
Expect passes plus skips, never failures or hangs. A separate job installs the package with no
627647
native libraries at all and imports it, which is the property the lazy
628648
loader exists to provide.
629649

‎src/libei/ei.py‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
from . import _capi
5252
from ._capi.libei import log_handler_t
53+
from ._capi.loader import LibraryNotFoundError
5354
from ._cobject import CObject
5455

5556
logger = logging.getLogger("libei.ei")
@@ -390,8 +391,9 @@ def up(self) -> Touch:
390391
def cancel(self) -> Touch:
391392
"""End the touch as cancelled rather than logically released.
392393
393-
Needs version 2 or later of the ``ei_touchscreen`` interface on
394-
both sides; against an older EIS implementation this is a noop.
394+
Requires libei 1.4. It also needs version 2 or later of the
395+
``ei_touchscreen`` interface on both sides -- against an older EIS
396+
implementation the call succeeds but arrives as a plain release.
395397
"""
396398
_capi.libei.touch_cancel(self)
397399
return self
@@ -832,13 +834,25 @@ def touch_up_event(self) -> TouchUpEvent:
832834
"""Touch id and cancellation flag for a TOUCH_UP event.
833835
834836
``is_cancel`` distinguishes a touch the compositor cancelled from
835-
one the user logically released; it is always False against an
836-
EIS implementation older than ``ei_touchscreen`` version 2.
837+
one the user logically released. It is False on libei older than
838+
1.4, which cannot express cancellation, and against an EIS
839+
implementation older than ``ei_touchscreen`` version 2. The touch
840+
id is available everywhere.
837841
"""
838842
self._require("touch_up_event", EventType.TOUCH_UP)
843+
try:
844+
is_cancel = bool(_capi.libei.event_touch_get_is_cancel(self))
845+
except LibraryNotFoundError:
846+
# ei_event_touch_get_is_cancel() arrived in libei 1.4.
847+
# An older library has no way to express cancellation, so every
848+
# TOUCH_UP it reports really is a plain release: False is the
849+
# accurate answer, not a failure. Without this the whole
850+
# accessor would raise on a 1.0-1.3 install, taking the touch
851+
# id -- which those versions do provide -- down with it.
852+
is_cancel = False
839853
return TouchUpEvent(
840854
touchid=_capi.libei.event_touch_get_id(self),
841-
is_cancel=bool(_capi.libei.event_touch_get_is_cancel(self)),
855+
is_cancel=is_cancel,
842856
)
843857

844858
@property

‎src/libei/eis.py‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
from . import _capi
3636
from ._capi.libei import log_handler_t
37+
from ._capi.loader import LibraryNotFoundError
3738
from ._cobject import CObject
3839
from .ei import _next_emulating_sequence
3940

@@ -347,8 +348,9 @@ def up(self) -> Touch:
347348
def cancel(self) -> Touch:
348349
"""End the touch as cancelled rather than logically released.
349350
350-
Needs version 2 or later of the ``ei_touchscreen`` interface on
351-
both sides; against an older client this is a noop.
351+
Requires libei 1.4, and version 2 or later of the
352+
``ei_touchscreen`` interface on both sides; against an older client
353+
it arrives as a plain release.
352354
"""
353355
_capi.libeis.touch_cancel(self)
354356
return self
@@ -673,9 +675,10 @@ def name(self) -> str:
673675
def pid(self) -> int:
674676
"""The client process's pid, via ``SO_PEERCRED``.
675677
676-
Socket-backend contexts only -- meaningless for a context set up
677-
with :meth:`Eis.create_for_fd`, where there is no peer socket to
678-
ask. Raises :class:`Error` if the library reports a failure.
678+
Requires libei 1.5. Socket-backend contexts only -- meaningless
679+
for a context set up with :meth:`Eis.create_for_fd`, where there is
680+
no peer socket to ask. Raises :class:`Error` if the library reports
681+
a failure.
679682
"""
680683
result = _capi.libeis.backend_socket_get_client_pid(self)
681684
if result < 0:
@@ -907,13 +910,24 @@ def touch_up_event(self) -> TouchUpEvent:
907910
"""Touch id and cancellation flag for a TOUCH_UP event.
908911
909912
``is_cancel`` distinguishes a cancelled touch from a logically
910-
released one; it is always False against a client older than
911-
``ei_touchscreen`` version 2.
913+
released one. It is False on libei older than 1.4, and against a
914+
client older than ``ei_touchscreen`` version 2. The touch id is
915+
available everywhere.
912916
"""
913917
self._require("touch_up_event", EventType.TOUCH_UP)
918+
try:
919+
is_cancel = bool(_capi.libeis.event_touch_get_is_cancel(self))
920+
except LibraryNotFoundError:
921+
# eis_event_touch_get_is_cancel() arrived in libei 1.4.
922+
# An older library has no way to express cancellation, so every
923+
# TOUCH_UP it reports really is a plain release: False is the
924+
# accurate answer, not a failure. Without this the whole
925+
# accessor would raise on a 1.0-1.3 install, taking the touch
926+
# id -- which those versions do provide -- down with it.
927+
is_cancel = False
914928
return TouchUpEvent(
915929
touchid=_capi.libeis.event_touch_get_id(self),
916-
is_cancel=bool(_capi.libeis.event_touch_get_is_cancel(self)),
930+
is_cancel=is_cancel,
917931
)
918932

919933
@property

‎tests/test_integration_extras.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def on_device(device: ei.Device) -> None:
151151
assert received[1] == eis.TextKeysymEvent(keysym=0x61, is_press=False)
152152

153153

154+
@requires_symbol("libei.so.1", "ei_touch_cancel")
154155
def test_touch_up_reports_cancellation() -> None:
155156
pair = Pair((eis.DeviceCapability.TOUCH,))
156157
ups: list[eis.TouchUpEvent] = []
@@ -197,6 +198,9 @@ def on_device(device: ei.Device) -> None:
197198
device.stop_emulating()
198199

199200
pair.run(lambda: bool(ups), on_server_event=on_server_event, on_device=on_device)
201+
# Deliberately not gated on ei_touch_cancel: this is also the
202+
# regression test for touch_up_event degrading rather than raising on a
203+
# libei older than 1.4, where the is_cancel accessor does not exist.
200204
assert ups[0].is_cancel is False
201205

202206

0 commit comments

Comments
 (0)