// F02 — resize correctness, X11 edition (../../../features/f02-resize.md).
// Derived from the X11 scaffold (../scaffold/app.d). A continuously refreshed
// corner-anchored gradient survives an aggressive programmatic resize storm
// driven over BOTH paths a real X11 window experiences:
//
// 1. self-resize — XResizeWindow on the demo's own connection (an app
// resizing itself), including one burst of three back-to-back requests;
// 2. external resize — a SECOND Display* connection (opened mid-run, same
// process) resizes the window by XID, exactly what a window manager or
// `xdotool` does. The window is a server-side resource: any
// authenticated client may configure it.
//
// Logged per the F02 spec, with everything needed to compare the two paths:
// * every ConfigureNotify: configure_notify size=WxH pos=X+Y serial=N
// send_event=0|1 override=0|1 (send_event=1 marks an ICCCM *synthetic*
// ConfigureNotify, the kind WMs send on move; serial ties the event to
// the last request the server processed *on this connection* — external
// resizes arrive under a stale serial)
// * every Expose (`expose count=… area=…`), every buffer (re)allocation
// (`buffer_realloc`), every resize request (`step name=XResizeWindow…`)
// * `stale_frame` — a frame presented at the old size between a resize
// request and its ConfigureNotify; XResizeWindow is asynchronous, so one
// such frame per resize is structural on X11 (the artifact window that
// Wayland's configure/ack protocol closes)
// * `quirk name=beyond_screen` — ConfigureNotify reporting a size larger
// than the screen (the storm includes 900x560 on Xvfb's 640x480) while
// the matching Expose stays clipped to the visible region
// * `x_error` — every protocol error, via XSetErrorHandler; the run must
// end `errors=0`
//
// WSI_AUTO_EXIT=1 bounds the run (storm + drain, then exit 0); otherwise it
// runs until WM_DELETE_WINDOW. Headless-safe: no display prints `SKIP:` and
// exits 0. Findings: ../../f02-resize.md.
module (module) appapp;
import (module) cc; // ImportC: Xlib + Xutil + Xatom + XShm + sys/ipc + sys/shm + poll
import (module) instrumentinstrument;
import (package) corecore.(package) core.stdcstdc.(module) core.stdc.configD compatible types that correspond to various basic types in associated
C and C++ compilers.
Source
core/stdc/config.d
config : c_long, c_ulong;
import (package) corecore.(package) core.stdcstdc.(module) core.stdc.stdioD header file for C99 <stdio.h>
pubs.opengroup.org/onlinepubs/009695399/basedefs/stdio.h.html, stdio.h
Source
core/stdc/stdio.d
stdio : (alias) app.printf = int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogcprintf;
import (package) corecore.(package) core.stdcstdc.(module) core.stdc.stdlibD header file for C99.
pubs.opengroup.org/onlinepubs/009695399/basedefs/stdlib.h.html, stdlib.h
Source
core/stdc/stdlib.d
stdlib : (alias) app.getenv = char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogcgetenv;
// Constants Xlib/glibc expose only as macros (not ImportC-able); re-declared
// per the ImportC guide, same as the scaffold.
enum : c_long
{
(enum value) app.KeyPressMask = 1LKeyPressMask = 1L << 0,
(enum value) app.ExposureMask = 32768LExposureMask = 1L << 15,
(enum value) app.StructureNotifyMask = 131072LStructureNotifyMask = 1L << 17,
}
enum // XEvent.type discriminators
{
(enum value) app.KeyPress = 2KeyPress = 2,
(enum value) app.Expose = 12Expose = 12,
(enum value) app.UnmapNotify = 18UnmapNotify = 18,
(enum value) app.MapNotify = 19MapNotify = 19,
(enum value) app.ReparentNotify = 21ReparentNotify = 21,
(enum value) app.ConfigureNotify = 22ConfigureNotify = 22,
(enum value) app.GravityNotify = 24GravityNotify = 24,
(enum value) app.ClientMessage = 33ClientMessage = 33,
}
enum (constant) int app.ZPixmap = 2ZPixmap = 2;
enum (constant) int app.ShmCompletion = 0ShmCompletion = 0; // offset inside MIT-SHM's allocated event range
enum (constant) int app.False = 0False = 0;
enum (constant) int app.True = 1True = 1;
enum (constant) int app.POLLIN = 1POLLIN = 0x001;
enum (constant) int app.IPC_PRIVATE = 0IPC_PRIVATE = 0;
enum (constant) int app.IPC_CREAT = 512IPC_CREAT = 0x200; // 01000 octal
enum (constant) int app.IPC_RMID = 0IPC_RMID = 0;
// ---------------------------------------------------------------------------
// Protocol-error accounting (F02: "no protocol errors"). Xlib reports errors
// asynchronously through this handler; the demo logs each and tallies them.
__gshared int (__gshared global) int app.g_xErrorsg_xErrors = 0;
extern (C) int app.onXErroronXError(Display* (parameter) Display* dpydpy, XErrorEvent* e) @nogc nothrow
{
char[128] _error_ texttext = 0;
XGetErrorText(dpy, e.error_code, text.ptr, text.text.lengthlength);
emitf("x_error", "code=%d request=%d.%d resource=0x%lx text=%s",
e.error_code, e.request_code, e.minor_code, e.resourceid, text.ptr);
++g_xErrors;
return 0;
}
// ---------------------------------------------------------------------------
// Backbuffer: MIT-SHM XImage with plain-XPutImage fallback (as the scaffold).
struct (struct) app.BackbufferBackbuffer
{
XImage* (field) _error_ app.Backbuffer.ximgximg;
XShmSegmentInfo (field) _error_ app.Backbuffer.shminfoshminfo;
bool (field) bool app.Backbuffer.usingShmusingShm;
int (field) int app.Backbuffer.widthwidth, (field) int app.Backbuffer.heightheight;
}
(struct) app.BackbufferBackbuffer app.createBackbuffercreateBackbuffer(Display* (parameter) Display* dpydpy, Visual* (parameter) Visual* visualvisual, int (parameter) int depthdepth,
int (parameter) int ww, int (parameter) int hh, bool wantShm) @nogc nothrow
{
(unresolved type) BackbufferBackbuffer _error_ bb;
b.b.widthwidth = w;
b.b.heightheight = h;
if (wantShm)
{
b.b.ximgximg = XShmCreateImage(dpy, visual, cast(uint) depth, ZPixmap,
null, &b.b.shminfoshminfo, cast(uint) w, cast(uint) h);
if (b.b.ximgximg !is null)
{
const _error_ nbytesnbytes = cast(size_t)(b.b.ximgximg.bytes_per_line * b.b.ximgximg.b.ximg.heightheight);
b.b.shminfoshminfo.shmid = shmget(IPC_PRIVATE, nbytes, IPC_CREAT | 0x180 /* 0600 */ );
if (b.b.shminfoshminfo.shmid >= 0)
{
b.b.shminfoshminfo.shmaddr = cast(char*) shmat(b.b.shminfoshminfo.shmid, null, 0);
if (b.b.shminfoshminfo.shmaddr !is cast(char*)-1)
{
b.b.ximgximg.b.ximg.datadata = b.b.shminfoshminfo.shmaddr;
b.b.shminfoshminfo.readOnly = False;
XShmAttach(dpy, &b.b.shminfoshminfo);
XSync(dpy, False); // server attached before ...
shmctl(b.b.shminfoshminfo.shmid, IPC_RMID, null); // ... mark-for-delete
b.b.usingShmusingShm = true;
return b;
}
shmctl(b.b.shminfoshminfo.shmid, IPC_RMID, null);
}
b.b.ximgximg.f.destroy_image(b.b.ximgximg); // XDestroyImage is a macro
b.b.ximgximg = null;
}
emit("step name=shm_fallback reason=alloc_or_attach_failed");
}
import core.stdc.stdlib : malloc;
auto _error_ datadata = cast(char*) malloc(cast(size_t) w * h * 4);
b.b.ximgximg = XCreateImage(dpy, visual, cast(uint) depth, ZPixmap, 0, data,
cast(uint) w, cast(uint) h, 32, 0);
b.b.usingShmusingShm = false;
return b;
}
void app.destroyBackbufferdestroyBackbuffer(Display* (parameter) Display* dpydpy, ref (struct) app.BackbufferBackbuffer (parameter) Backbuffer bb) @nogc nothrow
{
if (b.b.ximgximg is null)
return;
if (b.b.usingShmusingShm)
{
XSync(dpy, False); // let any in-flight XShmPutImage finish reading
XShmDetach(dpy, &b.b.shminfoshminfo);
}
b.b.ximgximg.f.destroy_image(b.b.ximgximg);
if (b.b.usingShmusingShm)
shmdt(b.b.shminfoshminfo.shmaddr);
b.b.ximgximg = null;
}
/// Corner-anchored diagonal gradient: red tracks x/width, green tracks
/// y/height, so the geometry visibly re-anchors at every size (F02 req. 1);
/// `phase` animates the blue channel so successive frames are distinguishable.
void app.drawGradientCorner-anchored diagonal gradient: red tracks x/width, green tracks
y/height, so the geometry visibly re-anchors at every size (F02 req. 1);
phase animates the blue channel so successive frames are distinguishable.
drawGradient(XImage* (parameter) XImage* ximgximg, int (parameter) int phasephase) @nogc nothrow
{
const _error_ ww = ximg.ximg.widthwidth, _error_ hh = ximg.ximg.heightheight;
if (ximg.bits_per_pixel != 32)
return;
foreach ((parameter) yy; 0 .. h)
{
auto _error_ rowrow = cast(uint*)(ximg.ximg.datadata + y * ximg.bytes_per_line);
const _error_ gg = cast(uint)(h > 1 ? (y * 255) / (h - 1) : 0);
foreach ((parameter) xx; 0 .. w)
{
const _error_ rr = cast(uint)(w > 1 ? (x * 255) / (w - 1) : 0);
const _error_ blbl = cast(uint)((x + y + phase) & 0xff);
row[x] = (r << 16) | (g << 8) | bl;
}
}
}
int int D main()main()
{
void instrument.initInstrument(const(char)* demoName) nothrow @nogcNames the demo, starts the monotonic clock, and emits init_start.
Call this first, before any platform API call.
initInstrument("f02_x11");
const (local variable) const(char*) envAutoenvAuto = char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogcgetenv("WSI_AUTO_EXIT");
const (local variable) const(bool) autoExitautoExit = (local variable) const(char*) envAutoenvAuto !is null && (local variable) const(char*) envAutoenvAuto[0] == '1';
XSetErrorHandler(&onXError);
// -- Connection #1: the app's own ----------------------------------------
Display* (local variable) _error_ dpydpy = XOpenDisplay(null);
if (dpy is null)
{
int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogcprintf("SKIP: no X11 display (XOpenDisplay returned null)\n");
return 0;
}
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("step", "name=XOpenDisplay fd=%d", XConnectionNumber(dpy));
const (local variable) const(_error_) screenscreen = XDefaultScreen(dpy);
const (local variable) const(_error_) rootroot = XRootWindow(dpy, screen);
Visual* (local variable) _error_ visualvisual = XDefaultVisual(dpy, screen);
const (local variable) const(_error_) depthdepth = XDefaultDepth(dpy, screen);
const (local variable) const(_error_) screenWscreenW = XDisplayWidth(dpy, screen), (local variable) const(_error_) screenHscreenH = XDisplayHeight(dpy, screen);
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("step", "name=XDisplayWidth/Height screen=%dx%d", screenW, screenH);
bool (local variable) bool haveShmhaveShm = XShmQueryExtension(dpy) != 0 && char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogcgetenv("WSI_NO_SHM") is null;
int (local variable) int shmCompletionTypeshmCompletionType = (local variable) bool haveShmhaveShm ? XShmGetEventBase(dpy) + ShmCompletion : -1;
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("step", "name=XShmQueryExtension using_shm=%d", cast(int) (local variable) bool haveShmhaveShm);
int (local variable) int widthwidth = 480, (local variable) int heightheight = 320;
Window (local variable) _error_ winwin = XCreateSimpleWindow(dpy, root, 0, 0, width, height, 1,
XBlackPixel(dpy, screen), XWhitePixel(dpy, screen));
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("step", "name=XCreateSimpleWindow xid=0x%lx", win);
XStoreName(dpy, win, "Sparkles · X11 F02");
Atom (local variable) _error_ wmDeletewmDelete = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
XSetWMProtocols(dpy, win, &wmDelete, 1);
XSelectInput(dpy, win, ExposureMask | KeyPressMask | StructureNotifyMask);
XMapWindow(dpy, win);
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("window_created", "xid=0x%lx size=%dx%d", win, (local variable) int widthwidth, (local variable) int heightheight);
GC (local variable) _error_ gcgc = XDefaultGC(dpy, screen);
auto (local variable) _error_ bufbuf = createBackbuffer(dpy, visual, depth, width, height, haveShm);
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("buffer_realloc", "size=%dx%d shm=%d bytes=%d", (local variable) int widthwidth, (local variable) int heightheight,
cast(int) buf.(field) _error_ buf.usingShmusingShm, buf.(field) _error_ buf.ximgximg.bytes_per_line * buf.(field) _error_ buf.ximgximg.(field) _error_ buf.ximg.heightheight);
// -- Connection #2: the "outside world" (WM / xdotool stand-in) ----------
// Opened lazily when the external phase starts, closed when it ends.
Display* (local variable) _error_ dpy2dpy2 = null;
scope (exit)
{
if (dpy2 !is null)
XCloseDisplay(dpy2);
destroyBackbuffer(dpy, buf);
XDestroyWindow(dpy, win);
XCloseDisplay(dpy);
}
// -- The storm ------------------------------------------------------------
// Phase "self": 6 spaced XResizeWindow calls on dpy, then one burst of 3
// back-to-back requests (aggressive: queued faster than frames present).
// Phase "ext": 4 XResizeWindow calls on dpy2 — including 900x560, larger
// than Xvfb's default 640x480 screen (the beyond-screen quirk).
static immutable int[2][6] (immutable global) immutable(int[2][6]) app.main.selfStormselfStorm = [
[640, 400], [320, 240], [800, 520], [400, 300], [720, 480], [360, 260],
];
static immutable int[2][3] (immutable global) immutable(int[2][3]) app.main.burstburst = [[600, 380], [440, 300], [560, 360]];
static immutable int[2][4] (immutable global) immutable(int[2][4]) app.main.extStormextStorm = [
[500, 340], [900, 560], [300, 200], [480, 320],
];
const (local variable) const(_error_) fdfd = XConnectionNumber(dpy);
bool (local variable) bool runningrunning = true, (local variable) bool needsRedrawneedsRedraw = false, (local variable) bool awaitingCompletionawaitingCompletion = false;
bool (local variable) bool sawFirstPixelsawFirstPixel = false, (local variable) bool burstIssuedburstIssued = false;
int (local variable) int framesframes = 0, (local variable) int phasephase = 0, (local variable) int selfIssuedselfIssued = 0, (local variable) int extIssuedextIssued = 0;
int (local variable) int pendingWpendingW = 0, (local variable) int pendingHpendingH = 0; // last size we *requested*, any connection
int (local variable) int staleFramesstaleFrames = 0, (local variable) int reallocsreallocs = 1, (local variable) int configuresconfigures = 0;
while ((local variable) bool runningrunning)
{
while (XPending(dpy) > 0) // XPending also flushes the output buffer
{
XEvent (local variable) _error_ evev;
XNextEvent(dpy, &ev);
switch (ev.type)
{
case MapNotify:
emitf("map_notify", "serial=%lu send_event=%d",
ev.xany.serial, cast(int) ev.xany.send_event);
break;
case ReparentNotify: // a WM adopted us (never seen on bare Xvfb)
emitf("reparent_notify", "parent=0x%lx serial=%lu",
ev.xreparent.parent, ev.xany.serial);
break;
case UnmapNotify:
emitf("unmap_notify", "serial=%lu", ev.xany.serial);
break;
case GravityNotify:
emitf("gravity_notify", "pos=%d+%d", ev.xgravity.ev.xgravity.xx, ev.xgravity.ev.xgravity.yy);
break;
case ConfigureNotify:
const _error_ cwcw = ev.xconfigure.ev.xconfigure.widthwidth, _error_ chch = ev.xconfigure.ev.xconfigure.heightheight;
++configures;
emitf("configure_notify",
"size=%dx%d pos=%d+%d serial=%lu send_event=%d override=%d",
cw, ch, ev.xconfigure.ev.xconfigure.xx, ev.xconfigure.ev.xconfigure.yy,
ev.xany.serial, cast(int) ev.xany.send_event,
cast(int) ev.xconfigure.override_redirect);
if (cw > screenW || ch > screenH)
emitf("quirk", "name=beyond_screen configure=%dx%d screen=%dx%d",
cw, ch, screenW, screenH);
if (cw == pendingW && ch == pendingH)
pendingW = pendingH = 0; // our request landed
if (cw != width || ch != height)
{
width = cw;
height = ch;
emitf("resize", "size=%dx%d scale=1", width, height);
destroyBackbuffer(dpy, buf);
buf = createBackbuffer(dpy, visual, depth, width, height, haveShm);
++reallocs;
emitf("buffer_realloc", "size=%dx%d shm=%d bytes=%d", width, height,
cast(int) buf.buf.usingShmusingShm, buf.buf.ximgximg.bytes_per_line * buf.buf.ximgximg.buf.ximg.heightheight);
needsRedraw = true;
}
break;
case Expose:
emitf("expose", "count=%d area=%dx%d+%d+%d serial=%lu", ev.xexpose.count,
ev.xexpose.ev.xexpose.widthwidth, ev.xexpose.ev.xexpose.heightheight, ev.xexpose.ev.xexpose.xx, ev.xexpose.ev.xexpose.yy,
ev.xany.serial);
if (ev.xexpose.count == 0) // last Expose of the batch
needsRedraw = true;
break;
case ClientMessage:
if (cast(Atom) ev.xclient.ev.xclient.datadata.l[0] == wmDelete)
{
emit("close_requested via=WM_DELETE_WINDOW");
running = false;
}
break;
case KeyPress:
emit("close_requested via=KeyPress");
running = false;
break;
default:
if (buf.buf.usingShmusingShm && ev.type == shmCompletionType)
awaitingCompletion = false;
break;
}
}
// Storm driver (auto-exit mode): self resizes every ~6 frames, then
// the burst, then external resizes from the second connection.
if ((local variable) const(bool) autoExitautoExit && (local variable) bool sawFirstPixelsawFirstPixel && !(local variable) bool awaitingCompletionawaitingCompletion)
{
if ((local variable) int selfIssuedselfIssued < (immutable global) immutable(int[2][6]) app.main.selfStormselfStorm.(constant) ulong immutable(int[2][6]).length = 6LUlength && (local variable) int framesframes >= 6 * ((local variable) int selfIssuedselfIssued + 1))
{
const (local variable) immutable(int[2]) ss = (immutable global) immutable(int[2][6]) app.main.selfStormselfStorm[(local variable) int selfIssuedselfIssued];
XResizeWindow(dpy, win, cast(uint) s[0], cast(uint) s[1]);
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("step", "name=XResizeWindow conn=self n=%d size=%dx%d",
(local variable) int selfIssuedselfIssued + 1, (local variable) immutable(int[2]) ss[0], (local variable) immutable(int[2]) ss[1]);
(local variable) int pendingWpendingW = (local variable) immutable(int[2]) ss[0];
(local variable) int pendingHpendingH = (local variable) immutable(int[2]) ss[1];
++(local variable) int selfIssuedselfIssued;
}
else if ((local variable) int selfIssuedselfIssued == (immutable global) immutable(int[2][6]) app.main.selfStormselfStorm.(constant) ulong immutable(int[2][6]).length = 6LUlength && !(local variable) bool burstIssuedburstIssued
&& (local variable) int framesframes >= 6 * ((local variable) int selfIssuedselfIssued + 1))
{
foreach ((parameter) ulong ii, (parameter) immutable(int[2]) ss; (immutable global) immutable(int[2][3]) app.main.burstburst) // three requests, no frame in between
{
XResizeWindow(dpy, win, cast(uint) s[0], cast(uint) s[1]);
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("step", "name=XResizeWindow conn=self_burst n=%zu size=%dx%d",
(local variable) ulong ii + 1, (local variable) immutable(int[2]) ss[0], (local variable) immutable(int[2]) ss[1]);
}
(local variable) int pendingWpendingW = (immutable global) immutable(int[2][3]) app.main.burstburst[$ - 1][0];
(local variable) int pendingHpendingH = (immutable global) immutable(int[2][3]) app.main.burstburst[$ - 1][1];
(local variable) bool burstIssuedburstIssued = true;
}
else if ((local variable) bool burstIssuedburstIssued && (local variable) int extIssuedextIssued < (immutable global) immutable(int[2][4]) app.main.extStormextStorm.(constant) ulong immutable(int[2][4]).length = 4LUlength
&& (local variable) int framesframes >= 6 * ((local variable) int selfIssuedselfIssued + 2 + (local variable) int extIssuedextIssued))
{
if (dpy2 is null)
{
dpy2 = XOpenDisplay(null);
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("step", "name=XOpenDisplay conn=external fd=%d",
dpy2 !is null ? XConnectionNumber(dpy2) : -1);
}
if (dpy2 !is null)
{
const (local variable) immutable(int[2]) ss = (immutable global) immutable(int[2][4]) app.main.extStormextStorm[(local variable) int extIssuedextIssued];
XResizeWindow(dpy2, win, cast(uint) s[0], cast(uint) s[1]);
XSync(dpy2, False); // make the external client synchronous
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("step", "name=XResizeWindow conn=external n=%d size=%dx%d",
(local variable) int extIssuedextIssued + 1, (local variable) immutable(int[2]) ss[0], (local variable) immutable(int[2]) ss[1]);
(local variable) int pendingWpendingW = (local variable) immutable(int[2]) ss[0];
(local variable) int pendingHpendingH = (local variable) immutable(int[2]) ss[1];
}
++(local variable) int extIssuedextIssued;
if ((local variable) int extIssuedextIssued == (immutable global) immutable(int[2][4]) app.main.extStormextStorm.(constant) ulong immutable(int[2][4]).length = 4LUlength && dpy2 !is null)
{
XCloseDisplay(dpy2);
dpy2 = null;
void instrument.emit(scope const(char)* kind) nothrow @nogcEmit an event with no key=value payload.
emit("step name=XCloseDisplay conn=external");
}
}
++(local variable) int phasephase;
(local variable) bool needsRedrawneedsRedraw = true;
}
// Present. A frame drawn while a resize request is still in flight is
// the structural X11 stale-frame artifact — log it as such.
if ((local variable) bool needsRedrawneedsRedraw && !(local variable) bool awaitingCompletionawaitingCompletion && buf.(field) _error_ buf.ximgximg !is null)
{
drawGradient(buf.buf.ximgximg, phase);
if (buf.(field) _error_ buf.usingShmusingShm)
{
XShmPutImage(dpy, win, gc, buf.buf.ximgximg, 0, 0, 0, 0,
cast(uint) buf.buf.widthwidth, cast(uint) buf.buf.heightheight, True);
XFlush(dpy); // push the put before sleeping in poll()
(local variable) bool awaitingCompletionawaitingCompletion = true;
}
else
{
XPutImage(dpy, win, gc, buf.buf.ximgximg, 0, 0, 0, 0,
cast(uint) buf.buf.widthwidth, cast(uint) buf.buf.heightheight);
XSync(dpy, False);
}
if (!(local variable) bool sawFirstPixelsawFirstPixel)
{
(local variable) bool sawFirstPixelsawFirstPixel = true;
void instrument.emit(scope const(char)* kind) nothrow @nogcEmit an event with no key=value payload.
emit("first_pixel_presented");
}
++(local variable) int framesframes;
if ((local variable) int pendingWpendingW != 0 && (buf.(field) _error_ buf.widthwidth != (local variable) int pendingWpendingW || buf.(field) _error_ buf.heightheight != (local variable) int pendingHpendingH))
{
++(local variable) int staleFramesstaleFrames;
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("stale_frame", "frame=%d size=%dx%d pending=%dx%d",
(local variable) int framesframes, buf.(field) _error_ buf.widthwidth, buf.(field) _error_ buf.heightheight, (local variable) int pendingWpendingW, (local variable) int pendingHpendingH);
}
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("frame_callback", "t=%lld frame=%d size=%dx%d",
long instrument.nowUs() nothrow @nogcMicroseconds elapsed since initInstrument.
nowUs(), (local variable) int framesframes, buf.(field) _error_ buf.widthwidth, buf.(field) _error_ buf.heightheight);
(local variable) bool needsRedrawneedsRedraw = false;
}
if ((local variable) const(bool) autoExitautoExit && ((local variable) int framesframes >= 140 || long instrument.nowUs() nothrow @nogcMicroseconds elapsed since initInstrument.
nowUs() > 8_000_000))
{
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("auto_exit", "frames=%d self=%d burst=%d ext=%d", (local variable) int framesframes,
(local variable) int selfIssuedselfIssued, cast(int) (local variable) bool burstIssuedburstIssued * 3, (local variable) int extIssuedextIssued);
break;
}
pollfd (local variable) _error_ pfdpfd;
pfd.pfd.fdfd = fd;
pfd.events = POLLIN;
pfd.revents = 0;
poll(&pfd, 1, autoExit ? 5 : -1);
}
// The F02 verdict line: zero protocol errors, zero size mismatches at exit.
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogcEmit an event with a printf-formatted key=value ... payload.
emitf("summary", "configures=%d reallocs=%d stale_frames=%d errors=%d final=%dx%d",
(local variable) int configuresconfigures, (local variable) int reallocsreallocs, (local variable) int staleFramesstaleFrames, (__gshared global) int app.g_xErrorsg_xErrors, (local variable) int widthwidth, (local variable) int heightheight);
void instrument.emit(scope const(char)* kind) nothrow @nogcEmit an event with no key=value payload.
emit("teardown");
return (__gshared global) int app.g_xErrorsg_xErrors == 0 ? 0 : 1;
}