Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ All notable changes to python-libei are recorded here. The format follows

## [Unreleased]

## [0.8.1] - 2026-11-11

### Added

- **A socketpair round-trip covering the event accessors no test reached.**
Expand Down Expand Up @@ -66,6 +68,40 @@ All notable changes to python-libei are recorded here. The format follows
`Region.convert_point()` is out of reach, and every remaining marker was
swept against 1.0.0's real headers: 17 `ei_` and 18 `eis_` markers, none
of them contradicted.
- **A malformed `Response` reply to a portal request now raises the typed
`PortalProtocolError` instead of a timeout or a crash.** Every
Request-returning portal call waits on a `Response` specified as
`(u response, a{sv} results)`, and `_request` unpacked it on faith: a
wrong-arity payload raised inside the GLib signal callback -- where PyGI
prints the traceback to stderr and swallows it, so the step silently
degraded to a full-timeout `PortalTimeoutError` -- while a non-dict
`results` slipped through to callers, whose `.get()` crashed with a raw
`AttributeError` past `except PortalError`. The shape is now checked in
the callback and any mismatch ends the wait with `PortalProtocolError`
(the same hardening the session signals received in 0.8.0), so what
`_request` returns is structurally guaranteed: an `int` code and a
`dict` of results. `GetZones`' and `SetPointerBarriers`' result *values*
are converted under the same kind of guard as the Activated signal's
(`zone_set` and each zone's four coordinates as the spec's integers,
`failed_barriers` as a list of them) -- and a `d` where the spec gives
an integer is now rejected rather than silently truncated by `int()`, so
a `0.9` coordinate or a `1.9` refused-barrier id cannot read back as a
different, valid-looking value. And a `Response` landing in the same
main-context iteration as
the request's deadline now resolves to whichever outcome was recorded
first, rather than the delivered reply being dropped for a timeout --
the same simultaneous-dispatch fix `_wait_for_signal` already had.
- **Every event pulled from the dispatch queue leaked one C reference.**
`ei_get_event()` and `eis_get_event()` transfer ownership of the
returned event to the caller, but `ei.Context.events()` and
`eis.Eis.events()` wrapped it with `wrap()`, which is for *borrowed*
pointers and takes its own extra ref -- so the transferred reference was
never released, leaking one `ei_event`/`eis_event` for every event the
iterator yielded. They now `adopt()` the transferred reference, which
takes no extra ref and lets the wrapper's finalizer balance the one the
C API handed over.

## [0.8.0] - 2026-10-20

### Added

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ and why, is in

## Status

Beta (`0.8.0`), published on [PyPI](https://pypi.org/project/python-libei/)
Beta (`0.8.1`), published on [PyPI](https://pypi.org/project/python-libei/)
since `0.1.0`, and **the API is not frozen** — expect renames before 1.0.

The injection path is exercised end to end against the real libraries by the
Expand Down
2 changes: 1 addition & 1 deletion docs/developers/verification.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# What has actually been verified

The package is beta (`0.8.0`) and the API is not frozen — expect renames
The package is beta (`0.8.1`) and the API is not frozen — expect renames
before 1.0. This page is what that qualifier covers, concretely: which paths
have been driven against real libraries, which have only ever been driven
against fakes, and which libei versions the whole thing has met.
Expand Down
3 changes: 2 additions & 1 deletion docs/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ Regions carry more than bounds. `region.mapping_id` groups the ones that map
to the same thing, `device.region_at(x, y)` finds which region a point falls
in, and `region.convert_point(x, y)` turns a desktop-wide point into one
relative to that region — returning `None` when it falls outside, which also
answers "is it in here?" in a single call. All three need libei 1.1.
answers "is it in here?" in a single call. `mapping_id` and `region_at()`
need libei 1.1; `convert_point()` works on the libei 1.0.0 floor.

## Picking the right device when several resume

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "python-libei"
version = "0.8.0"
version = "0.8.1"
description = "Inject, receive and capture input on Wayland from Python: ctypes bindings for libei, libeis and liboeffis, plus the RemoteDesktop and InputCapture portals"
readme = "README.md"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/libei/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
Beta: the API is not frozen.
"""

__version__ = "0.8.0"
__version__ = "0.8.1"

__all__ = ["__version__"]
8 changes: 5 additions & 3 deletions src/libei/ei.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ def convert_point(self, x: float, y: float) -> tuple[float, float] | None:

Returns the point with the region's offset subtracted, or ``None``
if it falls outside the region -- which is also how you test
membership without a second :meth:`contains` call. Requires
libei 1.1.
membership without a second :meth:`contains` call.
"""
# x/y are in-out parameters: libei overwrites them only when the
# point is inside, so the return value has to gate reading them.
Expand Down Expand Up @@ -1127,7 +1126,10 @@ def events(self) -> Iterator[Event]:
pointer = _capi.libei.get_event(self)
if not pointer:
break
event = Event.wrap(pointer)
# adopt(), not wrap(): ei_get_event() transfers ownership of
# the returned reference to the caller, and the unref in
# release() below is the one that balances it.
event = Event.adopt(pointer)
assert event is not None
# try/finally, not a bare call after yield: breaking out of a
# `for event in ctx.events:` loop (or an exception propagating
Expand Down
13 changes: 9 additions & 4 deletions src/libei/eis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,10 @@ def events(self) -> Iterator[Event]:
pointer = _capi.libeis.get_event(self)
if not pointer:
break
event = Event.wrap(pointer)
# adopt(), not wrap(): eis_get_event() transfers ownership of
# the returned reference to the caller, and the unref in
# release() below is the one that balances it.
event = Event.adopt(pointer)
assert event is not None
# See ei.Context.events: try/finally so release() still runs
# if the caller breaks out of the loop (GeneratorExit at the
Expand All @@ -1179,9 +1182,11 @@ def now(self) -> int:
def set_flag(self, flag: Flag) -> None:
"""Change this context's protocol behavior. Requires libei 1.6.

Must be called before the backend is set up, so in practice
before :meth:`create_for_fd` / :meth:`create_for_socket` -- which
also means this is only reachable on a context built by hand.
Must be called before the backend is set up, so the supported
way to use it is the ``flags`` parameter of
:meth:`create_for_fd` / :meth:`create_for_socket`, which apply
each flag at exactly that point; calling it directly only works
on a context built by hand, before its backend is set up.
Takes one flag, never a bitmask; call it again for another.
"""
result = _capi.libeis.set_flag(self, flag)
Expand Down
Loading
Loading