On this page

Live resize

While the user drags a window edge or moves the window, the system runs its own loop and the app's loop stops. The engine keeps frames coming from inside that loop, so the content follows the edge instead of freezing or stretching.

What holds the loop

PlatformWhenHow frames keep coming
WindowsThe size and move loop, from WM_ENTERSIZEMOVE to WM_EXITSIZEMOVE. It covers both dragging an edge and moving the window.Each drawn frame asks for the next paint, which the loop hands out as soon as input is drained, so frames keep the display rate. An 8 ms timer covers a pointer resting on an edge.
macOSA live resize, from viewWillStartLiveResize to viewDidEndLiveResize, and a window drag, from windowWillMove until the mouse button is up.Every size step paints a frame, and a display link ticks while the pointer rests on an edge or drags the window. A tick right after a size paint is skipped, so one vsync never carries two frames.

These frames go through the same gate as the normal loop: an idle app still draws nothing, a minimised window is skipped and the frame rate cap holds. A pending backend switch waits until the loop is back.

Level zero and level one

At level zero this needs nothing: the view is already the frame. At level one your loop is the one that stops, so the engine calls isolen_app_desc::view for the frames it runs meanwhile. Put the drawing in one function, call it from your loop and set it as view. With no view set, a level one app draws nothing during a live resize and says so in the log.

main.cpp
#include "isolenui/app/app.h"

struct model {
    uint32_t ticks;
};

// one function draws the frame, the loop calls it and so does the engine
// while the os holds the loop for a live resize or a move
static void draw(isolen_frame* f, void* user)
{
    model* m = static_cast<model*>(user);
    ui_box(f->ui, ui::col().pad(24.0f).gap(8.0f))
    {
        ui::textf(f->ui, ui::body(f->ui), "%.0f by %.0f", f->width, f->height);
        ui::textf(f->ui, ui::caption(f->ui), "%u ticks", m->ticks);
    }
}

int main(int argc, char** argv)
{
    static model m = {};
    isolen_app_desc d = isolen_app_defaults();
    d.title = "level one that keeps drawing while sized";
    d.view = draw;
    d.user = &m;
    isolen_app* app = isolen_open(&d, argc, argv);
    if (!app) {
        return 1;
    }
    isolen_frame f = {};
    while (isolen_next_frame(app, &f)) {
        ++m.ticks;
        draw(&f, &m);
    }
    isolen_close(app);
    return 0;
}

macOS presents in step

During a live resize the Metal drawable is presented inside the Core Animation transaction, so the new content and the new window edge land on the same frame. Outside a resize it presents as usual. The layer is pinned to the top left, so a drawable that misses a size step stays put instead of being stretched over the new bounds.

The window's own background follows the theme's bg, so a gap the drawable has not reached yet shows the theme colour rather than the system grey. See window chrome.

Each size step rebuilds the swapchain. During a live resize a chain with no scene targets skips the wait for the GPU to drain, since in flight drawables keep their own textures. Any other rebuild still waits.

The window side

For code that works with the platform window directly:

  • window::sizing is true while the system holds the loop. Only the paint hook runs frames then.
  • window::on_paint is a window_paint_fn, bool (*)(void* user), called with on_paint_user. It returns true when it drew a frame and wants the next paint, and false when it drew nothing, so the window waits for the next size step or timer tick.

In the log

LineWhen
window size move loop entered at WxH, window size move loop left at WxHWindows, on entering and leaving the loop.
window live resize started at WxH, display link on, window live resize ended at WxHmacOS, around a live resize. The link says off when the system offers none. A window drag logs the same lines with move in place of resize.
app live size loop at WxH, frames come from the paint hookThe first frame request inside the loop. It adds no view is set so none are drawn when there is no view.
app live size loop done at WxH, N frames in T ms, mean M ms max X msOnce the loop is back: how many frames ran and the mean and longest gap between them.
The last line is the quickest check that a resize stays smooth: on a 120 Hz display the mean sits near 8 ms, and a large max points at a slow frame.

Last updated 6 October 2026