build(shell): name Crafter.Graphics at a commit of its master, and answer a compositor's resize with a frame
The app was built against a checkout of Crafter.Graphics given with --graphics=, because the text-input purposes it asks the input method for were uncommitted work in one checkout. They are on Crafter.Graphics' master since a9ce1a0, so project.cpp names the library as a GitProject at that commit, as it names Crafter.Network and Crafter.DB. --graphics= is gone, and with it $NOSTRO_GRAPHICS in build-aarch64.sh and the workflow's step that cloned the branch claude/nostro-app, which the forge never had: neither job of the workflow could have built the app. That master also has 89111e0, which the window was not written against. A size the compositor configures is no longer taken in the configure's listener. The listener keeps it and fires onFrameOwed, and the next Render() makes the swapchain again, fires onResize from inside itself, and answers the configure with that frame's buffer. The window draws on demand, so: - Shell::Window asks for a frame from onFrameOwed. Without it nothing draws the frame that answers the configure, and the window keeps its old size until something else changes on it. - Canvas::Reconcile no longer turns the compositor's sizes into Resize(pixels). The library takes the size asked for last, whoever asked, so that call took the configured size's place, and with it came back the surface a dp larger than configured that 89111e0 had ended (Crafter.Graphics #201). It now sizes the window only where the library does not: the app's own size (--size, SetSize, --scale); the size that comes with a new window (#166), handed over in deferredLogicalWidth, where the library's listener keeps every later one; and a scale the display changes to by itself (#165), through RebuildSwapchain. The last two reach into the library's own state, and go once the library does them. The text-input API on master is the one the app was written against: nothing changed there. Looked at on 2026-11-20 on the made-up system, on a desktop (KWin at a scale of 1.85), with WAYLAND_DEBUG=1 on the app: - The accounts at 420x760: the start, and resize:600,800 from --poke, the app's own size. Each size reaches the surface once, with the first buffer drawn for it. - The same window given 760x532 by the compositor (a KWin script that sets its frameGeometry): the configure is kept, a frame is asked for, and set_destination(760, 532), the acknowledgement and the first buffer of 1406x985 go out together. A temporary probe had that frame's draw list reach 1406x985: it is laid out for the new size. - 421x761, whose pixels at 1.85 are no whole number: it opens as 422x762, since the app's own size goes through Resize in pixels. The notes say so. - --scale 2 --size 360x760, the cards and the pay form filled in from --poke, with resize:400,700: the compositor's sizes are passed over. - The --debug-api build driven with crafter-debug: Window_Resize, Ui_Tap, ui.texts and a screenshot. The two paths that are a phone's, a size in the first configure and a scale named after the first frames, were tried only with the values put in by hand in a temporary probe. Nothing was looked at on a phone, and what the input method is told was not read off the wire: the test window never had the keyboard. 17 tests pass and the four lint passes report nothing. The app, its --debug-api build, the fake system, the x86_64 Flatpak bundle and both aarch64 Flatpaks (build-aarch64.sh) build. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
490ea995e4
commit
3cf9e091a9
8 changed files with 94 additions and 89 deletions
|
|
@ -70,7 +70,17 @@ Canvas::Canvas(Fonts& fonts, const CanvasOptions& options) : fonts(fonts), logic
|
|||
try {
|
||||
Crafter::Window& window = parts->window;
|
||||
window.SetAppId(options.appId);
|
||||
// Before anything is made for the window's size.
|
||||
// The size the compositor gave with the new window, the whole screen on a phone, which the library passes over
|
||||
// (Crafter.Graphics #166). It is handed to the library as its own listener keeps every later one, and taken
|
||||
// at once: as the surface's size, unchanged, with the pixels that come to at the display's scale. Sized in
|
||||
// pixels instead, the surface would be what those come back to, a dp more than the screen at a scale such as
|
||||
// 2.85. Nothing is listening yet, and nothing has been made for the window's size.
|
||||
if(!pretend && window.pendingLogicalWidth > 0 && window.pendingLogicalHeight > 0) {
|
||||
window.deferredLogicalWidth = window.pendingLogicalWidth;
|
||||
window.deferredLogicalHeight = window.pendingLogicalHeight;
|
||||
window.RebuildIfDeferred();
|
||||
wanted = false;
|
||||
}
|
||||
Reconcile();
|
||||
const VkCommandBuffer init = window.StartInit();
|
||||
// A slot for every buffer of the pool, and a few to spare; the renderer's own images and its sampler.
|
||||
|
|
@ -144,37 +154,46 @@ Box Canvas::Bounds() const noexcept {
|
|||
|
||||
bool Canvas::Reconcile() {
|
||||
Crafter::Window& window = parts->window;
|
||||
// A frame being recorded draws at the size it began with, and the library sizes the window after it by itself.
|
||||
// A frame being recorded draws at the size it began with. What the app asked for waits for the next look.
|
||||
if(window.recording) {
|
||||
return false;
|
||||
}
|
||||
// What the compositor said since the last look: a size it asks for is the window's from here, and (0, 0), which
|
||||
// leaves the choice to the app, changes nothing. Only its newest word counts, so a size the app asked for after
|
||||
// it stands. At a scale that is not the display's the compositor's sizes mean something else, and are passed over.
|
||||
if(!pretend && (window.pendingLogicalWidth != askedWidth || window.pendingLogicalHeight != askedHeight)) {
|
||||
askedWidth = window.pendingLogicalWidth;
|
||||
askedHeight = window.pendingLogicalHeight;
|
||||
if(askedWidth > 0) {
|
||||
logicalWidth = askedWidth;
|
||||
}
|
||||
if(askedHeight > 0) {
|
||||
logicalHeight = askedHeight;
|
||||
}
|
||||
}
|
||||
// In pixels by the library's own sum, so that a size the library did apply is found applied.
|
||||
const float scale = Scale();
|
||||
const std::uint32_t width = static_cast<std::uint32_t>(std::ceil(static_cast<float>(logicalWidth) * scale));
|
||||
const std::uint32_t height = static_cast<std::uint32_t>(std::ceil(static_cast<float>(logicalHeight) * scale));
|
||||
if(width == 0 || height == 0 || (width == window.width && height == window.height)) {
|
||||
return false;
|
||||
const auto pixels = [scale](std::int32_t length) { return static_cast<std::uint32_t>(std::ceil(static_cast<float>(length) * scale)); };
|
||||
const std::uint32_t ownWidth = pixels(logicalWidth);
|
||||
const std::uint32_t ownHeight = pixels(logicalHeight);
|
||||
const std::uint32_t widthBefore = window.width;
|
||||
const std::uint32_t heightBefore = window.height;
|
||||
if(pretend || wanted) {
|
||||
// The app's own size. The library takes the size asked for last, whoever asked, so this also takes the place
|
||||
// of one the compositor asked for that still waits for its frame: at a scale that is not the display's the
|
||||
// compositor's sizes mean something else, and every one of them is passed over this way.
|
||||
wanted = false;
|
||||
window.Resize(ownWidth, ownHeight);
|
||||
} else if(window.deferredLogicalWidth == 0) {
|
||||
// Nothing asked for is waiting, so the window has its size, and what can be off is its pixels: the display's
|
||||
// scale changed since they were worked out, which the library leaves until it next makes the window's images
|
||||
// (Crafter.Graphics #165). (While a size the compositor asked for waits for the frame that answers it, the
|
||||
// library takes it there with the scale of that moment, and a size asked for here would take its place.)
|
||||
if(window.logicalConfigured) {
|
||||
// The compositor's size, which the surface keeps: the images are made again, and the library works the
|
||||
// pixels out for them.
|
||||
if(pixels(window.logicalWidth) != window.width || pixels(window.logicalHeight) != window.height) {
|
||||
window.RebuildSwapchain();
|
||||
}
|
||||
} else if(ownWidth != 0 && ownHeight != 0 && (ownWidth != window.width || ownHeight != window.height)) {
|
||||
// The app's size, which is these pixels.
|
||||
window.Resize(ownWidth, ownHeight);
|
||||
}
|
||||
}
|
||||
window.Resize(width, height);
|
||||
return true;
|
||||
return window.width != widthBefore || window.height != heightBefore;
|
||||
}
|
||||
|
||||
void Canvas::SetSize(std::uint32_t widthDp, std::uint32_t heightDp) noexcept {
|
||||
logicalWidth = static_cast<std::int32_t>(widthDp);
|
||||
logicalHeight = static_cast<std::int32_t>(heightDp);
|
||||
wanted = true;
|
||||
}
|
||||
|
||||
void Canvas::Render(const DrawList& list, Color ground) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue