Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ImsdMessages.Ui:Canvas — the window and what every screen draws with: the
|
|
|
|
|
font, the word wrapper over it, and four compositing layers. Within one
|
|
|
|
|
fused dispatch all quads composite before all text, so the scrolling
|
|
|
|
|
content (clipped to its area), the chrome above it and any sheet above that
|
|
|
|
|
are separate dispatches in that order; the background is a quad of its own
|
|
|
|
|
because the swapchain is never cleared.
|
|
|
|
|
*/
|
|
|
|
|
module;
|
|
|
|
|
#include "vulkan/vulkan.h"
|
|
|
|
|
export module ImsdMessages.Ui:Canvas;
|
|
|
|
|
import std;
|
|
|
|
|
import Crafter.Graphics;
|
|
|
|
|
import Crafter.Event;
|
|
|
|
|
import ImsdMessages;
|
|
|
|
|
|
|
|
|
|
export namespace ImsdMessages::Ui {
|
|
|
|
|
using Color = std::array<float, 4>;
|
|
|
|
|
|
|
|
|
|
struct Theme {
|
|
|
|
|
Color bg = { 0.96f, 0.96f, 0.97f, 1.0f };
|
|
|
|
|
Color surface = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
|
|
|
Color text = { 0.11f, 0.11f, 0.12f, 1.0f };
|
|
|
|
|
Color muted = { 0.43f, 0.43f, 0.45f, 1.0f };
|
|
|
|
|
Color accent = { 0.18f, 0.44f, 0.93f, 1.0f };
|
|
|
|
|
Color onAccent = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
|
|
|
Color bubbleIn = { 0.91f, 0.91f, 0.92f, 1.0f };
|
|
|
|
|
Color bubbleOut = { 0.18f, 0.44f, 0.93f, 1.0f };
|
|
|
|
|
Color banner = { 1.0f, 0.95f, 0.80f, 1.0f };
|
|
|
|
|
Color bannerText = { 0.40f, 0.30f, 0.01f, 1.0f };
|
|
|
|
|
Color divider = { 0.88f, 0.88f, 0.89f, 1.0f };
|
|
|
|
|
Color danger = { 0.80f, 0.16f, 0.16f, 1.0f };
|
|
|
|
|
Color scrim = { 0.0f, 0.0f, 0.0f, 0.35f };
|
Bus, Ui, main: the system's appearance, dark or light and its accent
The desktop portal's org.freedesktop.appearance settings on the session
bus say whether the system prefers dark (color-scheme 1) and which
accent colour it uses, and a flatpak may read them. Bus:Appearance
subscribes to SettingChanged and reads the namespace in one ReadAll
call, which every portal version has, so a start waits for one answer at
most, 2 s; a portal that gave no colour scheme by then — still starting,
or not on the bus yet — is asked again when its name has an owner,
without waiting, and its answer comes as a change. The canvas gained a
dark palette and takes the accent for the avatars, badges, buttons and
outgoing bubbles, with the text on it dark or light by the accent's
brightness. The app applies the theme to the window at once and keeps it
for the next one; --theme dark|light or IMSD_MESSAGES_THEME (the same
two values: another is refused on the command line and ignored in the
environment) overrides the portal's colour scheme, for benches and
desktops without a portal.
2026-10-18 03:08:03 +02:00
|
|
|
|
|
|
|
|
static Theme Light() { return Theme{}; }
|
|
|
|
|
|
|
|
|
|
static Theme Dark() {
|
|
|
|
|
Theme t;
|
|
|
|
|
t.bg = { 0.07f, 0.07f, 0.08f, 1.0f };
|
|
|
|
|
t.surface = { 0.12f, 0.12f, 0.13f, 1.0f };
|
|
|
|
|
t.text = { 0.93f, 0.93f, 0.94f, 1.0f };
|
|
|
|
|
t.muted = { 0.62f, 0.62f, 0.65f, 1.0f };
|
|
|
|
|
t.bubbleIn = { 0.18f, 0.18f, 0.20f, 1.0f };
|
|
|
|
|
t.banner = { 0.30f, 0.26f, 0.10f, 1.0f };
|
|
|
|
|
t.bannerText = { 0.98f, 0.88f, 0.55f, 1.0f };
|
|
|
|
|
t.divider = { 0.20f, 0.20f, 0.22f, 1.0f };
|
|
|
|
|
t.danger = { 0.90f, 0.30f, 0.30f, 1.0f };
|
|
|
|
|
t.scrim = { 0.0f, 0.0f, 0.0f, 0.55f };
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The system's accent colour, with text on it dark or light as its
|
|
|
|
|
// brightness asks.
|
|
|
|
|
void Accent(std::array<float, 3> rgb) {
|
|
|
|
|
accent = { rgb[0], rgb[1], rgb[2], 1.0f };
|
|
|
|
|
bubbleOut = accent;
|
|
|
|
|
const float luminance = 0.2126f * rgb[0] + 0.7152f * rgb[1] + 0.0722f * rgb[2];
|
|
|
|
|
onAccent = luminance > 0.6f ? Color{ 0.08f, 0.08f, 0.09f, 1.0f } : Color{ 1.0f, 1.0f, 1.0f, 1.0f };
|
|
|
|
|
}
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
};
|
|
|
|
|
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
// One compositing layer: its own item buffers — one set per frame in
|
|
|
|
|
// flight, the frame's own filled — and one fused dispatch. A frame still
|
|
|
|
|
// on the GPU reads its items as it runs, and the atlas evicts glyphs: a
|
|
|
|
|
// later frame written into the same buffers could name cells that frame
|
|
|
|
|
// drew other glyphs in (Crafter.Graphics a4be6f1, the library's usage
|
|
|
|
|
// contract since).
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
class Layer {
|
|
|
|
|
public:
|
|
|
|
|
void Create(Crafter::UIRenderer& ui, Crafter::FontAtlas& atlas, std::uint32_t quadCap, std::uint32_t circleCap, std::uint32_t glyphCap) {
|
|
|
|
|
constexpr VkBufferUsageFlags usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
|
|
|
|
|
constexpr VkMemoryPropertyFlags memory = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
for (Items& f : frames) {
|
|
|
|
|
f.quads.Create(usage, memory, quadCap);
|
|
|
|
|
f.circles.Create(usage, memory, circleCap);
|
|
|
|
|
f.glyphs.Create(usage, memory, glyphCap);
|
|
|
|
|
f.quadSlot.emplace(ui.RegisterBuffer(f.quads));
|
|
|
|
|
f.circleSlot.emplace(ui.RegisterBuffer(f.circles));
|
|
|
|
|
f.glyphSlot.emplace(ui.RegisterBuffer(f.glyphs));
|
|
|
|
|
}
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
this->quadCap = quadCap;
|
|
|
|
|
this->circleCap = circleCap;
|
|
|
|
|
this->glyphCap = glyphCap;
|
|
|
|
|
buf.quadCount = &quadCount;
|
|
|
|
|
buf.quadCap = quadCap;
|
|
|
|
|
buf.glyphCount = &glyphCount;
|
|
|
|
|
buf.glyphCap = glyphCap;
|
|
|
|
|
buf.atlas = &atlas;
|
|
|
|
|
buf.renderer = &ui;
|
|
|
|
|
}
|
|
|
|
|
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
// The frame's set of buffers: everything recorded until Submit goes
|
|
|
|
|
// into it.
|
|
|
|
|
void Begin(std::uint32_t frameIdx) {
|
|
|
|
|
current = frameIdx;
|
|
|
|
|
buf.quads = frames[current].quads.value;
|
|
|
|
|
buf.glyphs = frames[current].glyphs.value;
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
quadCount = 0;
|
|
|
|
|
circleCount = 0;
|
|
|
|
|
glyphCount = 0;
|
|
|
|
|
clip = { 0.0f, 0.0f, 1e9f, 1e9f };
|
|
|
|
|
overflow = false;
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
glyphsWaiting = 0;
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetClip(Box b) { clip = { b.x, b.y, b.w, b.h }; }
|
|
|
|
|
|
|
|
|
|
Crafter::UIBuffer& Buf() noexcept { return buf; }
|
|
|
|
|
|
|
|
|
|
void Quad(Box b, Color c, float radius = 0, float outline = 0, Color outlineColor = {}) {
|
|
|
|
|
if (quadCount >= quadCap) {
|
|
|
|
|
overflow = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
frames[current].quads.value[quadCount++] = Crafter::QuadItem{ b.x, b.y, b.w, b.h, c[0], c[1], c[2], c[3], radius, radius, radius, radius, outline, outlineColor[0], outlineColor[1], outlineColor[2] };
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Circle(Point center, float radius, Color c) {
|
|
|
|
|
if (circleCount >= circleCap) {
|
|
|
|
|
overflow = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
frames[current].circles.value[circleCount++] = Crafter::CircleItem{ center.x, center.y, radius, 0, c[0], c[1], c[2], c[3], 0, 0, 0, 0 };
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// One line; returns its advance.
|
|
|
|
|
float Text(std::string_view text, float x, float baselineY, Crafter::Font& font, float px, Color c, Crafter::TextAlign align = Crafter::TextAlign::Left) {
|
|
|
|
|
const std::uint32_t before = glyphCount;
|
|
|
|
|
const float advance = Crafter::DrawText(buf, text, x, baselineY, font, px, c, align);
|
|
|
|
|
if (glyphCount == before && !text.empty() && glyphCount >= glyphCap) overflow = true;
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
// A glyph with ink that found no room in the atlas drew blank and
|
|
|
|
|
// gets a cell when the next frame begins (the library's contract):
|
|
|
|
|
// counted, so the frame is asked for.
|
|
|
|
|
for (std::size_t i = 0; i < text.size();) {
|
|
|
|
|
const std::uint32_t cp = DecodeUtf8(text, i);
|
|
|
|
|
if (const Crafter::Glyph* g = buf.atlas->Lookup(font, cp); g && g->w > 0 && !g->Resident()) ++glyphsWaiting;
|
|
|
|
|
}
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
return advance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Submit(VkCommandBuffer cmd, Crafter::UIRenderer& ui) {
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
Items& f = frames[current];
|
|
|
|
|
if (quadCount) f.quads.FlushDevice(cmd, VK_ACCESS_SHADER_READ_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
|
|
|
if (circleCount) f.circles.FlushDevice(cmd, VK_ACCESS_SHADER_READ_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
|
|
|
if (glyphCount) f.glyphs.FlushDevice(cmd, VK_ACCESS_SHADER_READ_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
if (!quadCount && !circleCount && !glyphCount) return;
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
ui.DispatchFused(cmd, { *f.quadSlot, quadCount, clip }, { *f.circleSlot, circleCount, clip }, {}, { *f.glyphSlot, glyphCount, clip });
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Overflowed() const noexcept { return overflow; }
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
std::uint32_t GlyphsWaiting() const noexcept { return glyphsWaiting; }
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
|
|
|
|
|
private:
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
struct Items {
|
|
|
|
|
Crafter::GraphicsBuffer<Crafter::QuadItem, true> quads;
|
|
|
|
|
Crafter::GraphicsBuffer<Crafter::CircleItem, true> circles;
|
|
|
|
|
Crafter::GraphicsBuffer<Crafter::GlyphItem, true> glyphs;
|
|
|
|
|
std::optional<Crafter::BufferSlot> quadSlot;
|
|
|
|
|
std::optional<Crafter::BufferSlot> circleSlot;
|
|
|
|
|
std::optional<Crafter::BufferSlot> glyphSlot;
|
|
|
|
|
};
|
|
|
|
|
std::array<Items, Crafter::Window::numFrames> frames;
|
|
|
|
|
std::uint32_t current = 0;
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
std::uint32_t quadCap = 0;
|
|
|
|
|
std::uint32_t circleCap = 0;
|
|
|
|
|
std::uint32_t glyphCap = 0;
|
|
|
|
|
std::uint32_t quadCount = 0;
|
|
|
|
|
std::uint32_t circleCount = 0;
|
|
|
|
|
std::uint32_t glyphCount = 0;
|
|
|
|
|
std::array<float, 4> clip = { 0.0f, 0.0f, 1e9f, 1e9f };
|
|
|
|
|
bool overflow = false;
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
std::uint32_t glyphsWaiting = 0; // glyphs drawn blank this frame for want of an atlas cell
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
Crafter::UIBuffer buf;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Canvas {
|
|
|
|
|
// Declared first so they die last: a layer's buffer slots hand their
|
|
|
|
|
// numbers back to the heap when they go, so the heap (and the
|
2026-10-18 01:16:35 +02:00
|
|
|
// renderer, which holds slots of its own) must still exist then. The
|
|
|
|
|
// atlas destroys its image and the heap, in sets mode, holds a view
|
|
|
|
|
// of it, so the heap goes before the atlas. Members are destroyed in
|
|
|
|
|
// the reverse order of their declaration, whatever their access.
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
std::optional<Crafter::Window> window;
|
|
|
|
|
std::optional<Crafter::Font> font;
|
|
|
|
|
Crafter::FontAtlas atlas;
|
2026-10-18 01:16:35 +02:00
|
|
|
Crafter::GraphicsDescriptorHeap heap;
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
Crafter::UIRenderer ui;
|
|
|
|
|
std::optional<Crafter::EventListener<Crafter::UIBuildArgs>> buildSub;
|
|
|
|
|
std::optional<WordWrapper> wrapper;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Theme theme;
|
|
|
|
|
Layer background;
|
|
|
|
|
Layer content;
|
|
|
|
|
Layer chrome;
|
|
|
|
|
Layer overlay;
|
|
|
|
|
|
|
|
|
|
// The screens draw into the layers from here, once per frame.
|
|
|
|
|
std::function<void(VkCommandBuffer)> onDraw;
|
|
|
|
|
|
|
|
|
|
// The device once per process, then the window, the heap, the font,
|
|
|
|
|
// the atlas, the renderer and the layers. Sizes in dp; the
|
|
|
|
|
// compositor decides the real size on a phone anyway.
|
Ui, main: the input method, the app id, and touch through the pointer path
With the Crafter.Graphics branch delivering touch (the first finger as the
pointer), zwp_text_input_v3 and xdg app ids, the app:
- sets its app id on the window;
- tells the compositor which field has the focus and where its caret is,
after every frame that changed it: the number field at once (purpose
phone), the message field on a tap or a key; a sheet or leaving the
screen takes it back;
- shows the input method's composing text in the accent colour at the
cursor, each run placed at the advance the one before it was drawn
with, applies its deletions by code point and leaves the composing
text to the input method, and takes its committed text as typed (the
composing text and its deletions are the core's Edit, in tests/Edit; a
draft kept for a conversation that is left keeps a word still being
composed as text); a tap inside the composing text leaves the cursor
where it is, a tap elsewhere in the field commits the word where it
was typed and resets the input method, as Send does, so the half-typed
word does not move to the tap; a sheet, a hide and leaving a screen by
Open (over the number screen or over another conversation), by Back or
by the + end the composition the same way and at once (EndComposition:
the word committed, the input method told), since the input method
starts afresh after, and left on until the next frame it would send
its next commit to the screen that opens or have it dropped. The
message field starts unfocused, as on a phone, and the caret blinks
only in a focused field;
- sends what the field shows: Send, like Start, reads the shown text
once, the composing word included, and clears the field only once the
store took it (a field of nothing but spaces and line breaks is
cleared with nothing sent); the field keeps the focus while the input
method is reset (disabled, enabled again the next frame) — a refused
text leaves the field and the composing word as they are; Start reads
the shown text once — the key and the address dialled come from it —
so a refused number leaves the composing word to the input method;
- logs the window's size on every resize, and which conversation was
opened — under --headless; a plain start names no correspondent in its
log, as the rest of the app does not.
Touch takes the mouse's gesture path, and a touch the compositor cancels
(a gesture of its own) arrives as a release without the finger's
touch-up: it is fed to the gestures as a cancel, so it taps nothing.
Tested: tests/Edit (the composing text kept by a deletion, and put into
the field's text by ComposeCommitPreedit).
2026-10-18 02:30:01 +02:00
|
|
|
void Create(std::uint32_t widthDp, std::uint32_t heightDp, std::string_view title, std::string_view appId, const std::filesystem::path& assetDir, const std::filesystem::path& cacheDir) {
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
static bool deviceReady = false;
|
Ui, project: Crafter.Graphics at 6f471ca, whose text-input disable ends the composition
The pinned library kept its record of the last composing text it had
reported across the app's disable of the text input (only the
compositor's leave cleared it) and reported a later composition only
when it differed from that record or a commit came with it: after
Send's, a tap's or a hide's reset, a first composition equal to the last
word shown, with no commit beside it, never reached the field.
Crafter.Graphics 6f471ca clears the record and the pending flags on the
disable, as the leave does; the app's resets all go through that disable
and need nothing more.
The pin moves from 079b6b0 to the library's master of 2026-10-31, ten
commits on: windows on compositors without xdg-decoration, viewporter or
fractional scale, device features the application asks for (the defaults
serve this one), the descriptor heap's rounding, ray-tracing and Win32
fixes, a WebGPU example's build fix, the library's AGENTS files. The
event orders and contracts this app relies on hold at the new commit;
the vendored code and the licence texts are unchanged. The library ships
consumer notes from this commit on (AGENTS.consumer.md); crafter-build
since 4.0.0 writes them only into an AGENTS.md it generates from an
AGENTS.template.md, and this app has none: its AGENTS.md is written by
hand and no build touches it.
2026-10-31 18:11:40 +01:00
|
|
|
static std::string deviceError; // a failed set-up is final: the app asks the library for nothing it could ask less of
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
if (!deviceError.empty()) throw std::runtime_error(deviceError);
|
|
|
|
|
if (!deviceReady) {
|
|
|
|
|
std::error_code ec;
|
|
|
|
|
std::filesystem::create_directories(cacheDir, ec);
|
|
|
|
|
Crafter::Device::pipelineCachePath = cacheDir / "pipeline_cache.bin";
|
|
|
|
|
try {
|
|
|
|
|
Crafter::Device::Initialize();
|
|
|
|
|
} catch (const std::exception& e) {
|
Ui, project: Crafter.Graphics at 6f471ca, whose text-input disable ends the composition
The pinned library kept its record of the last composing text it had
reported across the app's disable of the text input (only the
compositor's leave cleared it) and reported a later composition only
when it differed from that record or a commit came with it: after
Send's, a tap's or a hide's reset, a first composition equal to the last
word shown, with no commit beside it, never reached the field.
Crafter.Graphics 6f471ca clears the record and the pending flags on the
disable, as the leave does; the app's resets all go through that disable
and need nothing more.
The pin moves from 079b6b0 to the library's master of 2026-10-31, ten
commits on: windows on compositors without xdg-decoration, viewporter or
fractional scale, device features the application asks for (the defaults
serve this one), the descriptor heap's rounding, ray-tracing and Win32
fixes, a WebGPU example's build fix, the library's AGENTS files. The
event orders and contracts this app relies on hold at the new commit;
the vendored code and the licence texts are unchanged. The library ships
consumer notes from this commit on (AGENTS.consumer.md); crafter-build
since 4.0.0 writes them only into an AGENTS.md it generates from an
AGENTS.template.md, and this app has none: its AGENTS.md is written by
hand and no build touches it.
2026-10-31 18:11:40 +01:00
|
|
|
deviceError = std::format("{} (the device's set-up is not run again)", e.what());
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
deviceReady = true;
|
|
|
|
|
}
|
|
|
|
|
window.emplace(widthDp, heightDp, title);
|
Ui, main: the input method, the app id, and touch through the pointer path
With the Crafter.Graphics branch delivering touch (the first finger as the
pointer), zwp_text_input_v3 and xdg app ids, the app:
- sets its app id on the window;
- tells the compositor which field has the focus and where its caret is,
after every frame that changed it: the number field at once (purpose
phone), the message field on a tap or a key; a sheet or leaving the
screen takes it back;
- shows the input method's composing text in the accent colour at the
cursor, each run placed at the advance the one before it was drawn
with, applies its deletions by code point and leaves the composing
text to the input method, and takes its committed text as typed (the
composing text and its deletions are the core's Edit, in tests/Edit; a
draft kept for a conversation that is left keeps a word still being
composed as text); a tap inside the composing text leaves the cursor
where it is, a tap elsewhere in the field commits the word where it
was typed and resets the input method, as Send does, so the half-typed
word does not move to the tap; a sheet, a hide and leaving a screen by
Open (over the number screen or over another conversation), by Back or
by the + end the composition the same way and at once (EndComposition:
the word committed, the input method told), since the input method
starts afresh after, and left on until the next frame it would send
its next commit to the screen that opens or have it dropped. The
message field starts unfocused, as on a phone, and the caret blinks
only in a focused field;
- sends what the field shows: Send, like Start, reads the shown text
once, the composing word included, and clears the field only once the
store took it (a field of nothing but spaces and line breaks is
cleared with nothing sent); the field keeps the focus while the input
method is reset (disabled, enabled again the next frame) — a refused
text leaves the field and the composing word as they are; Start reads
the shown text once — the key and the address dialled come from it —
so a refused number leaves the composing word to the input method;
- logs the window's size on every resize, and which conversation was
opened — under --headless; a plain start names no correspondent in its
log, as the rest of the app does not.
Touch takes the mouse's gesture path, and a touch the compositor cancels
(a gesture of its own) arrives as a release without the finger's
touch-up: it is fed to the gestures as a cancel, so it taps nothing.
Tested: tests/Edit (the composing text kept by a deletion, and put into
the field's text by ComposeCommitPreedit).
2026-10-18 02:30:01 +02:00
|
|
|
window->SetAppId(appId);
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
VkCommandBuffer init = window->StartInit();
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
heap.Initialize(16, 48, 4); // buffers: four layers, three buffers each, per frame in flight (36 at three frames; the rest spare)
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
window->descriptorHeap = &heap;
|
|
|
|
|
font.emplace(assetDir / "NotoSans-Regular.ttf");
|
|
|
|
|
atlas.Initialize(init);
|
|
|
|
|
ui.fontAtlas = &atlas;
|
|
|
|
|
ui.Initialize(*window, heap, init, assetDir / "ui-quads.comp.spv", assetDir / "ui-circles.comp.spv", assetDir / "ui-images.comp.spv", assetDir / "ui-text.comp.spv", assetDir / "ui-fused.comp.spv");
|
|
|
|
|
window->passes.push_back(&ui);
|
|
|
|
|
background.Create(ui, atlas, 4, 4, 64);
|
|
|
|
|
content.Create(ui, atlas, 2048, 256, 16384);
|
|
|
|
|
chrome.Create(ui, atlas, 256, 32, 2048);
|
|
|
|
|
overlay.Create(ui, atlas, 128, 16, 1024);
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
buildSub.emplace(&ui.onBuild, [this](Crafter::UIBuildArgs a) { Frame(a.cmd, a.frameIdx); });
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
wrapper.emplace([this](std::uint32_t cp, float px) { return static_cast<float>(font->AdvanceUnits(cp)) * font->ScaleForSize(px); });
|
|
|
|
|
window->FinishInit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Crafter::Window& Window() noexcept { return *window; }
|
Ui, project: on screen means active and not suspended; Crafter.Graphics at c006519
A conversation counted as on screen while its window was up and no
close was pending, and a text for the conversation on screen is stored
read and not notified. A window is up behind a lock screen too, behind
another application, minimised, with the display off: a text for the
conversation left open there was marked read unseen, and no
notification told of it.
The compositor says of a window whether it counts as the active one and
whether it is ordinarily being repainted: xdg_toplevel's `activated`
state and, from version 6 of xdg_wm_base, `suspended`. The pinned
library dropped both. Crafter.Graphics c006519, one commit on the pin
before, keeps them on the window (Window::activated, suspended) and
fires onToplevelState when a configure changes either.
Now the window is on screen while it is up, no close is pending, and
the compositor counts it active and has not suspended it: both, since
which of the two a lock screen or another window in front changes is
the compositor's choice. When the compositor's word changes the app
does what it does at a close and at a Show: out of sight Sync is told
that no conversation is open, so a text is stored unread and notified;
in sight again the open conversation is read and its notification
withdrawn. Opened waits for it too: a conversation is read once its
window is on screen in this sense, not because the window was made or
the conversation opened in it. A window that is visible beside the
active one counts as not on screen, and its texts notify until it is
the active one. Under --headless the log has the compositor's word at
each change after the window is made.
Tested: on the bench, the build before against this one on KWin 6.8.0,
a text for the open conversation in each state of the window. Behind
KWin's lock screen, behind another application's window, minimised and
with the display off it was stored read with no notification; it is
stored unread and notified, and the notification goes when the window
is on screen again. KWin reports the window not active behind the other
application, suspended with the display off, and both under the lock
and minimised. A conversation opened while the app has no window and
another application is active gets a window KWin makes the active one,
and is read; one opened in a window that is behind another
application's stays unread until that window is active.
2026-11-17 00:57:08 +01:00
|
|
|
const Crafter::Window& Window() const noexcept { return *window; }
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
Crafter::Font& Font() noexcept { return *font; }
|
|
|
|
|
WordWrapper& Wrapper() noexcept { return *wrapper; }
|
|
|
|
|
float Scale() const noexcept { return window->scale > 0 ? window->scale : 1.0f; }
|
|
|
|
|
float Dp(float dp) const noexcept { return std::round(dp * Scale()); }
|
|
|
|
|
float Width() const noexcept { return static_cast<float>(window->width); }
|
|
|
|
|
float Height() const noexcept { return static_cast<float>(window->height); }
|
|
|
|
|
float Ascent(float px) { return font->AscentPx(px); }
|
|
|
|
|
float LineHeight(float px) { return font->LineHeight(px); }
|
|
|
|
|
// A line's width as DrawText advances it (the font's unrounded
|
|
|
|
|
// advances, none for a newline), so a caret or a following run lands
|
|
|
|
|
// where the glyphs end.
|
|
|
|
|
float TextWidth(std::string_view text, float px) {
|
|
|
|
|
const float scale = font->ScaleForSize(px);
|
|
|
|
|
float width = 0;
|
|
|
|
|
for (std::size_t i = 0; i < text.size();) {
|
|
|
|
|
const std::uint32_t cp = DecodeUtf8(text, i);
|
|
|
|
|
if (cp == 0) break;
|
|
|
|
|
if (cp != '\n') width += static_cast<float>(font->AdvanceUnits(cp)) * scale;
|
|
|
|
|
}
|
|
|
|
|
return width;
|
|
|
|
|
}
|
|
|
|
|
|
Ui: the compose field and the send bar
A text message needs several lines and UTF-8, and the library's
InputField is one line edited by byte, so the field is the app's own.
Its state and editing are the core's (ImsdMessages:Edit, tested without
a window): a plain struct, insertion at the cursor, Backspace and Delete
by code point, Home and End within the line, a newline. Ui:Compose turns
the keys into those edits and draws the field one to five lines tall —
as many as half the area under the header and the banner holds, and one
at the least — with the canvas's word wrapper (a longer text shows the
lines that end at the caret's, or the first ones while the caret is
among them), a placeholder when empty, the caret at the cursor, and a
tap placing the cursor at the nearest byte by the widths the glyphs are
drawn at, in the text as it is when the tap lands (an edit since the
last frame only asked for one; a field no frame has laid out yet takes a
tap as one at its text's end; a tap at or past the last line's end asks
for the text's end, where a space the wrapper hung off the line may be).
The bar under a conversation holds the field and Send, enabled only with
text, a sendable status and an address to send to; Send hands the text
to Sync with that address and clears the field (a store that refuses the
text keeps the draft) (Model's SendAddress: as a link gave it, else the
latest message's — the network's form of a received text, the dialled
form of ours — never the key, whose completed country code is a guess
that groups; a conversation with neither has Send off, and so has one
whose address is not international — a national number, a short code;
typed, linked or the message's — and was typed or written under another
SIM's plan than the one known now, which the plan each row and the view
carry tells (the view's is that of the SIM the address was typed under,
which Number's AfterStatus keeps; Number's AnotherPlan, its second
caller)); Sync's StateChanged moves the bubble's caption. Keys reach the
field while a conversation is open (Escape goes back, Ctrl+Enter sends),
a held key repeats through a timer since frames are on demand, and the
caret blinks on one. A text typed and not sent is its conversation's,
not the view's: leaving the conversation (Back, another one opened by a
notification or a link) keeps it by the conversation's key for the run,
and opening the conversation again takes it up (Edit's Drafts: an empty
field keeps nothing and drops nothing; the draft of a typed or linked
address follows imsd's status as the open conversation's key does —
Number's AfterStatus over the address and the plan kept with it — so one
left before the status brought the country code is found under the key
the address makes afterwards; and a second text kept under one key — two
keys that became one — goes after the first on a line of its own).
Tested: tests/Model, the address a text goes to (the typed or linked
one, the latest message's, none for an emptied conversation, none under
another SIM's plan than it was typed or written under — a national
number with or without a trunk prefix under another country's SIM, a
short code under another operator's too, though dialled under the same
operator, the own number read when it was typed or not; a national
number typed before the own number was read, none under another operator
— an international one under any — and a typed address judged by its own
plan, whatever the latest row's); tests/Edit (code points of one to four
bytes, the moves within a line, the edits that change nothing, the first
line shown as the caret moves down a long text; the drafts: kept and
taken up by key with the cursor, taken once, an empty field keeping and
dropping nothing, one per conversation, a second text under one key on a
line of its own; a typed address's following the status — moved when the
code comes, not while texts are stored under its key, not under another
SIM's status, a list conversation's left alone and the store not asked,
the learned plan kept, two keys that became one keeping both texts).
2026-10-18 00:35:39 +02:00
|
|
|
// The byte offset in a line nearest to x from its start, by the
|
|
|
|
|
// widths TextWidth measures: where a tap puts the cursor.
|
|
|
|
|
std::size_t NearestByte(std::string_view line, float px, float x) {
|
|
|
|
|
if (x <= 0) return 0;
|
|
|
|
|
const float scale = font->ScaleForSize(px);
|
|
|
|
|
float width = 0;
|
|
|
|
|
float bestDistance = x;
|
|
|
|
|
std::size_t best = 0;
|
|
|
|
|
for (std::size_t i = 0; i < line.size();) {
|
|
|
|
|
const std::uint32_t cp = DecodeUtf8(line, i);
|
|
|
|
|
if (cp == 0) break;
|
|
|
|
|
if (cp != '\n') width += static_cast<float>(font->AdvanceUnits(cp)) * scale;
|
|
|
|
|
const float distance = std::abs(x - width);
|
|
|
|
|
if (distance > bestDistance) break; // the widths only grow; at a tie the later offset wins (past a zero-width mark)
|
|
|
|
|
bestDistance = distance;
|
|
|
|
|
best = i;
|
|
|
|
|
}
|
|
|
|
|
return best;
|
|
|
|
|
}
|
|
|
|
|
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
// The baseline that centres one line of text in a box.
|
|
|
|
|
float CenteredBaseline(Box b, float px) { return b.y + (b.h - LineHeight(px)) / 2.0f + Ascent(px); }
|
|
|
|
|
|
|
|
|
|
// True when any layer dropped items this frame (buffers too small).
|
|
|
|
|
bool Overflowed() const noexcept { return background.Overflowed() || content.Overflowed() || chrome.Overflowed() || overlay.Overflowed(); }
|
|
|
|
|
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
// Glyphs drawn blank this frame for want of an atlas cell: they get
|
|
|
|
|
// one when a later frame begins, from glyphs not drawn in the last
|
|
|
|
|
// framesInFlight + 1 frames (Gesture's FrameWait asks for the frames).
|
|
|
|
|
std::uint32_t GlyphsWaiting() const noexcept { return background.GlyphsWaiting() + content.GlyphsWaiting() + chrome.GlyphsWaiting() + overlay.GlyphsWaiting(); }
|
|
|
|
|
static constexpr std::uint32_t framesInFlight = Crafter::Window::numFrames;
|
|
|
|
|
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
private:
|
Gesture, Ui, project: Crafter.Graphics at 3f646ec, whose key repeat fires once at the delay
The pinned library's key repeat counted the compositor's delay as missed
periods: lastFireTime was the press itself and the catch-up loop fired
once per period since it, so the first repeat after the delay was a
burst of floor(delay / period) events — with rate 25 and delay 600 a
held Backspace deleted sixteen characters at the delay mark and a held
letter put fifteen copies in the field, from a hardware keyboard and
from an on-screen keyboard that sends Backspace as key events; a rate
above 1000 made the period zero and the loop endless. Crafter.Graphics
3f646ec lands the first repeat at the delay, keeps the period at a
millisecond or more and caps the catch-up after a stalled frame; the
app's own repeat timer and the frame path's TickKeyRepeats need nothing
more.
The pin moves from 6f471ca to the library's master of 2026-11-01, eight
commits on: the swapchain sized for its present mode and frames in
flight keyed by frame, the font atlas's SDF decoded in atlas pixels and
glyphs that find no room given a cell at the next frame, Win32 linking
and titles and a Win32 test's stand-in dropped, the library's AGENTS
template, the key repeat. One contract changes with a4be6f1: once the
atlas evicts, a glyph item is good for the frame it was shaped for, so
item buffers must be one set per frame in flight (the library's usage
contract since; its HelloUI shows it). The Canvas's layers keep
Window::numFrames sets of their quad, circle and glyph buffers and fill
the one at UIBuildArgs::frameIdx, where one set had served the three
frames paced by frame callbacks — about 3 MB of host-visible memory in
all; the descriptor heap grows to hold their slots. The atlas's contract
changed with the eviction: a glyph that finds no free cell draws blank
and gets one when the next frame begins — a frame this app, drawing on
demand, has to ask for: the layers count the glyphs drawn blank
(FontAtlas::Lookup, not Resident) and Build asks for another frame while
glyphs wait, until the frames in flight plus one have passed without a
cell gained — a cell comes from glyphs not drawn in those frames, so a
screen change needs that many before the cells it displaced come free
(FrameWait in Gesture, beside the fling's frame rule, added with this,
its use — restarted by every redraw request and by each frame of a
fling, which changes what is drawn as a request does — and tested
there). The other contracts this app relies on hold at the new commit:
the disable ends the composition and clears the shown record,
CaptureNextFrame writes its PNG inside the frame that records the copy,
a touch's up precedes the synthesised release, the deletion queue still
wants the app's drain when a window ends (DrainDeletions), libevdev
stays vendored; the licence texts are unchanged.
2026-11-01 00:59:06 +01:00
|
|
|
void Frame(VkCommandBuffer cmd, std::uint32_t frameIdx) {
|
|
|
|
|
background.Begin(frameIdx);
|
|
|
|
|
content.Begin(frameIdx);
|
|
|
|
|
chrome.Begin(frameIdx);
|
|
|
|
|
overlay.Begin(frameIdx);
|
Ui: the window on Crafter.Graphics, driven from the GLib main loop
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
2026-10-18 00:26:09 +02:00
|
|
|
background.Quad({ 0, 0, Width(), Height() }, theme.bg);
|
|
|
|
|
if (onDraw) onDraw(cmd);
|
|
|
|
|
background.Submit(cmd, ui);
|
|
|
|
|
content.Submit(cmd, ui);
|
|
|
|
|
chrome.Submit(cmd, ui);
|
|
|
|
|
overlay.Submit(cmd, ui);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|