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.
205 lines
9.2 KiB
C++
205 lines
9.2 KiB
C++
// SPDX-License-Identifier: GPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
// lint-disable-file no-char-pointer
|
|
import std;
|
|
import Crafter.Build;
|
|
#pragma crafter dependency "https://forgejo.catcrafts.net/Catcrafts/Crafter.LintRules.git" commit "e906f797da2cd0b1776dd1b420f9b04d3cd24baf"
|
|
import Crafter.LintRules;
|
|
namespace fs = std::filesystem;
|
|
using namespace Crafter;
|
|
|
|
// pkg-config wrapper (std-only: no popen in import std). Returns the flags
|
|
// split on whitespace, or empty if pkg-config is unavailable — callers
|
|
// provide a fallback for that case.
|
|
static std::vector<std::string> PkgConfig(std::string_view args) {
|
|
fs::path tmp = fs::temp_directory_path() /
|
|
std::format("imsd-messages-pkgconfig-{}.txt", std::hash<std::string_view>{}(args));
|
|
std::string cmd = std::format("pkg-config {} > {} 2>/dev/null", args, tmp.string());
|
|
std::vector<std::string> flags;
|
|
if (std::system(cmd.c_str()) == 0) {
|
|
std::ifstream f(tmp);
|
|
std::string flag;
|
|
while (f >> flag)
|
|
flags.push_back(flag);
|
|
}
|
|
std::error_code ec;
|
|
fs::remove(tmp, ec);
|
|
return flags;
|
|
}
|
|
|
|
// GDBus (gio-2.0) — bus layer for the two daemons; chosen over sd-bus because
|
|
// the platform stack (ModemManager, libqmi for the future direct-AKA port) is
|
|
// GLib, so they want a GMainLoop regardless. (imsd's reasoning; the same
|
|
// layer here.) Computed once, for each target that takes them.
|
|
struct GioFlags {
|
|
std::vector<std::string> compile;
|
|
std::vector<std::string> link;
|
|
};
|
|
|
|
static GioFlags ComputeGioFlags(const Configuration& cfg) {
|
|
GioFlags f;
|
|
if (!cfg.sysroot.empty()) {
|
|
// cross build (--target=aarch64-unknown-linux-gnu against a
|
|
// Freedesktop Sdk, or --target=aarch64-alpine-linux-musl against
|
|
// an Alpine sysroot): the host's pkg-config would answer for the
|
|
// wrong architecture. glib's headers are in
|
|
// include/glib-2.0, its glibconfig.h in lib/glib-2.0/include or, on
|
|
// a multiarch layout like the Freedesktop Sdk's, under
|
|
// lib/<arch>-linux-gnu; the `-I=` form makes clang resolve the
|
|
// paths inside the sysroot.
|
|
const std::string arch = cfg.target.substr(0, cfg.target.find('-'));
|
|
f.compile = { "-I=/usr/include/glib-2.0", "-I=/usr/lib/glib-2.0/include", std::format("-I=/usr/lib/{}-linux-gnu/glib-2.0/include", arch) };
|
|
f.link = { "-lgio-2.0", "-lgobject-2.0", "-lglib-2.0" };
|
|
return f;
|
|
}
|
|
// native build: ask pkg-config. Only -I/-D flags pass through:
|
|
// pkg-config also emits -pthread, which would config-mismatch the
|
|
// shared prebuilt std.pcm (and pthread lives in libc on every
|
|
// platform we target).
|
|
for (std::string& flag : PkgConfig("--cflags gio-2.0"))
|
|
if (flag.starts_with("-I") || flag.starts_with("-D")) f.compile.push_back(std::move(flag));
|
|
for (std::string& flag : PkgConfig("--libs gio-2.0"))
|
|
if (flag.starts_with("-l") || flag.starts_with("-L")) f.link.push_back(std::move(flag));
|
|
if (f.link.empty()) f.link = { "-lgio-2.0", "-lgobject-2.0", "-lglib-2.0" };
|
|
return f;
|
|
}
|
|
|
|
static void ApplyGioFlags(Configuration& cfg, const GioFlags& f) {
|
|
for (const std::string& flag : f.compile) cfg.compileFlags.push_back(flag);
|
|
for (const std::string& flag : f.link) cfg.linkFlags.push_back(flag);
|
|
}
|
|
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
|
// Crafter.DB and Crafter.Graphics come from the forge at the commits
|
|
// pinned below; --local builds them from the sibling checkouts in
|
|
// ../Crafter/ instead, for work on both sides at once. The flag is
|
|
// this project's: it is removed before the arguments are forwarded, so a
|
|
// dependency's project.cpp never sees it.
|
|
std::vector<std::string> depArgs(args.begin(), args.end());
|
|
const bool local = std::erase(depArgs, "--local") > 0;
|
|
|
|
Configuration* db = local
|
|
? LocalProject({ .projectFile = "../Crafter/Crafter.DB/project.cpp", .args = depArgs })
|
|
: GitProject({ .source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.DB.git", .commit = "bfd0cc261bb39dc6812bb9c0ef407c919e7cc258" }, .args = depArgs });
|
|
// The window library.
|
|
Configuration* graphics = local
|
|
? LocalProject({ .projectFile = "../Crafter/Crafter.Graphics/project.cpp", .args = depArgs })
|
|
: GitProject({ .source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Graphics.git", .commit = "3f646ec42bee39056549098b77aceed7a00a26a4" }, .args = depArgs });
|
|
|
|
// imsd-messages-core — numbers, time, the model, word wrap, gestures,
|
|
// the message field's editing, the store and the sync logic: std +
|
|
// Crafter.DB, no GLib, so every test runs with no bus, no phone and no
|
|
// GPU.
|
|
static auto Core = std::make_unique<Configuration>();
|
|
Core->path = "./";
|
|
Core->name = "imsd-messages-core";
|
|
Core->outputName = "imsd-messages-core";
|
|
ApplyStandardArgs(*Core, args);
|
|
Core->type = ConfigurationType::LibraryStatic;
|
|
Core->dependencies = { db };
|
|
{
|
|
std::array<fs::path, 9> ifaces = {
|
|
"interfaces/ImsdMessages",
|
|
"interfaces/ImsdMessages-Number",
|
|
"interfaces/ImsdMessages-Time",
|
|
"interfaces/ImsdMessages-Model",
|
|
"interfaces/ImsdMessages-Wrap",
|
|
"interfaces/ImsdMessages-Store",
|
|
"interfaces/ImsdMessages-Sync",
|
|
"interfaces/ImsdMessages-Gesture",
|
|
"interfaces/ImsdMessages-Edit",
|
|
};
|
|
std::array<fs::path, 0> impls = {};
|
|
Core->GetInterfacesAndImplementations(ifaces, impls);
|
|
}
|
|
|
|
// imsd-messages-bus — the GLib side: imsd's dictionaries, the GDBus client
|
|
// of net.catcrafts.IMS1.Messaging, the desktop notifications, the app's
|
|
// own session-bus name and the desktop portal (appearance, background). No
|
|
// window.
|
|
static auto Bus = std::make_unique<Configuration>();
|
|
Bus->path = "./";
|
|
Bus->name = "imsd-messages-bus";
|
|
Bus->outputName = "imsd-messages-bus";
|
|
ApplyStandardArgs(*Bus, args);
|
|
Bus->type = ConfigurationType::LibraryStatic;
|
|
Bus->dependencies = { Core.get() };
|
|
{
|
|
std::array<fs::path, 7> ifaces = {
|
|
"interfaces/ImsdMessages.Bus",
|
|
"interfaces/ImsdMessages.Bus-Variant",
|
|
"interfaces/ImsdMessages.Bus-Client",
|
|
"interfaces/ImsdMessages.Bus-Notifier",
|
|
"interfaces/ImsdMessages.Bus-Appearance",
|
|
"interfaces/ImsdMessages.Bus-Background",
|
|
"interfaces/ImsdMessages.Bus-Instance",
|
|
};
|
|
std::array<fs::path, 0> impls = {};
|
|
Bus->GetInterfacesAndImplementations(ifaces, impls);
|
|
}
|
|
const GioFlags gio = ComputeGioFlags(*Bus);
|
|
ApplyGioFlags(*Bus, gio);
|
|
|
|
// imsd-messages-ui — the window: Crafter.Graphics driven from the GLib
|
|
// main loop.
|
|
static auto Ui = std::make_unique<Configuration>();
|
|
Ui->path = "./";
|
|
Ui->name = "imsd-messages-ui";
|
|
Ui->outputName = "imsd-messages-ui";
|
|
ApplyStandardArgs(*Ui, args);
|
|
Ui->type = ConfigurationType::LibraryStatic;
|
|
Ui->dependencies = { Core.get(), graphics };
|
|
{
|
|
std::array<fs::path, 6> ifaces = {
|
|
"interfaces/ImsdMessages.Ui",
|
|
"interfaces/ImsdMessages.Ui-Loop",
|
|
"interfaces/ImsdMessages.Ui-Canvas",
|
|
"interfaces/ImsdMessages.Ui-Compose",
|
|
"interfaces/ImsdMessages.Ui-Screens",
|
|
"interfaces/ImsdMessages.Ui-App",
|
|
};
|
|
std::array<fs::path, 0> impls = {};
|
|
Ui->GetInterfacesAndImplementations(ifaces, impls);
|
|
}
|
|
ApplyGioFlags(*Ui, gio);
|
|
|
|
// imsd-messages — the executable: the command line, the window and the
|
|
// wiring between the bus layer and the UI.
|
|
Configuration cfg;
|
|
cfg.path = "./";
|
|
cfg.name = "imsd-messages";
|
|
cfg.outputName = "imsd-messages";
|
|
ApplyStandardArgs(cfg, args);
|
|
cfg.type = ConfigurationType::Executable;
|
|
cfg.dependencies = { Core.get(), Bus.get(), Ui.get(), db };
|
|
{
|
|
std::array<fs::path, 0> ifaces = {};
|
|
std::array<fs::path, 1> impls = { "implementations/main" };
|
|
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
|
}
|
|
ApplyGioFlags(cfg, gio);
|
|
cfg.files.push_back("assets/NotoSans-Regular.ttf");
|
|
|
|
cfg.AddTest("Number").Dependencies({ Core.get() });
|
|
cfg.AddTest("Time").Dependencies({ Core.get() });
|
|
cfg.AddTest("Wrap").Dependencies({ Core.get() });
|
|
cfg.AddTest("Model").Dependencies({ Core.get() });
|
|
cfg.AddTest("Store").Dependencies({ Core.get(), db });
|
|
cfg.AddTest("Sync").Dependencies({ Core.get() });
|
|
cfg.AddTest("Gesture").Dependencies({ Core.get() });
|
|
cfg.AddTest("Edit").Dependencies({ Core.get() });
|
|
// The bus library's tests include GLib's headers: the library's compile
|
|
// flags (its link flags come with the library). Decode names the core's
|
|
// types too; Portal imports the bus library alone.
|
|
const auto busTest = [&](std::string_view name, std::vector<Configuration*> deps) {
|
|
TestBuilder test = cfg.AddTest(std::string(name));
|
|
test.Dependencies(std::move(deps));
|
|
for (const std::string& flag : gio.compile) test.CompileFlag(flag);
|
|
};
|
|
busTest("Decode", { Core.get(), Bus.get() });
|
|
busTest("Portal", { Bus.get() });
|
|
|
|
LintRules::AddRules(cfg);
|
|
return cfg;
|
|
}
|