imsd-messages/interfaces/ImsdMessages.Ui-App.cppm

1244 lines
61 KiB
Text
Raw Normal View History

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®
// lint-disable-file no-char-pointer
/*
ImsdMessages.Ui:App — the window as a whole: created on the first Show and
again after a Hide, fed by
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
Sync through the shell, drawn from the store on demand. Mouse events
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
become gestures (the library's first finger drives the pointer; a touch
the compositor cancels is a cancel), a tap is resolved against the
regions the last frame recorded, scrolling is by wheel, drag or fling,
and nothing is drawn while nothing changes.
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
*/
module;
#include <gio/gio.h>
#include <time.h>
#include "vulkan/vulkan.h"
export module ImsdMessages.Ui:App;
import std;
import Crafter.Graphics;
import Crafter.Event;
import ImsdMessages;
import :Loop;
import :Canvas;
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
import :Compose;
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
import :Screens;
export namespace ImsdMessages::Ui {
class App {
public:
App(MessageStore& store, std::filesystem::path assetDir, std::filesystem::path cacheDir) : store(store), assetDir(std::move(assetDir)), cacheDir(std::move(cacheDir)) {}
~App() {
Shutdown();
if (longPressTimer) g_source_remove(longPressTimer);
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
if (repeatTimer) g_source_remove(repeatTimer);
if (hideIdle) g_source_remove(hideIdle);
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
}
// Tears the window down in order: the GPU first finishes the frame
// it may still be drawing from the item buffers, then the listeners
// let go of the window, then the frame driver and the canvas go, and
// the display source last.
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 Shutdown() {
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
showAfterHide = false;
Teardown();
source.reset();
}
private:
void Teardown() {
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 (!canvas) return;
StopFling();
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
// The composition ends with the window: committed into the field,
// and the input method told (the disable Send's reset sends), so
// neither it nor the library carries the word into the next window.
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
EndComposition();
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
vkDeviceWaitIdle(Crafter::Device::device);
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
if (blinkTimer) g_source_remove(blinkTimer);
blinkTimer = 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
downSub.reset();
upSub.reset();
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
touchDownSub.reset();
touchUpSub.reset();
touchCancelSub.reset();
touch.reset();
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
moveSub.reset();
scrollSub.reset();
keySub.reset();
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
keyUpSub.reset();
textSub.reset();
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
preeditSub.reset();
deleteSub.reset();
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
resizeSub.reset();
closeSub.reset();
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
seenSub.reset();
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
day.reset();
frames.reset();
canvas.reset();
// The library queues a window's buffers, shaders and pipelines
// for deletion; with no window left no frame frees them, and
// the device is idle here.
Crafter::Device::DrainDeletions();
gestures = GestureDetector{};
hits.clear();
hitKeys.clear();
hitMessages.clear();
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
textSinceFrame.clear();
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
frameFailed = false;
}
static gboolean OnHideIdle(gpointer data) {
App& self = *static_cast<App*>(data);
self.hideIdle = 0;
self.Hide();
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
if (std::exchange(self.showAfterHide, false)) self.Show(); // asked for while a failed window waited for this Hide
return G_SOURCE_REMOVE;
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 gboolean OnScreenshot(gpointer data) {
App& self = *static_cast<App*>(data);
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
if (self.canvas && !self.frameFailed) {
try {
self.canvas->Window().CaptureNextFrame(self.screenshotPath);
self.canvas->Window().Update();
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
self.FrameDrawn();
self.Log(std::format("screenshot written to {} ({}x{} px)", self.screenshotPath.string(), self.canvas->Window().width, self.canvas->Window().height));
self.exitCode = 0; // a failure until written (main)
} catch (const std::exception& e) {
// The library throws when the capture fails (a Vulkan call,
// the PNG's write): the bench learns it from the log and the
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
// exit status. The capture's frame is a frame: one that
// threw is not known to have shown anything (FrameLost).
self.Log(std::format("screenshot not written to {}: {}", self.screenshotPath.string(), e.what()));
self.exitCode = 1;
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
self.FrameLost(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
} else {
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
// No window to render it — none could be made, it went
// between the request and the capture, or it failed in a
// frame and waits for its Hide (another Update on it could
// wait for ever on a fence the failed frame reset): logged,
// and the run ends with exit 1, so a bench learns it from both.
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
self.Log(std::format("screenshot not written to {}: no window", self.screenshotPath.string()));
self.exitCode = 1;
}
if (self.onQuit) self.onQuit();
return G_SOURCE_REMOVE;
}
public:
App(const App&) = delete;
App& operator=(const App&) = delete;
Sync* sync = nullptr;
bool closeQuits = false; // no session bus: a close ends the process, since nothing could show the window again
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
bool verbose = false; // --headless: log lines may name a correspondent
std::string appId = "net.catcrafts.ImsdMessages"; // the xdg app id; main sets it from the bus layer's constant
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
std::function<void()> onQuit; // the screenshot's run is over, the window closed with no bus to come back on, or one was asked for of a lost device
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::function<void(const std::string&)> onConversationOpened; // the notification goes
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
std::function<void(const std::string&)> onConversationDeleted; // so does the notification
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
std::function<void(const Message&)> onUnseen; // a text made read that no frame is known to have shown (GiveBack): notified after all
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::function<void(std::string_view)> onLog;
std::function<void()> onDisplayLost; // the compositor's connection broke
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
std::int32_t exitCode = 0; // what main returns when nothing else decided: 1 for a screenshot not written, and for an end over a window that failed or a device that is lost
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 Visible() const noexcept { return canvas.has_value(); }
// The system's appearance: dark or light, and its accent colour.
// Applied to the window at once and kept for the next one.
void SetTheme(bool dark, std::optional<std::array<float, 3>> accent) {
theme = dark ? Theme::Dark() : Theme::Light();
if (accent) theme.Accent(*accent);
if (canvas) canvas->theme = theme;
Dirty();
}
// Cancels a close's deferred Hide: a Show or an Open before it runs
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
// keeps the window — not one that failed in a frame, whose Hide
// stands (Show serves the request after it). True when there was
// one.
bool KeepWindow() {
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
if (!hideIdle || frameFailed) return false;
g_source_remove(hideIdle);
hideIdle = 0;
return true;
}
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
// Whether the screens count as seen: the window is up, no close is
// waiting for its Hide, and the compositor counts it the active
// window and has not suspended it (the library's Window::activated
// and suspended, xdg_toplevel's states). A window behind a lock
// screen or another application, minimised or with the display
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
// off, is up all the same; one that failed draws nothing more.
bool OnScreen() const noexcept { return canvas.has_value() && !frameFailed && hideIdle == 0 && canvas->Window().activated && !canvas->Window().suspended; }
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
// The compositor's word on the window changed. Out of sight, no
// conversation is on screen: a text for the open one is stored
// unread and notified, as after a close. In sight again, the open
// conversation is read, as at a Show.
void SeenChanged() {
if (verbose) Log(std::format("window {}{}", canvas->Window().activated ? "active" : "not active", canvas->Window().suspended ? ", suspended" : ""));
if (OnScreen()) Opened();
else if (sync) sync->SetOpenConversation(std::nullopt);
}
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
// Creates the window; shows it again after a Hide. With the device
// lost (CheckDevice) there is none to make: the request ends the
// process instead (EndOverDevice).
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 Show() {
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
if (deviceLost) {
EndOverDevice();
return;
}
if (canvas && frameFailed) {
// The window failed in a frame and goes with its Hide, which
// is not hurried from here: Show is reachable from that
// window's own listeners (a tap that opens). The request is
// served after the Hide (OnHideIdle).
showAfterHide = true;
return;
}
const bool kept = KeepWindow();
if (canvas) {
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
if (kept) Opened(); // a close taken back: the kept conversation is on screen again, if the window is seen
return;
}
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
canvas.emplace();
try {
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
canvas->Create(400, 800, "Messages", appId, assetDir, 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
} catch (const std::exception& e) {
// No display, a compositor without a global the library
// needs, no Vulkan device: the library throws, and the app
// has no window. It says so and runs on without one — a
// resident instance keeps importing. A later Show fails at
// once with the same reason when the device's set-up failed
// (it runs only once), and tries again past it (an asset
// missing): what the failed Create queued is drained here,
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
// as Teardown drains, since no frame will. A device that
// was set up and is lost since makes no window in this
// process again: the process ends (EndOverDevice).
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
canvas.reset();
Crafter::Device::DrainDeletions();
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
Log(std::format("no window: {}", e.what()));
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
CheckDevice(e.what());
if (deviceLost) {
GiveBack(); // what the window before this one drew last, the device may not have finished
EndOverDevice();
}
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;
}
canvas->theme = theme;
if (!source) {
source.emplace(Crafter::Device::display);
source->onLost = [this] {
if (onDisplayLost) onDisplayLost();
};
Log(std::format("vulkan: {}, descriptors by {}; window scale {}", Crafter::Device::deviceProperties.deviceName, Crafter::Device::descriptorHeapSupported ? "heap" : "sets", canvas->Window().scale));
}
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
frames.emplace(canvas->Window());
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
frames->onFrame = [this] {
if (frameFailed) return; // until the close's Hide has taken it
try {
canvas->Window().Update();
FrameDrawn();
if (!readUnshown.empty()) frames->RequestRedraw(); // the frames that prove the one a text was drawn in
} catch (const std::exception& e) {
// Closed as at the compositor's word: the teardown is
// the loop's, since this runs inside the frame callback.
// Without a session bus the close ends the process, and
// not as a close the user asked for.
WindowFailed(e.what());
if (closeQuits) exitCode = 1;
Close();
}
};
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
day.emplace();
// The captions name the day ("Today", a clock time for today's
// text): drawn again when it changes.
day->onDay = [this] {
Log("the day changed");
Dirty();
};
canvas->onDraw = [this](VkCommandBuffer cmd) { Build(cmd); };
Crafter::Window& w = canvas->Window();
downSub.emplace(&w.onMouseLeftClick, [this] { Pointer(PointerPhase::Down); });
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
// The first finger drives the pointer. A touch the compositor
// cancels (a gesture of its own) arrives as a release without the
// finger's touch-up: a cancel, which taps nothing.
touchDownSub.emplace(&w.onTouchDown, [this](Crafter::TouchPoint t) {
if (canvas->Window().primaryTouchId < 0) {
touch = t.id;
touchUp = false;
}
});
touchUpSub.emplace(&w.onTouchUp, [this](Crafter::TouchPoint t) {
if (touch && t.id == *touch) touchUp = true;
});
upSub.emplace(&w.onMouseLeftRelease, [this] {
const bool cancelled = touch && !touchUp;
touch.reset();
Pointer(cancelled ? PointerPhase::Cancel : PointerPhase::Up);
});
touchCancelSub.emplace(&w.onTouchCancel, [this] {
touch.reset();
if (gestures.Pressed()) Pointer(PointerPhase::Cancel);
});
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
moveSub.emplace(&w.onMouseMove, [this] {
if (gestures.Pressed()) Pointer(PointerPhase::Move);
});
scrollSub.emplace(&w.onMouseScroll, [this](std::uint32_t raw) {
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (sheet || fresh) return; // a sheet takes the wheel as it takes the taps; the new-conversation screen scrolls nothing
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
const std::int32_t detents = static_cast<std::int32_t>(raw);
ActiveScroll().ScrollBy(static_cast<float>(detents) * canvas->Dp(48));
if (view) view->stickToBottom = false;
Dirty();
});
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
keySub.emplace(&w.onRawKeyDown, [this](Crafter::KeyCode code) { Key(code); });
keyUpSub.emplace(&w.onRawKeyUp, [this](Crafter::KeyCode) {
if (canvas->Window().heldKeys.empty() && repeatTimer) {
g_source_remove(repeatTimer);
repeatTimer = 0;
}
});
textSub.emplace(&w.onTextInput, [this](const std::string_view text) {
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (sheet) return;
if (fresh) {
// One line: a pasted number's line breaks are dropped, the rest kept.
std::string oneLine(text);
std::erase_if(oneLine, [](char c) { return c == '\n' || c == '\r'; });
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
fresh->field.preedit.clear();
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
ComposeInsert(fresh->field, oneLine);
fresh->error.clear();
ShowCaret();
} else if (view) {
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
view->compose.preedit.clear();
view->compose.focused = true;
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
ComposeInsert(view->compose, text);
ShowCaret();
}
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
});
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
// The input method's composing text and its deletions; what it
// commits arrives as text input above.
preeditSub.emplace(&w.onPreedit, [this](const std::string_view text) {
if (sheet) return;
if (ComposeState* field = FocusedField()) {
field->preedit = std::string(text);
ShowCaret();
}
});
deleteSub.emplace(&w.onTextInputDelete, [this](Crafter::TextDelete d) {
if (sheet) return;
if (ComposeState* field = FocusedField()) {
ComposeDeleteAround(*field, d.beforeBytes, d.afterBytes);
ShowCaret();
}
});
resizeSub.emplace(&w.onResize, [this] {
if (verbose) Log(std::format("window {}x{} px", canvas->Window().width, canvas->Window().height));
Dirty();
});
closeSub.emplace(&w.onClose, [this] { Close(); });
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
seenSub.emplace(&w.onToplevelState, [this] { SeenChanged(); });
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
Reload();
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
Opened(); // read once the new window counts as seen: now, or at the call that finds it so
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (fresh || (view && view->compose.focused)) ShowCaret(); // the blink a hide stopped
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
try {
w.Render();
FrameDrawn();
} catch (const std::exception& e) {
// The first frame failed as a later one can: no window,
// taken down here (nothing of the library's is on the
// stack). A start that asked for one ends with exit 1
// (main); a resident instance runs on, unless the device
// is lost.
WindowFailed(e.what());
Teardown();
if (deviceLost) EndOverDevice();
return;
}
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
frames->RequestRedraw();
}
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
// A frame threw: the library does at a Vulkan error (the device
// lost, its memory exhausted). That costs the window and not the
// process, which would end in std::terminate with nothing to catch
// it under the frame callback: said once, nothing is on screen from
// here, and the window goes — an instance that can be asked for a
// window again runs on without one, importing and notifying. Only
// a frame's error comes by here: one the library meets under its
// own listeners (the swapchain it rebuilds at a resize) is under
// no catch of the app's.
void WindowFailed(std::string_view what) {
Log(std::format("the window failed: {}", what));
FrameLost(what);
}
// What a frame that threw leaves, the screenshot's too: nothing more
// is drawn on the window and nothing is on screen from here, the
// device may be lost, and the texts made read for a frame nobody is
// known to have seen are given back.
void FrameLost(std::string_view what) {
frameFailed = true;
CheckDevice(what);
if (sync) sync->SetOpenConversation(std::nullopt);
GiveBack();
}
// The texts made read that the device has not answered for
// (readUnshown; the frame that failed is often the one a text asked
// for): unread again, and notified, since nobody is known to have
// seen them. A read that throws leaves the rest as they are, and is
// said.
void GiveBack() {
std::uint32_t unseen = 0;
try {
for (const Unshown& u : readUnshown) {
std::optional<Message> m = store.Get(u.id);
if (!m || !m->read) continue; // deleted since, or not left read
store.SetRead(u.id, false); // in place: the row reads unread even when the store refuses the flush
m->read = false;
++unseen;
if (onUnseen) onUnseen(*m);
}
} catch (const std::exception& e) {
Log(std::format("the texts no frame showed were not all made unread: {}", e.what()));
}
readUnshown.clear();
if (unseen > 0) Log(std::format("{} text(s) no frame showed: unread again", unseen));
}
// A text was made read, its conversation counting as on screen: kept
// until the device has answered for the next frame (readUnshown).
void MadeRead(std::uint64_t id) { readUnshown.push_back({ id, framesDrawn + 1 + Canvas::framesInFlight }); }
// A frame was drawn without a throw. The library's Render begins by
// waiting for the frame that had its slot, the frames in flight
// before it, and went on to submit and present: the device's word
// that the earlier frame is finished.
void FrameDrawn() {
++framesDrawn;
std::erase_if(readUnshown, [this](const Unshown& u) { return u.shownBy <= framesDrawn; });
}
// Whether the device is lost, by the failure's own word: the library
// throws the failed call's result by its name
// (Device::CheckVkResult), and VK_ERROR_DEVICE_LOST is a lost
// device's. It stays lost, and the device is set up once per process
// (Canvas::Create): this process makes no window again.
void CheckDevice(std::string_view what) {
if (deviceLost || what != "VK_ERROR_DEVICE_LOST") return;
deviceLost = true;
Log("the Vulkan device is lost: this process can make no window again");
}
// A window was asked for and the device is lost: the process ends in
// order with exit 1, so that the next start has a new device.
void EndOverDevice() {
if (!endSaid) Log("a window was asked for and the device is lost: quitting, the next start has a new one");
endSaid = true;
exitCode = 1;
if (onQuit) onQuit();
}
// The window's close: the compositor's, the bench's (--hide-after,
// --hide-every), or the one a failed frame makes. Closing hides: the
// process stays for the next text (the resident model); --quit or a
// signal ends it. The library runs onClose from inside its own
// listener, so the teardown is deferred to the loop; a Show before
// it runs keeps the window. The conversation is off the screen from
// here, not from the Hide: a text for it meanwhile is unread, and
// notified. Without a session bus nothing could show the window
// again, so there a close ends the process.
void Close() {
if (!canvas) return;
if (closeQuits) {
Log("window closed; no session bus to come back on: quitting");
if (onQuit) onQuit();
return;
}
if (hideIdle) return;
if (sync) sync->SetOpenConversation(std::nullopt);
hideIdle = g_idle_add(OnHideIdle, this);
}
// Tears the window down and keeps everything else: the store, the
// screens (a conversation left open comes back on Show; its texts
// stay unread meanwhile), the bus.
void Hide() {
if (!canvas) return;
Teardown();
Log("window hidden; still running");
}
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
// Shows the window on a conversation. Without a window (Show says
main: show the window; --screenshot and --quit-after The executable shows the window at start unless --daemon (which --headless and --send imply), on Activate and Open from a second launch or a notification (of the URIs an Open carries, its first sms: link), and on an sms: link, which opens the conversation of its first recipient at once (Number's SmsUriRecipient: the scheme in any case, the fields after '?' dropped, percent-escapes decoded; then ConversationKey with the country code known at that moment — --country's, else the one imsd's status gave once it is in, else what the number itself carries — which takes NormalizeNumber's result as a phone number — E.164, or digits: a short code, a national number no country code completed — and nothing else), or just the window when it names no phone number; the conversation remembers the address as dialled and the plan of the SIM it was typed under, and that SIM's statuses move its key (Number's AfterStatus, one step, applied in App::Status: another SIM's status — another operator's, or without operators another own number's code, Number's SameSim — changes nothing, so a SIM change leaves the key and the plan the address was typed under; the same SIM's fills in what the plan lacks, and the key follows from its digits to the centre's stand-in and from any key to the own number's code once the plan has it, never from one stand-in's key to another's and not while the code is lost, the conversation it moves to shown at its latest message — and only while nothing is stored under the key: a text stored before the code arrived keeps the conversation on the key its rows carry). The shell forwards Sync's events to the window and the notifier closes a conversation's notification when it is opened (one closed while its Notify is on its way goes when the answer comes). --screenshot renders one frame outside the compositor's pacing 2.5 s after start — 600 ms later where it has to make the window first — and saves it as a PNG before quitting, or ends with exit 1 when no frame was captured — with a line when no window could render it or another instance is running (a flag that acts on the window finds none there: the run forwards nothing), and without one when the run ended before the capture (the display gone, a close that quits); a PNG the library cannot write is not noticed at this commit, and a capture that throws ends the process — the verification path for a machine without eyes, which must not depend on a desktop that repaints — and --quit-after ends a bench on its own clock (a number of seconds its timer can take: anything else is refused); a --send errand ended by anything but its final state — that clock — exits 2, as it does on a signal, its end latched before the loop stops; --screenshot beside --send or --quit is refused, neither having a window. The window is torn down in order before the bus client stops, and when the compositor's connection breaks the process ends, so the next launch starts afresh. A window the library cannot make (no display, no Vulkan driver) is logged by Ui's Show and the start ends with exit 1, as a start without its database does; a resident instance logs it and runs on without one, and a later Activate or Open logs the same at once, the device's set-up running only once. Tested: tests/Number, the sms: links (a query, an escape, a list, the scheme in capitals, no number), the keys of typed addresses, SameSim (the same operator, another operator of one country, a status without its operator, nothing known, own numbers' codes without operators) and AfterStatus through the statuses a typed address meets: the stand-in completing its digits while the plan learns the operator; another stand-in, a lost code and another operator's status — its own number's code the stand-in's or not — changing nothing; rows keeping the key while the plan learns the code; the own number's code moving the stand-in's key, at once or once nothing is stored; a key the own number's code made, and its plan, staying under another SIM and under its own SIM's stand-in; an own code that makes the stand-in's key; a short code; --country before the operator; no operators; no address; an international address, under another SIM and under its own; and the address as dialled making the key the address as typed made.
2026-10-18 00:26:09 +02:00
// why) nothing is on screen, so nothing is read or opened. `dialled`
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
// is the address as the user typed or a link gave it, what a text
// from here is sent to and what the status re-keys the conversation
// from (Status); "" from the list or a notification, where the
// latest message's address is (Destination).
main: show the window; --screenshot and --quit-after The executable shows the window at start unless --daemon (which --headless and --send imply), on Activate and Open from a second launch or a notification (of the URIs an Open carries, its first sms: link), and on an sms: link, which opens the conversation of its first recipient at once (Number's SmsUriRecipient: the scheme in any case, the fields after '?' dropped, percent-escapes decoded; then ConversationKey with the country code known at that moment — --country's, else the one imsd's status gave once it is in, else what the number itself carries — which takes NormalizeNumber's result as a phone number — E.164, or digits: a short code, a national number no country code completed — and nothing else), or just the window when it names no phone number; the conversation remembers the address as dialled and the plan of the SIM it was typed under, and that SIM's statuses move its key (Number's AfterStatus, one step, applied in App::Status: another SIM's status — another operator's, or without operators another own number's code, Number's SameSim — changes nothing, so a SIM change leaves the key and the plan the address was typed under; the same SIM's fills in what the plan lacks, and the key follows from its digits to the centre's stand-in and from any key to the own number's code once the plan has it, never from one stand-in's key to another's and not while the code is lost, the conversation it moves to shown at its latest message — and only while nothing is stored under the key: a text stored before the code arrived keeps the conversation on the key its rows carry). The shell forwards Sync's events to the window and the notifier closes a conversation's notification when it is opened (one closed while its Notify is on its way goes when the answer comes). --screenshot renders one frame outside the compositor's pacing 2.5 s after start — 600 ms later where it has to make the window first — and saves it as a PNG before quitting, or ends with exit 1 when no frame was captured — with a line when no window could render it or another instance is running (a flag that acts on the window finds none there: the run forwards nothing), and without one when the run ended before the capture (the display gone, a close that quits); a PNG the library cannot write is not noticed at this commit, and a capture that throws ends the process — the verification path for a machine without eyes, which must not depend on a desktop that repaints — and --quit-after ends a bench on its own clock (a number of seconds its timer can take: anything else is refused); a --send errand ended by anything but its final state — that clock — exits 2, as it does on a signal, its end latched before the loop stops; --screenshot beside --send or --quit is refused, neither having a window. The window is torn down in order before the bus client stops, and when the compositor's connection breaks the process ends, so the next launch starts afresh. A window the library cannot make (no display, no Vulkan driver) is logged by Ui's Show and the start ends with exit 1, as a start without its database does; a resident instance logs it and runs on without one, and a later Activate or Open logs the same at once, the device's set-up running only once. Tested: tests/Number, the sms: links (a query, an escape, a list, the scheme in capitals, no number), the keys of typed addresses, SameSim (the same operator, another operator of one country, a status without its operator, nothing known, own numbers' codes without operators) and AfterStatus through the statuses a typed address meets: the stand-in completing its digits while the plan learns the operator; another stand-in, a lost code and another operator's status — its own number's code the stand-in's or not — changing nothing; rows keeping the key while the plan learns the code; the own number's code moving the stand-in's key, at once or once nothing is stored; a key the own number's code made, and its plan, staying under another SIM and under its own SIM's stand-in; an own code that makes the stand-in's key; a short code; --country before the operator; no operators; no address; an international address, under another SIM and under its own; and the address as dialled making the key the address as typed made.
2026-10-18 00:26:09 +02:00
void Open(std::string_view key, std::string_view dialled = "") {
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 view may point into what opening replaces (a row's key in
// `hitKeys`, the notifier's record of the tapped notification):
// owned before anything runs.
const std::string opening(key);
key = opening;
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
// Over the number screen, or over another conversation: the
// field that goes ends its composition first.
if (fresh || (view && view->key != key)) EndComposition();
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
StopFling();
CancelGesture();
KeepWindow();
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
fresh.reset();
sheet.reset();
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 (!view || view->key != key) {
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
KeepDraft();
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
view.emplace();
view->key = std::string(key);
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
view->compose = drafts.Take(key);
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
}
main: show the window; --screenshot and --quit-after The executable shows the window at start unless --daemon (which --headless and --send imply), on Activate and Open from a second launch or a notification (of the URIs an Open carries, its first sms: link), and on an sms: link, which opens the conversation of its first recipient at once (Number's SmsUriRecipient: the scheme in any case, the fields after '?' dropped, percent-escapes decoded; then ConversationKey with the country code known at that moment — --country's, else the one imsd's status gave once it is in, else what the number itself carries — which takes NormalizeNumber's result as a phone number — E.164, or digits: a short code, a national number no country code completed — and nothing else), or just the window when it names no phone number; the conversation remembers the address as dialled and the plan of the SIM it was typed under, and that SIM's statuses move its key (Number's AfterStatus, one step, applied in App::Status: another SIM's status — another operator's, or without operators another own number's code, Number's SameSim — changes nothing, so a SIM change leaves the key and the plan the address was typed under; the same SIM's fills in what the plan lacks, and the key follows from its digits to the centre's stand-in and from any key to the own number's code once the plan has it, never from one stand-in's key to another's and not while the code is lost, the conversation it moves to shown at its latest message — and only while nothing is stored under the key: a text stored before the code arrived keeps the conversation on the key its rows carry). The shell forwards Sync's events to the window and the notifier closes a conversation's notification when it is opened (one closed while its Notify is on its way goes when the answer comes). --screenshot renders one frame outside the compositor's pacing 2.5 s after start — 600 ms later where it has to make the window first — and saves it as a PNG before quitting, or ends with exit 1 when no frame was captured — with a line when no window could render it or another instance is running (a flag that acts on the window finds none there: the run forwards nothing), and without one when the run ended before the capture (the display gone, a close that quits); a PNG the library cannot write is not noticed at this commit, and a capture that throws ends the process — the verification path for a machine without eyes, which must not depend on a desktop that repaints — and --quit-after ends a bench on its own clock (a number of seconds its timer can take: anything else is refused); a --send errand ended by anything but its final state — that clock — exits 2, as it does on a signal, its end latched before the loop stops; --screenshot beside --send or --quit is refused, neither having a window. The window is torn down in order before the bus client stops, and when the compositor's connection breaks the process ends, so the next launch starts afresh. A window the library cannot make (no display, no Vulkan driver) is logged by Ui's Show and the start ends with exit 1, as a start without its database does; a resident instance logs it and runs on without one, and a later Activate or Open logs the same at once, the device's set-up running only once. Tested: tests/Number, the sms: links (a query, an escape, a list, the scheme in capitals, no number), the keys of typed addresses, SameSim (the same operator, another operator of one country, a status without its operator, nothing known, own numbers' codes without operators) and AfterStatus through the statuses a typed address meets: the stand-in completing its digits while the plan learns the operator; another stand-in, a lost code and another operator's status — its own number's code the stand-in's or not — changing nothing; rows keeping the key while the plan learns the code; the own number's code moving the stand-in's key, at once or once nothing is stored; a key the own number's code made, and its plan, staying under another SIM and under its own SIM's stand-in; an own code that makes the stand-in's key; a short code; --country before the operator; no operators; no address; an international address, under another SIM and under its own; and the address as dialled making the key the address as typed made.
2026-10-18 00:26:09 +02:00
view->dialled = std::string(dialled);
view->dialledPlan = sync ? sync->Plan() : SimPlan{}; // for an address typed or linked now: the SIM's as known now
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
view->stickToBottom = true;
view->messages = store.Conversation(key);
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
if (verbose) Log(std::format("opened {}", key));
else Log("opened a conversation");
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
if (canvas && !frameFailed) Opened();
else Show();
ShowCaret();
}
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
// The conversation the window shows, while the screens count as
// seen (OnScreen): read, its notification gone, Sync told (a text
// for it is stored read). Until then nothing: SeenChanged or the
// next Show calls again.
void Opened() {
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
if (!view || !OnScreen()) return;
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
if (MarkOpenRead() > 0) Reload();
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 (sync) sync->SetOpenConversation(view->key);
if (onConversationOpened) onConversationOpened(view->key);
}
void Back() {
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
// Every exit is a screen change: a press held across it (Escape
// on a keyboard while a finger or a button is down) is cancelled,
// not resolved against what the next frame draws there.
if (sheet) {
CancelGesture();
sheet.reset();
Dirty();
return;
}
if (fresh) {
CancelGesture();
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
EndComposition();
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
fresh.reset();
Dirty();
return;
}
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 (!view) return;
StopFling();
CancelGesture();
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
EndComposition();
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
KeepDraft();
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
view.reset();
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
if (blinkTimer) {
g_source_remove(blinkTimer);
blinkTimer = 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
if (sync) sync->SetOpenConversation(std::nullopt);
Dirty();
}
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
// The screen behind the +.
void NewConversation() {
StopFling();
CancelGesture();
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
EndComposition();
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
KeepDraft();
view.reset();
sheet.reset();
fresh.emplace();
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
fresh->field.focused = true;
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
Show();
if (sync) sync->SetOpenConversation(std::nullopt);
ShowCaret();
}
// Start, from the new-conversation screen: a number becomes a key.
void Start() {
if (!fresh) return;
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
// One reading of the field, the composing text included: the key
// and the address dialled come from the same digits.
const std::string shown = ComposeShown(fresh->field);
const std::string key = ConversationKey(shown, sync ? sync->CountryCode() : "");
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (key.empty()) {
fresh->error = "Enter a phone number";
Dirty();
return;
}
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
const std::string dialled = DialledNumber(shown);
ResetTextInput(); // the composing text is used up: told before the screen changes, as Send does
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
fresh.reset();
Open(key, dialled);
}
// The bench's hands: types into the field of the open screen, and
// opens a sheet as a long press would.
void Prefill(std::string_view text) {
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
if (fresh) {
ComposeInsert(fresh->field, text);
} else if (view) {
view->compose.focused = true;
ComposeInsert(view->compose, text);
}
ShowCaret();
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
}
void BenchSheet(std::string_view which) {
// As a long press opens them: a conversation's sheet over the
// list, a message's over its conversation — and a line when the
// screen has nothing of the kind to press.
if (which == "conversation" && !view && !fresh && !convs.empty()) sheet = Sheet{ Sheet::Kind::DeleteConversation, convs.front().key, 0, "" };
else if (which == "message" && view && !view->messages.empty()) sheet = Sheet{ Sheet::Kind::MessageActions, view->key, view->messages.front().id, view->messages.front().text };
else Log(std::format("--bench-sheet {}: nothing on this screen to press", which));
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
if (sheet) EndComposition();
Dirty();
}
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 address a text from the open conversation is sent to (Model's
// SendAddress: as the user typed or a link gave it, else the latest
// message's, never the key); "" when none is known or it belongs to
// another SIM's plan, and Send is off.
std::string Destination() const { return SendAddress(view->dialled, view->dialledPlan, view->messages, sync ? sync->Plan() : SimPlan{}); }
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
// Sends what the field shows, a word the input method is still
// composing included, to the open conversation. The field keeps the
// focus for the next text, and the input method starts afresh.
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
void SendDraft() {
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
if (!view || !sync || !CanSend(status) || Destination().empty()) return;
// One reading of the shown text, the composing word included, as
// Start takes it: a store that refuses the text (its disk full)
// leaves the field and the composing word as they are; taken, the
// field is cleared and the input method told its text is used up.
std::string text = ComposeShown(view->compose);
if (text.empty()) return;
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
while (!text.empty() && (text.back() == '\n' || text.back() == ' ')) text.pop_back();
if (!text.empty() && sync->Send(view->key, Destination(), text) == Sync::kNotStored) return;
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
view->compose = ComposeState{ .focused = true };
ResetTextInput();
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
view->stickToBottom = true;
Dirty();
}
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
// Renders one frame now, outside the compositor's pacing, saves it as
// a PNG and asks to quit: the verification path for a machine without
// eyes, which must not depend on a desktop that repaints. A window
// created here first gets a moment for the compositor's configure,
// which sizes it (to the screen, on a phone) before the frame.
void ScreenshotThenQuit(const std::filesystem::path& path) {
const bool created = !canvas;
Show();
screenshotPath = path;
if (created && canvas) g_timeout_add(600, OnScreenshot, this);
else OnScreenshot(this); // a window already up, or none to come: now
}
// ---- fed by the shell from Sync's events ------------------------------
void Status(const AppStatus& s) {
status = s;
main: show the window; --screenshot and --quit-after The executable shows the window at start unless --daemon (which --headless and --send imply), on Activate and Open from a second launch or a notification (of the URIs an Open carries, its first sms: link), and on an sms: link, which opens the conversation of its first recipient at once (Number's SmsUriRecipient: the scheme in any case, the fields after '?' dropped, percent-escapes decoded; then ConversationKey with the country code known at that moment — --country's, else the one imsd's status gave once it is in, else what the number itself carries — which takes NormalizeNumber's result as a phone number — E.164, or digits: a short code, a national number no country code completed — and nothing else), or just the window when it names no phone number; the conversation remembers the address as dialled and the plan of the SIM it was typed under, and that SIM's statuses move its key (Number's AfterStatus, one step, applied in App::Status: another SIM's status — another operator's, or without operators another own number's code, Number's SameSim — changes nothing, so a SIM change leaves the key and the plan the address was typed under; the same SIM's fills in what the plan lacks, and the key follows from its digits to the centre's stand-in and from any key to the own number's code once the plan has it, never from one stand-in's key to another's and not while the code is lost, the conversation it moves to shown at its latest message — and only while nothing is stored under the key: a text stored before the code arrived keeps the conversation on the key its rows carry). The shell forwards Sync's events to the window and the notifier closes a conversation's notification when it is opened (one closed while its Notify is on its way goes when the answer comes). --screenshot renders one frame outside the compositor's pacing 2.5 s after start — 600 ms later where it has to make the window first — and saves it as a PNG before quitting, or ends with exit 1 when no frame was captured — with a line when no window could render it or another instance is running (a flag that acts on the window finds none there: the run forwards nothing), and without one when the run ended before the capture (the display gone, a close that quits); a PNG the library cannot write is not noticed at this commit, and a capture that throws ends the process — the verification path for a machine without eyes, which must not depend on a desktop that repaints — and --quit-after ends a bench on its own clock (a number of seconds its timer can take: anything else is refused); a --send errand ended by anything but its final state — that clock — exits 2, as it does on a signal, its end latched before the loop stops; --screenshot beside --send or --quit is refused, neither having a window. The window is torn down in order before the bus client stops, and when the compositor's connection breaks the process ends, so the next launch starts afresh. A window the library cannot make (no display, no Vulkan driver) is logged by Ui's Show and the start ends with exit 1, as a start without its database does; a resident instance logs it and runs on without one, and a later Activate or Open logs the same at once, the device's set-up running only once. Tested: tests/Number, the sms: links (a query, an escape, a list, the scheme in capitals, no number), the keys of typed addresses, SameSim (the same operator, another operator of one country, a status without its operator, nothing known, own numbers' codes without operators) and AfterStatus through the statuses a typed address meets: the stand-in completing its digits while the plan learns the operator; another stand-in, a lost code and another operator's status — its own number's code the stand-in's or not — changing nothing; rows keeping the key while the plan learns the code; the own number's code moving the stand-in's key, at once or once nothing is stored; a key the own number's code made, and its plan, staying under another SIM and under its own SIM's stand-in; an own code that makes the stand-in's key; a short code; --country before the operator; no operators; no address; an international address, under another SIM and under its own; and the address as dialled making the key the address as typed made.
2026-10-18 00:26:09 +02:00
// The open conversation's key and its typed address's plan follow
// the status of the SIM the address was typed under (Number's
// AfterStatus): one opened from a link or a typed number before
// imsd's status brought the code was keyed as its digits, and a
// text sent meanwhile (CanSend needs no code — a status without
// one, a registration before the re-read) keeps the conversation
// on the key its rows carry.
if (view && s.statusKnown && sync && !view->dialled.empty()) {
TypedKey typed = AfterStatus(view->dialled, { view->key, view->dialledPlan }, sync->Plan(), sync->CountryCode(), store.Conversation(view->key).empty());
view->dialledPlan = std::move(typed.plan);
if (typed.key != view->key) {
view->key = std::move(typed.key);
view->messages = store.Conversation(view->key);
// Shown as Open shows a conversation: at its latest message,
// whatever a turn of the wheel did over the empty one.
view->scroll = ScrollState{};
view->stickToBottom = true;
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
if (OnScreen()) Opened(); // not on screen, the kept conversation stays unread and keeps its notification: Show or SeenChanged opens it
main: show the window; --screenshot and --quit-after The executable shows the window at start unless --daemon (which --headless and --send imply), on Activate and Open from a second launch or a notification (of the URIs an Open carries, its first sms: link), and on an sms: link, which opens the conversation of its first recipient at once (Number's SmsUriRecipient: the scheme in any case, the fields after '?' dropped, percent-escapes decoded; then ConversationKey with the country code known at that moment — --country's, else the one imsd's status gave once it is in, else what the number itself carries — which takes NormalizeNumber's result as a phone number — E.164, or digits: a short code, a national number no country code completed — and nothing else), or just the window when it names no phone number; the conversation remembers the address as dialled and the plan of the SIM it was typed under, and that SIM's statuses move its key (Number's AfterStatus, one step, applied in App::Status: another SIM's status — another operator's, or without operators another own number's code, Number's SameSim — changes nothing, so a SIM change leaves the key and the plan the address was typed under; the same SIM's fills in what the plan lacks, and the key follows from its digits to the centre's stand-in and from any key to the own number's code once the plan has it, never from one stand-in's key to another's and not while the code is lost, the conversation it moves to shown at its latest message — and only while nothing is stored under the key: a text stored before the code arrived keeps the conversation on the key its rows carry). The shell forwards Sync's events to the window and the notifier closes a conversation's notification when it is opened (one closed while its Notify is on its way goes when the answer comes). --screenshot renders one frame outside the compositor's pacing 2.5 s after start — 600 ms later where it has to make the window first — and saves it as a PNG before quitting, or ends with exit 1 when no frame was captured — with a line when no window could render it or another instance is running (a flag that acts on the window finds none there: the run forwards nothing), and without one when the run ended before the capture (the display gone, a close that quits); a PNG the library cannot write is not noticed at this commit, and a capture that throws ends the process — the verification path for a machine without eyes, which must not depend on a desktop that repaints — and --quit-after ends a bench on its own clock (a number of seconds its timer can take: anything else is refused); a --send errand ended by anything but its final state — that clock — exits 2, as it does on a signal, its end latched before the loop stops; --screenshot beside --send or --quit is refused, neither having a window. The window is torn down in order before the bus client stops, and when the compositor's connection breaks the process ends, so the next launch starts afresh. A window the library cannot make (no display, no Vulkan driver) is logged by Ui's Show and the start ends with exit 1, as a start without its database does; a resident instance logs it and runs on without one, and a later Activate or Open logs the same at once, the device's set-up running only once. Tested: tests/Number, the sms: links (a query, an escape, a list, the scheme in capitals, no number), the keys of typed addresses, SameSim (the same operator, another operator of one country, a status without its operator, nothing known, own numbers' codes without operators) and AfterStatus through the statuses a typed address meets: the stand-in completing its digits while the plan learns the operator; another stand-in, a lost code and another operator's status — its own number's code the stand-in's or not — changing nothing; rows keeping the key while the plan learns the code; the own number's code moving the stand-in's key, at once or once nothing is stored; a key the own number's code made, and its plan, staying under another SIM and under its own SIM's stand-in; an own code that makes the stand-in's key; a short code; --country before the operator; no operators; no address; an international address, under another SIM and under its own; and the address as dialled making the key the address as typed made.
2026-10-18 00:26:09 +02:00
}
}
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 drafts of the typed addresses that were left follow it too.
if (s.statusKnown && sync) drafts.Status(sync->Plan(), sync->CountryCode(), [this](std::string_view key) { return store.Conversation(key).empty(); });
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
Dirty();
}
void Changed() { Reload(); }
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
// A text arrived. A sheet that asks to delete its conversation goes:
// the question was about the texts the list showed, and a yes to it
// would delete this one unread. A press on its row opens no such
// sheet either while the row it aimed at had not shown the text —
// the regions are a frame's: the press that is down now, and one
// that comes down before the next frame is drawn (Pointer), have no
// long press. A release before the long-press time is still the
// row's tap, while the row stays under the finger.
void Imported(const Message& m) {
if (sheet && sheet->kind == Sheet::Kind::DeleteConversation && sheet->key == m.conversation) {
CancelGesture();
sheet.reset();
}
textSinceFrame.insert(m.conversation);
if (gestures.Pressed() && pressedOn && pressedOn->id == Hit::rowBase && pressedOn->key == m.conversation) pressGotText = true;
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
if (m.read) MadeRead(m.id); // stored read for the open conversation (Sync): not drawn yet
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
Reload();
}
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:
void Log(std::string_view line) {
if (onLog) onLog(line);
}
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 redraw asked for: whatever changed may have changed what is
// drawn, so the atlas wait starts over (Build's own request does not
// come through here; a fling's frames, which do not either, restart
// it in Build).
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 Dirty() {
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
frameWait.Reset();
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 (frames) frames->RequestRedraw();
}
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
// Leaving a conversation keeps what its field holds, by its key
// (Edit's Drafts); Open takes it up again.
void KeepDraft() {
if (view) drafts.Keep(view->key, view->compose, view->dialled, view->dialledPlan);
}
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
// Marks the open conversation's unread texts read, and keeps which
// they were until a frame has shown them (MadeRead): the ones the
// store has unread now. The view's copies are older, and a text
// made read since still reads unread in them.
std::uint32_t MarkOpenRead() {
std::vector<std::uint64_t> unread;
for (const Message& m : store.Conversation(view->key)) {
if (!m.read) unread.push_back(m.id);
}
const std::uint32_t marked = store.MarkRead(view->key);
// Kept whatever the count says: a MarkRead whose flush the store
// refused answers 0 with the rows read in place, and GiveBack
// passes over a text that was left unread.
for (const std::uint64_t id : unread) MadeRead(id);
return marked;
}
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 Reload() {
convs = GroupConversations(store.All());
if (view) {
const std::size_t before = view->messages.size();
view->messages = store.Conversation(view->key);
if (view->messages.size() > before) view->stickToBottom = true;
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
// Texts on screen are read; a conversation kept across a hide
// or in a window that is not seen is not on screen, and its
// new texts stay unread until it is.
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
if (OnScreen() && sync && MarkOpenRead() > 0) convs = GroupConversations(store.All());
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
}
Dirty();
}
static std::int64_t NowEpoch() {
return std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}
static std::int64_t NowMs() {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
}
static std::int32_t OffsetAt(std::int64_t epoch) {
std::tm tm{};
const time_t t = static_cast<time_t>(epoch);
localtime_r(&t, &tm);
return static_cast<std::int32_t>(tm.tm_gmtoff / 60);
}
ScrollState& ActiveScroll() { return view ? view->scroll : list.scroll; }
// A screen change stops a fling: the scroll left behind keeps no
// velocity for a return to revive, and the frames stop asking.
void StopFling() {
list.scroll.velocity = 0;
if (view) view->scroll.velocity = 0;
if (frames) frames->SetAnimating(false);
}
// A screen change under a finger cancels the press: its release is no
// tap on what the new screen drew where the finger went down (a
// forwarded link's or a notification's Open by the other thumb, Back
// from a key), and its long press does not fire.
void CancelGesture() {
Gesture, Ui, project: Crafter.Graphics at 364d210, whose pointer and touch events carry their time The pinned library dropped the compositor's time of every pointer and touch event, so the app dated them by its own clock at dispatch. Events queued while the main loop was busy — a List importing a backlog, each Import an fdatasync — all carried the time the loop came back: a swipe's backlog read as a few milliseconds' travel and flung the list to its far end, and a press whose down and up both waited out a stall had them at one time, a tap where the user held — on a Failed bubble a Retry, an SMS the user did not ask for. Crafter.Graphics 364d210 keeps the time on the window (lastInputTime, set before the event fires), one commit on the master of 2026-11-02, which added the library's review configuration and no code. The gesture detector now gets each event's own time, unwrapped past the wrap at 2^32 into one running clock (an event stamped 0, which the compositor's time reads for one millisecond in 2^32, gets the host's clock), and the long-press timer's expiry is the host's elapsed since the press put on that clock, so a press and its release keep their distance however late the loop dispatches them — and a release or a move the detector sees past the long-press time with no timer fired is the long press itself, at the press, where the press can be one, since the hold is measured on the events' clock (tests/Gesture pins both). The pin moves from 3f646ec; the contracts this app relies on are unchanged by the two commits between.
2026-11-02 16:09:33 +01:00
if (gestures.Pressed()) gestures.Feed(PointerPhase::Cancel, Point{}, eventClock);
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 (longPressTimer) {
g_source_remove(longPressTimer);
longPressTimer = 0;
}
}
void Build(VkCommandBuffer) {
tzset(); // the zone may have changed since the last frame: the captions read it
Canvas& c = *canvas;
hits.clear();
const std::int64_t now = NowEpoch();
const ZoneFn zone = OffsetAt;
const auto frameTime = std::chrono::steady_clock::now();
const float dt = lastFrame.time_since_epoch().count() == 0 ? 0.0f : std::chrono::duration<float>(frameTime - lastFrame).count();
lastFrame = frameTime;
if (frames->Animating()) {
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
frameWait.Reset(); // a fling's frame changes what is drawn, as a request through Dirty does: the atlas wait starts over
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 (!ActiveScroll().Tick(std::min(dt, 0.05f))) frames->SetAnimating(false);
}
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (fresh) {
Box area = DrawHeader(c, "New message", true, hits);
area = DrawBanner(c, area, status);
fresh->Draw(c, area, hits);
} else if (view) {
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
Box area = DrawHeader(c, DisplayNumber(view->key), true, hits);
area = DrawBanner(c, area, status);
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
area = view->DrawComposeBar(c, area, CanSend(status) && !Destination().empty(), hits);
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
view->Draw(c, area, now, zone, hits);
} else {
Box area = DrawHeader(c, "Messages", false, hits);
area = DrawBanner(c, area, status);
list.Draw(c, area, convs, now, zone, hits);
}
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (sheet) DrawSheet(c, *sheet, hits);
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
UpdateTextInput();
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
// What the regions name, as drawn: a reload before the next frame
// re-sorts the vectors, so a gesture resolves against these.
hitKeys.clear();
for (const auto& conv : convs) hitKeys.push_back(conv.key);
hitMessages.clear();
if (view) for (const Message& m : view->messages) hitMessages.push_back(m.id);
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
textSinceFrame.clear(); // this frame's regions are of the texts as they are now
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 (c.Overflowed() && !overflowLogged) {
overflowLogged = true;
Log("a layer ran out of items this frame; the buffers are too small for this screen");
}
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 that found no room in the atlas drew blank and gets a
// cell when a later frame begins — from glyphs not drawn in the
// last framesInFlight + 1 frames — and only a request brings a
// frame, frames being drawn on demand: FrameWait's rule (Gesture),
// the request not through Dirty, which would start the wait over.
if (frameWait.Again(c.GlyphsWaiting())) frames->RequestRedraw();
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
}
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
ComposeState* FocusedField() {
if (fresh) return &fresh->field;
if (view && view->compose.focused) return &view->compose;
return nullptr;
}
struct TextInputState {
bool active = false;
Box caret{};
Crafter::TextInputPurpose purpose = Crafter::TextInputPurpose::Normal;
};
// The word the input method is composing goes into its field, as a
// tap elsewhere does: once the text input is off, the input method
// starts afresh and would replace or drop it.
void CommitComposition() {
if (fresh) ComposeCommitPreedit(fresh->field);
if (view) ComposeCommitPreedit(view->compose);
}
// Tells the compositor which field has the focus and where its caret
// is, after every frame, when that changed: the number field at once,
// the message field after a tap or a key; a sheet or leaving the
// screen takes it back.
void UpdateTextInput() {
TextInputState want;
if (!sheet) {
if (fresh) want = { true, fresh->fieldLayout.caret, Crafter::TextInputPurpose::Phone };
else if (view && view->compose.focused) want = { true, view->composeLayout.caret, Crafter::TextInputPurpose::Normal };
}
const bool sameCaret = want.caret.x == lastTextInput.caret.x && want.caret.y == lastTextInput.caret.y && want.caret.w == lastTextInput.caret.w && want.caret.h == lastTextInput.caret.h;
if (want.active == lastTextInput.active && want.purpose == lastTextInput.purpose && (!want.active || sameCaret)) return;
if (want.active != lastTextInput.active) Log(want.active ? (want.purpose == Crafter::TextInputPurpose::Phone ? "text input on (a number)" : "text input on") : "text input off");
// Turning the input off ends the composition on the input
// method's side; the field keeps the word it showed.
if (!want.active && lastTextInput.active) CommitComposition();
lastTextInput = want;
canvas->Window().SetTextInput(want.active, static_cast<std::int32_t>(want.caret.x), static_cast<std::int32_t>(want.caret.y), static_cast<std::int32_t>(want.caret.w), static_cast<std::int32_t>(want.caret.h), want.purpose);
}
Gesture, Ui, project: Crafter.Graphics at 364d210, whose pointer and touch events carry their time The pinned library dropped the compositor's time of every pointer and touch event, so the app dated them by its own clock at dispatch. Events queued while the main loop was busy — a List importing a backlog, each Import an fdatasync — all carried the time the loop came back: a swipe's backlog read as a few milliseconds' travel and flung the list to its far end, and a press whose down and up both waited out a stall had them at one time, a tap where the user held — on a Failed bubble a Retry, an SMS the user did not ask for. Crafter.Graphics 364d210 keeps the time on the window (lastInputTime, set before the event fires), one commit on the master of 2026-11-02, which added the library's review configuration and no code. The gesture detector now gets each event's own time, unwrapped past the wrap at 2^32 into one running clock (an event stamped 0, which the compositor's time reads for one millisecond in 2^32, gets the host's clock), and the long-press timer's expiry is the host's elapsed since the press put on that clock, so a press and its release keep their distance however late the loop dispatches them — and a release or a move the detector sees past the long-press time with no timer fired is the long press itself, at the press, where the press can be one, since the hold is measured on the events' clock (tests/Gesture pins both). The pin moves from 3f646ec; the contracts this app relies on are unchanged by the two commits between.
2026-11-02 16:09:33 +01:00
// The event's own time: the compositor's stamp of the pointer or touch
// event the listener is being invoked for (Window::lastInputTime, ms
// from an undefined base, wrapping at 2^32), unwrapped into one
// running clock. Events queued while the loop was busy keep the
// times they happened at, so a backlog is not read as a burst: a
// swipe's as a fling at many times the finger's speed, a held press
// as a tap. The host's clock where the stamp is 0: the one
// millisecond in 2^32 that the compositor's time reads 0, and before
// the first event that has a time.
std::int64_t EventTimeMs() {
const std::uint32_t raw = canvas->Window().lastInputTime;
if (raw == 0) return NowMs();
if (lastRawEventMs != 0) eventClock += static_cast<std::int32_t>(raw - lastRawEventMs);
else eventClock = raw;
lastRawEventMs = raw;
return eventClock;
}
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 Pointer(PointerPhase phase) {
const Point p{ canvas->Window().currentMousePos.x, canvas->Window().currentMousePos.y };
// Buffer pixels: the slop and the fling threshold follow the
// window's scale like every other distance, set at the point of use,
// so a fresh detector after a teardown has them too.
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
gestures.slopPx = canvas->Dp(8);
gestures.flingMinPxPerS = canvas->Dp(60);
if (phase == PointerPhase::Down) ActiveScroll().velocity = 0; // a finger down stops the fling under it
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (phase == PointerPhase::Down) {
pressedOn = Target(p);
pressGotText = pressedOn && pressedOn->id == Hit::rowBase && textSinceFrame.contains(pressedOn->key);
// Only a row and a message have a long press. A press on
// anything else — a button, a field, a sheet's row — stays
// that control's tap at its release, however long it was
// held: a slow finger presses the button all the same.
gestures.longPress = pressedOn && pressedOn->id >= Hit::rowBase;
}
Gesture, Ui, project: Crafter.Graphics at 364d210, whose pointer and touch events carry their time The pinned library dropped the compositor's time of every pointer and touch event, so the app dated them by its own clock at dispatch. Events queued while the main loop was busy — a List importing a backlog, each Import an fdatasync — all carried the time the loop came back: a swipe's backlog read as a few milliseconds' travel and flung the list to its far end, and a press whose down and up both waited out a stall had them at one time, a tap where the user held — on a Failed bubble a Retry, an SMS the user did not ask for. Crafter.Graphics 364d210 keeps the time on the window (lastInputTime, set before the event fires), one commit on the master of 2026-11-02, which added the library's review configuration and no code. The gesture detector now gets each event's own time, unwrapped past the wrap at 2^32 into one running clock (an event stamped 0, which the compositor's time reads for one millisecond in 2^32, gets the host's clock), and the long-press timer's expiry is the host's elapsed since the press put on that clock, so a press and its release keep their distance however late the loop dispatches them — and a release or a move the detector sees past the long-press time with no timer fired is the long press itself, at the press, where the press can be one, since the hold is measured on the events' clock (tests/Gesture pins both). The pin moves from 3f646ec; the contracts this app relies on are unchanged by the two commits between.
2026-11-02 16:09:33 +01:00
const std::int64_t at = EventTimeMs();
Handle(gestures.Feed(phase, p, at));
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 (phase == PointerPhase::Down) {
Gesture, Ui, project: Crafter.Graphics at 364d210, whose pointer and touch events carry their time The pinned library dropped the compositor's time of every pointer and touch event, so the app dated them by its own clock at dispatch. Events queued while the main loop was busy — a List importing a backlog, each Import an fdatasync — all carried the time the loop came back: a swipe's backlog read as a few milliseconds' travel and flung the list to its far end, and a press whose down and up both waited out a stall had them at one time, a tap where the user held — on a Failed bubble a Retry, an SMS the user did not ask for. Crafter.Graphics 364d210 keeps the time on the window (lastInputTime, set before the event fires), one commit on the master of 2026-11-02, which added the library's review configuration and no code. The gesture detector now gets each event's own time, unwrapped past the wrap at 2^32 into one running clock (an event stamped 0, which the compositor's time reads for one millisecond in 2^32, gets the host's clock), and the long-press timer's expiry is the host's elapsed since the press put on that clock, so a press and its release keep their distance however late the loop dispatches them — and a release or a move the detector sees past the long-press time with no timer fired is the long press itself, at the press, where the press can be one, since the hold is measured on the events' clock (tests/Gesture pins both). The pin moves from 3f646ec; the contracts this app relies on are unchanged by the two commits between.
2026-11-02 16:09:33 +01:00
downEventMs = at;
downHostMs = NowMs();
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 (longPressTimer) g_source_remove(longPressTimer);
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
longPressTimer = gestures.longPress ? g_timeout_add(static_cast<guint>(gestures.longPressMs), OnLongPress, this) : 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
} else if (phase != PointerPhase::Move && longPressTimer) {
g_source_remove(longPressTimer);
longPressTimer = 0;
}
}
static gboolean OnLongPress(gpointer data) {
App& self = *static_cast<App*>(data);
self.longPressTimer = 0;
Gesture, Ui, project: Crafter.Graphics at 364d210, whose pointer and touch events carry their time The pinned library dropped the compositor's time of every pointer and touch event, so the app dated them by its own clock at dispatch. Events queued while the main loop was busy — a List importing a backlog, each Import an fdatasync — all carried the time the loop came back: a swipe's backlog read as a few milliseconds' travel and flung the list to its far end, and a press whose down and up both waited out a stall had them at one time, a tap where the user held — on a Failed bubble a Retry, an SMS the user did not ask for. Crafter.Graphics 364d210 keeps the time on the window (lastInputTime, set before the event fires), one commit on the master of 2026-11-02, which added the library's review configuration and no code. The gesture detector now gets each event's own time, unwrapped past the wrap at 2^32 into one running clock (an event stamped 0, which the compositor's time reads for one millisecond in 2^32, gets the host's clock), and the long-press timer's expiry is the host's elapsed since the press put on that clock, so a press and its release keep their distance however late the loop dispatches them — and a release or a move the detector sees past the long-press time with no timer fired is the long press itself, at the press, where the press can be one, since the hold is measured on the events' clock (tests/Gesture pins both). The pin moves from 3f646ec; the contracts this app relies on are unchanged by the two commits between.
2026-11-02 16:09:33 +01:00
self.Handle(self.gestures.Timeout(self.downEventMs + (NowMs() - self.downHostMs))); // the host's elapsed since the press, on the events' clock
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 G_SOURCE_REMOVE;
}
void Handle(const GestureEvent& e) {
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (sheet && e.kind != GestureEvent::Kind::Tap) return;
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
// A tap or a long press acts on what the press went down on: a
// frame drawn meanwhile (a new text snapped the conversation, the
// list re-sorted) that moved another bubble or row under the
// finger names something else, and the release acts on nothing.
if ((e.kind == GestureEvent::Kind::Tap || e.kind == GestureEvent::Kind::LongPress) && Target(e.at) != pressedOn) return;
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (e.kind == GestureEvent::Kind::LongPress && pressGotText) return; // the pressed row had not shown a text of its conversation (Imported)
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
switch (e.kind) {
case GestureEvent::Kind::None: return;
case GestureEvent::Kind::Tap: Tap(e.at); return;
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
case GestureEvent::Kind::LongPress: LongPress(e.at); return;
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
case GestureEvent::Kind::DragStart:
case GestureEvent::Kind::Drag:
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (fresh) return; // the new-conversation screen scrolls nothing
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
frames->SetAnimating(false);
ActiveScroll().ScrollBy(-e.delta.y);
if (view) view->stickToBottom = false;
Dirty();
return;
case GestureEvent::Kind::Fling:
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (fresh) return;
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
ActiveScroll().Fling(-e.velocity.y);
frames->SetAnimating(true);
return;
case GestureEvent::Kind::Release: return;
}
}
// What a frame's regions name at a point (Gesture's TargetAt).
std::optional<HitTarget> Target(Point p) const { return TargetAt(hits, p, Hit::rowBase, hitKeys, Hit::messageBase, hitMessages); }
// The message a frame's region named, if the conversation still
// holds it.
const Message* HitMessage(std::size_t i) const {
if (!view || i >= hitMessages.size()) return nullptr;
for (const Message& m : view->messages) {
if (m.id == hitMessages[i]) return &m;
}
return nullptr;
}
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
// A key: Escape goes back; Enter on the number screen starts the
// conversation; Ctrl+Enter sends; the rest edits the field.
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
void Key(Crafter::KeyCode code) {
using Crafter::CrafterKeys;
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
// A key whose press changed the screen acts once: held, the
// library sends it again (its repeat is that key's while it
// runs), and those are the old screen's — Enter's, which
// started the conversation, would type line breaks into its
// field, and Escape's would go on back, from a sheet through
// the conversation and its draft. A new press acts again.
if (spentKey == code) {
if (Crafter::Device::keyRepeat.active && Crafter::Device::keyRepeat.key == code) return;
spentKey.reset();
}
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
if (code == Crafter::Key(CrafterKeys::Escape)) {
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
spentKey = code;
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
Back();
return;
}
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (sheet) return;
if (fresh) {
if (code == Crafter::Key(CrafterKeys::Enter) || code == Crafter::Key(CrafterKeys::keypad_enter)) {
Start();
if (!fresh) spentKey = code; // started: the conversation's screen is up
} else if (ComposeKey(fresh->field, code)) ShowCaret();
if (!repeatTimer) repeatTimer = g_timeout_add(30, OnRepeat, this);
return;
}
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
if (!view) return;
const std::unordered_set<Crafter::KeyCode>& held = canvas->Window().heldKeys;
const bool ctrl = held.contains(Crafter::Key(CrafterKeys::LeftCtrl)) || held.contains(Crafter::Key(CrafterKeys::RightCtrl));
if (ctrl && (code == Crafter::Key(CrafterKeys::Enter) || code == Crafter::Key(CrafterKeys::keypad_enter))) {
SendDraft();
return;
}
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
if (ComposeKey(view->compose, code)) {
view->compose.focused = true;
ShowCaret();
}
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 library repeats a held key only while frames run; with frames
// on demand a timer ticks the repeat instead.
if (!repeatTimer) repeatTimer = g_timeout_add(30, OnRepeat, this);
}
static gboolean OnRepeat(gpointer data) {
App& self = *static_cast<App*>(data);
if (!self.canvas || self.canvas->Window().heldKeys.empty()) {
self.repeatTimer = 0;
return G_SOURCE_REMOVE;
}
Crafter::Device::TickKeyRepeats();
return G_SOURCE_CONTINUE;
}
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
// A tap places the cursor. Inside the composing text it stays where it
// is (that span is the input method's); outside, the word is committed
// where it was typed and the input method reset, as Send does, so the
// half-typed word does not move to the tap.
void TapField(ComposeState& s, const ComposeLayout& layout, Point at) {
const std::size_t shown = ComposeHit(*canvas, s, layout, at);
if (!s.preedit.empty()) {
if (shown > s.cursor && shown < s.cursor + s.preedit.size()) return;
ComposeCommitPreedit(s);
ResetTextInput();
}
s.cursor = shown;
}
// Disables the text input now and lets the next frame enable it
// again: an enable resets the input method, the word it was composing
// included.
void ResetTextInput() {
if (!canvas || !lastTextInput.active) return;
canvas->Window().SetTextInput(false, 0, 0, 0, 0, lastTextInput.purpose);
lastTextInput = {};
}
// The caret shows at once after an edit and blinks from there while a
// field has the focus and the window is up (without one nothing
// draws it; Show starts the blink again).
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
void ShowCaret() {
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
if (blinkTimer) {
g_source_remove(blinkTimer);
blinkTimer = 0;
}
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (view) view->caretVisible = true;
if (fresh) fresh->caretVisible = true;
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
if (canvas && FocusedField()) blinkTimer = g_timeout_add(500, OnBlink, this);
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
Dirty();
}
static gboolean OnBlink(gpointer data) {
App& self = *static_cast<App*>(data);
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
if (!self.FocusedField()) {
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
self.blinkTimer = 0;
return G_SOURCE_REMOVE;
}
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (self.view) self.view->caretVisible = !self.view->caretVisible;
if (self.fresh) self.fresh->caretVisible = !self.fresh->caretVisible;
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
self.Dirty();
return G_SOURCE_CONTINUE;
}
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
void LongPress(Point at) {
const std::optional<std::uint32_t> id = HitTest(hits, at);
if (!id) return;
if (*id >= Hit::messageBase && view) {
if (const Message* m = HitMessage(*id - Hit::messageBase)) sheet = Sheet{ Sheet::Kind::MessageActions, view->key, m->id, m->text };
} else if (*id >= Hit::rowBase && !view && !fresh) {
const std::size_t i = *id - Hit::rowBase;
if (i < hitKeys.size()) sheet = Sheet{ Sheet::Kind::DeleteConversation, hitKeys[i], 0, "" };
}
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
if (sheet) EndComposition();
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
Dirty();
}
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
// Leaving a screen with its field (Open, Back, the +), or a sheet
// over the screen, ends the composition of the field that had the
// text input, now and not at the next frame's UpdateTextInput: the
// word goes into the field as shown and the input method is told.
// Left on for that frame, it would send its next commit to the
// screen that opens — into another conversation's field — or have
// it dropped on a sheet.
void EndComposition() {
if (!lastTextInput.active) return;
CommitComposition();
ResetTextInput();
}
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
// A conversation that no longer exists: its notification goes, and
// the view on it closes, its field's text kept as at any leave (a
// view closes when its last message is deleted; a conversation
// deleted whole takes its draft with it, SheetAction).
void ConversationGone(const std::string& key) {
if (onConversationDeleted) onConversationDeleted(key);
if (view && view->key == key) {
StopFling();
CancelGesture();
KeepDraft();
view.reset();
if (sync) sync->SetOpenConversation(std::nullopt);
}
}
void SheetAction(std::uint32_t id) {
if (!sheet) return;
const Sheet s = *sheet;
sheet.reset();
if (id == Hit::sheetDelete) {
if (s.kind == Sheet::Kind::DeleteConversation) {
if (sync) sync->EraseConversation(s.key);
else store.EraseConversation(s.key);
} else {
if (sync) sync->Erase(s.messageId);
else store.Erase(s.messageId);
}
// Gone once no message is left (the list groups messages) —
// not on a delete the store refused: the rows stay, their
// notification with them, and the banner says why.
if (store.Conversation(s.key).empty()) {
ConversationGone(s.key);
if (s.kind == Sheet::Kind::DeleteConversation) drafts.Drop(s.key);
}
Reload();
} else if (id == Hit::sheetCopy) {
if (!Crafter::Clipboard::SetText(s.text)) Log("the clipboard did not take the text");
}
Dirty();
}
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 Tap(Point at) {
const std::optional<std::uint32_t> id = HitTest(hits, at);
if (!id) return;
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
if (*id == Hit::sheetScrim || *id == Hit::sheetCancel || *id == Hit::sheetDelete || *id == Hit::sheetCopy) {
SheetAction(*id);
} else if (*id == Hit::back) {
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
Back();
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
} else if (*id == Hit::start) {
Start();
} else if (*id == Hit::newField) {
if (!fresh) return;
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
TapField(fresh->field, fresh->fieldLayout, at);
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
ShowCaret();
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
} else if (*id == Hit::compose) {
if (!view) return;
view->compose.focused = true;
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
TapField(view->compose, view->composeLayout, at);
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
ShowCaret();
} else if (*id == Hit::send) {
SendDraft();
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
} else if (*id == Hit::fab) {
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
NewConversation();
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
} else if (*id >= Hit::messageBase) {
if (!view || !sync) return;
const Message* m = HitMessage(*id - Hit::messageBase);
if (m && m->state == MessageState::Failed) sync->Retry(m->id);
} else if (*id >= Hit::rowBase) {
const std::size_t i = *id - Hit::rowBase;
if (i < hitKeys.size()) Open(hitKeys[i]);
}
}
MessageStore& store;
std::filesystem::path assetDir;
std::filesystem::path cacheDir;
AppStatus status;
Theme theme;
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::vector<Conversation> convs;
std::optional<Canvas> canvas;
std::vector<std::string> hitKeys; // the conversation each row region named, as drawn
std::vector<std::uint64_t> hitMessages; // the message each bubble region named, as drawn
std::optional<HitTarget> pressedOn; // what the press went down on, as drawn then
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
bool pressGotText = false; // the pressed row had not shown a text of its conversation: no long press (Imported)
std::unordered_set<std::string> textSinceFrame; // the conversations a text arrived for since the regions were recorded
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<WaylandSource> source;
std::optional<FrameDriver> frames;
std::optional<DayWatch> day; // while the window is up
ListScreen list;
std::optional<ViewScreen> view;
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
Drafts drafts; // what was typed in the conversations left and not sent
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
std::optional<NewScreen> fresh; // the new-conversation screen
std::optional<Sheet> sheet;
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
GestureDetector gestures;
std::vector<HitRegion> hits;
guint longPressTimer = 0;
Gesture, Ui, project: Crafter.Graphics at 364d210, whose pointer and touch events carry their time The pinned library dropped the compositor's time of every pointer and touch event, so the app dated them by its own clock at dispatch. Events queued while the main loop was busy — a List importing a backlog, each Import an fdatasync — all carried the time the loop came back: a swipe's backlog read as a few milliseconds' travel and flung the list to its far end, and a press whose down and up both waited out a stall had them at one time, a tap where the user held — on a Failed bubble a Retry, an SMS the user did not ask for. Crafter.Graphics 364d210 keeps the time on the window (lastInputTime, set before the event fires), one commit on the master of 2026-11-02, which added the library's review configuration and no code. The gesture detector now gets each event's own time, unwrapped past the wrap at 2^32 into one running clock (an event stamped 0, which the compositor's time reads for one millisecond in 2^32, gets the host's clock), and the long-press timer's expiry is the host's elapsed since the press put on that clock, so a press and its release keep their distance however late the loop dispatches them — and a release or a move the detector sees past the long-press time with no timer fired is the long press itself, at the press, where the press can be one, since the hold is measured on the events' clock (tests/Gesture pins both). The pin moves from 3f646ec; the contracts this app relies on are unchanged by the two commits between.
2026-11-02 16:09:33 +01:00
std::int64_t eventClock = 0; // the events' own clock (EventTimeMs), unwrapped
std::uint32_t lastRawEventMs = 0;
std::int64_t downEventMs = 0; // the press on both clocks: the long-press timer's expiry is mapped from the host's
std::int64_t downHostMs = 0;
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
guint repeatTimer = 0;
Ui, main: the new-conversation screen and the long-press sheets The + opens a screen with a number field (its placeholder "Number", a parameter of the compose field now) and Start; the number becomes a conversation key through Number's ConversationKey, as an sms: link's does (E.164 through the country code, a short code as digits), anything else is refused in place. A long press on a conversation row offers to delete the conversation, on a message to copy its text to the clipboard or delete it; only those two have one: App tells the recogniser before each press whether what it lands on has a long press (GestureDetector's longPress), and without one a press held as long — on a button, a field, a sheet's row — stays a tap at its release, so a slow finger presses the button all the same. A sheet draws on the overlay layer over a scrim and pushes its regions last, so they win the hit test, and the wheel scrolls nothing under it; Escape, the back arrow and a tap outside dismiss it. Deleting a conversation also closes its notification and drops its draft; the + keeps the draft of the conversation it leaves, as Back does, and so does a view that closes because its last message was deleted. The deletes go through Sync (Erase, EraseConversation: the commit before, which keeps a deleted text deleted). The number field's box is drawn by its screen, as the send bar's is by the bar: the shared field drawing paints no background of its own. Opening a conversation, from a notification or a link, leaves the new-conversation screen and any sheet, and the + leaves any sheet. A key whose press changed the screen acts once: held, its repeats are not the new screen's — Enter, which started the conversation, would type line breaks into its field, and Escape would go on back, from a sheet through the conversation and its draft. A sheet that asks to delete a conversation goes when a text arrives for it: a yes would delete that text unread. A press on the conversation's row opens no such sheet either while the row it aimed at had not shown the text — the regions are a frame's: the press that is down when the text arrives, and one that comes down before the next frame is drawn, have no long press; a release before the long-press time is still the row's tap, while the row stays under the finger. --new and --bench-sheet put either on screen for the bench (--bench-sheet conversation or message, each on the screen a long press opens it over: another value is refused, and one that finds nothing to press says so in the log), and are window flags as --screenshot is. Tested: the screens and the sheets by the bench (--new, --bench-sheet) and the phone step's screenshots; the deletes' logic with the commit before, in tests/Store and tests/Sync; the press without a long press in tests/Gesture (the timer gives no long press and a move within the slop nothing; the release is the tap, however late; a slide off the control is a drag); a deleted conversation's draft dropped, in tests/Edit. The press on a row a text arrived for has no bench: none holds a finger on a row.
2026-11-01 18:11:40 +01:00
std::optional<Crafter::KeyCode> spentKey; // the key whose press changed the screen (Key)
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
guint blinkTimer = 0;
guint hideIdle = 0; // a close's Hide, deferred to the loop
Ui, main: a frame that fails no longer ends the process in std::terminate The library throws at a Vulkan error, and a frame's — the device lost, its memory exhausted — came out of the frame callback with nothing under it to catch it: std::terminate. The instance was gone with its window, and every later text imsd had stored waited there, not notified, until somebody started the app again. A first frame that failed in the window an Activate had asked for threw into the Activate handler instead and left an instance with a window it never showed. The frame path catches it now. The failure is logged and nothing counts as on screen from there. From the frame callback the window closes as at the compositor's word: an instance with a session bus runs on without one, importing and notifying, and one without ends with exit 1. At Show's first frame the window is taken down at once, and a start left without a window ends with exit 1. A window asked for while a failed one waits for its Hide is made after that Hide. The screenshot's frame is a frame like the others, and a capture finds a window that failed to be no window. A failure named VK_ERROR_DEVICE_LOST — the library throws the failed call's result by its name — means the device is lost. It stays lost, and the app sets the device up once per process, so this process can make no window again: the next request for one — at once when the failure was a window's making or its first frame — ends the instance in order with exit 1, and the start after it has a new device. That covers a device lost while there was no window, where the window's making fails and the instance used to stay, failing every later request the same way. With the device not lost the next request makes a new window. The frame that fails is often the one a text asked for, and that text was stored read, its conversation counting as on screen. A text made read — by Sync at its import, by the app at Opened and Reload — is now kept until the device has answered for the frame after it: the next frame draws it, if its conversation is still the screen's, and the library's Render begins by waiting for the frame that had its slot, the frames in flight before it, so the app asks for that many more frames and lets the text go when they are drawn. A window that fails before then, or a device found lost at the next window's making, gives its texts back: unread again, and notified through main's notifier, whose bus main flushes before a start's early exit as before the loop's. Only the frame path's errors are caught. One the library meets under its own listeners — the swapchain it rebuilds at a resize — is under no catch of the app's and still ends the process. And a resident instance whose own start asks for the window (--new) and meets the lost device there says it quits and runs on until the next request: that quit comes before the main loop runs, and is lost. Tested: on KWin, with a Vulkan layer of the bench's that answers VK_ERROR_DEVICE_LOST from a chosen frame or moment on (the real device is not lost: the waits a teardown makes fail too), this build beside the one before. A conversation open and a text for it drawn, then the device lost and another text for it: before, an abort with that text stored read; now the first text stays read, the second is unread again and notified, the next text is notified, an Activate ends the instance with exit 1, and the start after it has its window. A text whose frame is handed over and the device lost from the next frame on: unread again and notified. A text drawn, its window closed before the frames that answer for it, the device lost, and an Activate: unread again and notified, exit 1. A plain start whose first frame fails, and a window without a session bus: exit 1, before an abort. A resident instance whose first frame fails at an Activate, and one whose device is lost while it has no window: the Activate ends it with exit 1 and the start after it has its window, where before the instance stayed and showed none. One frame alone answering VK_ERROR_OUT_OF_DEVICE_MEMORY: the window goes, its text is unread and notified, and the next Activate makes a new window, before an abort; an Activate sent while that frame is still failing is served after the Hide, and so is a link to another conversation. The screenshot's frame meeting the lost device: no PNG, exit 1, and a text waiting for its frames is unread again and notified, where before it stayed read; a capture that comes due while a frame fails in its submit: no window, exit 1, before an abort. A text made read as its window became the active one, the store refusing that write's flush (the bench fails its fdatasync), and the next frame on the lost device: unread again and notified; the same text drawn first, its window left and returned to, and then the loss: it stays read. And the limit: the device lost and the window resized before a frame — an abort, as before.
2026-11-17 06:26:37 +01:00
bool frameFailed = false; // the window threw in a frame (WindowFailed): nothing more is drawn on it
bool deviceLost = false; // the device said so after a failure (CheckDevice): no window is made again
bool endSaid = false; // EndOverDevice's line, once
bool showAfterHide = false; // a window was asked for while a failed one waited for its Hide (Show)
// The texts made read — the open conversation counted as on screen
// — that the device has not answered for yet. The next frame draws
// such a text, if its conversation is still the screen's, and
// the frame that takes that frame's slot again, the frames in
// flight later, waits for it before it draws (the library's
// Render): the count of frames drawn that carries the answer is
// kept with each. A window that fails before then, or a device
// found lost at the next window's making, gives them back
// (GiveBack).
struct Unshown {
std::uint64_t id;
std::uint64_t shownBy;
};
std::vector<Unshown> readUnshown;
std::uint64_t framesDrawn = 0; // the frames drawn without a throw, over every window of the process
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::chrono::steady_clock::time_point lastFrame{};
bool overflowLogged = 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
FrameWait frameWait{ .patience = Canvas::framesInFlight + 1 }; // the frames owed to the atlas while glyphs wait for a 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
std::filesystem::path screenshotPath;
std::optional<Crafter::EventListener<void>> downSub;
std::optional<Crafter::EventListener<void>> upSub;
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
std::optional<Crafter::EventListener<Crafter::TouchPoint>> touchDownSub;
std::optional<Crafter::EventListener<Crafter::TouchPoint>> touchUpSub;
std::optional<Crafter::EventListener<void>> touchCancelSub;
std::optional<std::int32_t> touch; // the finger that drives the pointer
bool touchUp = false; // its touch-up came before the release
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::EventListener<void>> moveSub;
std::optional<Crafter::EventListener<std::uint32_t>> scrollSub;
std::optional<Crafter::EventListener<Crafter::KeyCode>> keySub;
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
std::optional<Crafter::EventListener<Crafter::KeyCode>> keyUpSub;
std::optional<Crafter::EventListener<const std::string_view>> textSub;
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
std::optional<Crafter::EventListener<const std::string_view>> preeditSub;
std::optional<Crafter::EventListener<Crafter::TextDelete>> deleteSub;
TextInputState lastTextInput;
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::EventListener<void>> resizeSub;
std::optional<Crafter::EventListener<void>> closeSub;
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
std::optional<Crafter::EventListener<void>> seenSub;
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
};
}