Commit graph Crafter.Graphics/AGENTS.template.md
Author SHA1 Message Date
c006519fa0
feat(wayland): keep xdg_toplevel's activated and suspended states on the window
A consumer could not tell a window somebody is looking at from one that
merely exists. The compositor's word on it comes with every
xdg_toplevel configure — the `activated` state, and since version 6 of
xdg_wm_base `suspended`, "not ordinarily being repainted", for example
for a content covered by another window or outputs switched off for a
screen lock — and the window dropped the states array. A messenger
built on it took a conversation left open behind a lock screen or
another application for one that was being read: its texts were marked
read and never notified.

Window: `activated` and `suspended` hold the two states, and
onToplevelState fires after a configure changed either, with both
already set. They are batched as the size is: xdg_toplevel.configure
leaves them pending and the xdg_surface.configure that ends the batch
applies them (ApplyToplevelState) last, so the handler does nothing
with the window after its listeners. The constructor takes the first
configure before a listener can be added, so a consumer reads the two
once after it. Both are reported and the library combines nothing:
which of the two a lock screen or another window in front changes is
the compositor's choice, so a consumer that asks whether the user is
looking at the window wants `activated && !suspended`, and the consumer
notes say so. The members are the Wayland backend's; the Win32 and DOM
backends keep no such state.

Device: xdg_wm_base is bound at the version the compositor offers, up
to 6, where it was bound at 1: `suspended` does not exist below 6
(`activated` is version 1's). Every request the windows make is version
1's. Besides `suspended`, the higher versions bring the window state
values it passes over (the tiled ones, 2) and two events,
xdg_toplevel's configure_bounds (4) and wm_capabilities (5), which the
toplevel's listener takes and drops, since libwayland aborts a client
at an event whose handler is null.

Tests: ToplevelState feeds the two configure callbacks of a window
whose surfaces are proxies on a wl_display over a socketpair, as
TitleWayland makes them, and reads the bind off the wire: the states
pending until the surface's configure, the last toplevel configure of a
batch applied, one event for a batch that changes both, none for a
repeat or for other states, an empty array clearing both; an offer of
7, 6, 5 and 1 bound at 6, 6, 5 and 1; a handler in the xdg_wm_base,
xdg_surface and xdg_toplevel listeners for every event of the bundled
protocol.
2026-11-17 06:57:46 +01:00
364d2101c9
feat(wayland): add Window::lastInputTime, the compositor's time of a pointer or touch event
The pointer and touch handlers received wl_pointer's and wl_touch's
`time` and dropped it, so a consumer could date an event only by its own
clock at dispatch. Events queued while the consumer's loop is busy are
dispatched together when it comes back, so by that clock a swipe's
backlog is a burst, and a press and its release that both waited out
a stall happen at one time.

Window::lastInputTime is the compositor's time of the pointer, touch or
scroll event a listener is being invoked for — milliseconds from an
undefined base, wrapping at 2^32 — set before the event fires: the
button events, a motion's onMouseMove, onMouseScroll, onTouchDown,
onTouchMove and onTouchUp, and the pointer events the first finger
stands in for. An event the compositor sends without a time keeps the
last one's: an enter's onMouseEnter and the move that follows it,
onMouseLeave, and a touch_cancel's release and onTouchCancel.

A listener that dispatches Wayland events itself (it makes a Window, or
calls Clipboard::GetText) runs the handlers of what is queued behind
its event, and they set the time too: for that listener from there on,
and for the listeners of its event that come after it. The click, move
and release the first finger stands in for fire after the touch
event's listeners, so the touch handlers set the time again before
them.

The member is the Wayland backend's alone: the Win32 and DOM handlers
set no such time, and design rule 1 keeps the library from "inventing a
shared signature that is a no-op on one side". Those builds have no
such member, and the consumer notes say so.

Tests: InputTime drives the wl_pointer and wl_touch handlers directly,
as MouseScroll and PointerEnterLeave do, and reads lastInputTime in
every listener: 0 before the first event; each event's own time for a
motion, the four button events, a scroll and a touch's down, motion and
up; the touch's time for the first finger's click, move and release,
also when a listener of the touch event has run another handler in
between, as a dispatch from inside it would; the last event's time for
an enter and its move, a leave, and a cancel's release and
onTouchCancel; a time past 2^31 and the one after the wrap as they came.
2026-11-17 06:57:46 +01:00
005b04b183
added review 2026-11-02 14:57:39 +01:00
8c9a588083
test(win32): drop the __libc_single_threaded stand-in, which crafter-build 5.0.0 made unneeded
Tests
- Win32Link linked under the Flatpak only with a C file defining
  __libc_single_threaded. crafter-build gave clang the host's /usr as
  the MinGW sysroot, which put glibc's headers on the include path, and
  libstdc++'s shared_ptr, inlined from nlohmann/json in Crafter.Asset's
  GLB loader, then read the symbol. crafter-build 5.0.0 shows clang only
  the mingw-w64 parts of /usr (Catcrafts/Crafter.Build#43), so nothing
  references it any more. Under 5.0.0 Win32Link links without it, and so
  does examples/HelloUI, which no stand-in covered. The native
  crafter-build on the host, which never had the problem, still builds
  PointerWin32, TextWin32 and Win32Link and runs them under Wine.

Docs
- AGENTS.template.md and AGENTS.consumer.md: linking for Win32 under the
  Flatpak needs crafter-build 5.0.0, and the workaround is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 00:37:41 +01:00
e0b1cf7b9e
switched to agents.md template 2026-10-31 20:40:16 +01:00
Renamed from AGENTS.md (Browse further)