app.dhover×279 error×51all
// F03 — modal-loop survival, X11 edition (../../../features/f03-modal-loop.md).
// Derived from the X11 scaffold (../scaffold/app.d) and the F02 demo
// (../f02-resize/app.d). On Win32, interactive resize/move traps the thread in
// a system modal loop (WM_ENTERSIZEMOVE) and the message pump stops being
// yours; the F03 spec asks each platform to prove animation survives that.
// X11's answer is that THERE IS NO MODAL LOOP TO SURVIVE: resize — self,
// external-client, or WM-mediated — is just more events in the same queue, and
// nothing ever takes the thread away from the app's own poll(2) loop. This
// demo makes that absence measurable:
//
//   * a ~2 Hz full-window color cycle, ticked by a TIMERFD polled alongside
//     the X connection fd — the animation clock is the app's own, exactly the
//     loop shape a framework owns; X11 never re-enters or blocks it;
//   * a `tick t=… n=… phase=… presented=0|1 gap_us=…` line per animation
//     frame, where gap_us is the delta to the previous tick — the modal-loop
//     symptom (animation freeze) would show as an unbounded gap;
//   * three instrumented phases: `calm` (baseline cadence), `self` (a resize
//     storm from the demo's own connection: XResizeWindow every other tick,
//     25 requests), `ext` (the same storm from a SECOND Display* connection —
//     what a WM or `xdotool` does), then a drain; per-phase
//     `gap_summary phase=… ticks=… resizes=… max_gap_us=…` lines at exit;
//   * every ConfigureNotify still triggers the naive realloc-the-SHM-segment
//     response from F02 — the worst-case per-resize work — and the tick
//     cadence must hold anyway;
//   * protocol errors via XSetErrorHandler; the run must end errors=0.
//
// Run it once on bare Xvfb and once with icewm inside the same Xvfb: under
// the WM every resize becomes a ConfigureRequest the WM mediates (see the
// F02 findings) — the closest X11 gets to "someone else is driving" — and the
// ticks must still flow. True interactive border-drag needs a human and a
// real session: Tier C, queued in ../../../manual-run-queue.md.
//
// WSI_AUTO_EXIT=1 bounds the run (~2.6 s, 156 ticks); otherwise it runs until
// WM_DELETE_WINDOW, ticking forever. Headless-safe: no display prints `SKIP:`
// and exits 0. Findings: ../../f03-modal-loop.md.
module 
(module) app
app
;
import
(module) c
c
; // ImportC: Xlib + Xutil + Xatom + XShm + sys/ipc + sys/shm + timerfd + poll
C preprocess command `cpp` failed for file `/home/runner/work/sparkles/sparkles/docs/research/window-system-integration/os-apis/x11/examples/f03-modal-loop/c.c`, exit status 1
import
(module) instrument
instrument
;
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.config

D compatible types that correspond to various basic types in associated C and C++ compilers.

Source

core/stdc/config.d

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly@standardsISO/IEC 9899:1999 (E)
config
: c_long, c_ulong;
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.stdio

D header file for C99 <stdio.h>

pubs.opengroup.org/onlinepubs/009695399/basedefs/stdio.h.html, stdio.h

Source

core/stdc/stdio.d

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly, Alex Rønne Petersen@standardsISO/IEC 9899:1999 (E)
stdio
:
(alias) app.printf = int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
;
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.stdlib

D header file for C99.

pubs.opengroup.org/onlinepubs/009695399/basedefs/stdlib.h.html, stdlib.h

Source

core/stdc/stdlib.d

@copyrightCopyright Sean Kelly 2005 - 2014.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly@standardsISO/IEC 9899:1999 (E)
stdlib
:
(alias) app.getenv = char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
;
import
(package) core
core
.
(package) core.sys
sys
.
(package) core.sys.posix
posix
.
(module) core.sys.posix.unistd

D header file for POSIX.

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseBoost License 1.0.@authorsSean Kelly@standardsThe Open Group Base Specifications Issue 8, IEEE Std 1003.1, 2024 Edition
unistd
:
(alias) app.read = long core.sys.posix.unistd.read(int, void*, ulong) nothrow @nogc
read
;
// 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 = 1L
KeyPressMask
= 1L << 0,
(enum value) app.ExposureMask = 32768L
ExposureMask
= 1L << 15,
(enum value) app.StructureNotifyMask = 131072L
StructureNotifyMask
= 1L << 17,
} enum // XEvent.type discriminators {
(enum value) app.KeyPress = 2
KeyPress
= 2,
(enum value) app.Expose = 12
Expose
= 12,
(enum value) app.MapNotify = 19
MapNotify
= 19,
(enum value) app.ReparentNotify = 21
ReparentNotify
= 21,
(enum value) app.ConfigureNotify = 22
ConfigureNotify
= 22,
(enum value) app.ClientMessage = 33
ClientMessage
= 33,
} enum
(constant) int app.ZPixmap = 2
ZPixmap
= 2;
enum
(constant) int app.ShmCompletion = 0
ShmCompletion
= 0; // offset inside MIT-SHM's allocated event range
enum
(constant) int app.False = 0
False
= 0;
enum
(constant) int app.True = 1
True
= 1;
enum
(constant) int app.POLLIN = 1
POLLIN
= 0x001;
enum
(constant) int app.IPC_PRIVATE = 0
IPC_PRIVATE
= 0;
enum
(constant) int app.IPC_CREAT = 512
IPC_CREAT
= 0x200; // 01000 octal
enum
(constant) int app.IPC_RMID = 0
IPC_RMID
= 0;
enum
(constant) int app.CLOCK_MONOTONIC = 1
CLOCK_MONOTONIC
= 1;
// --------------------------------------------------------------------------- // Protocol-error accounting, as in F02: Xlib reports errors asynchronously. __gshared int
(__gshared global) int app.g_xErrors
g_xErrors
= 0;
extern (C) int
app.onXError
onXError
(Display*
(parameter) Display* dpy
dpy
, XErrorEvent* e) @nogc nothrow
undefined identifier `Display`
undefined identifier `XErrorEvent`
{ char[128]
_error_ text
text
= 0;
XGetErrorText(dpy, e.error_code, text.
text.ptr
ptr
, text.length);
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.
text.ptr
ptr
);
++g_xErrors; return 0; } // --------------------------------------------------------------------------- // Backbuffer: MIT-SHM XImage with plain-XPutImage fallback (as the scaffold). struct
(struct) app.Backbuffer
Backbuffer
{ XImage*
(field) _error_ app.Backbuffer.ximg
ximg
;
undefined identifier `XImage`
XShmSegmentInfo
(field) _error_ app.Backbuffer.shminfo
shminfo
;
undefined identifier `XShmSegmentInfo`
bool
(field) bool app.Backbuffer.usingShm
usingShm
;
int
(field) int app.Backbuffer.width
width
,
(field) int app.Backbuffer.height
height
;
}
(struct) app.Backbuffer
Backbuffer
app.createBackbuffer
createBackbuffer
(Display*
(parameter) Display* dpy
dpy
, Visual*
(parameter) Visual* visual
visual
, int
(parameter) int depth
depth
,
undefined identifier `Display`
undefined identifier `Visual`
int
(parameter) int w
w
, int
(parameter) int h
h
, bool wantShm) @nogc nothrow
{
(unresolved type) Backbuffer
Backbuffer
_error_ b
b
;
b.
b.width
width
= w;
b.
b.height
height
= h;
if (wantShm) { b.
b.ximg
ximg
= XShmCreateImage(dpy, visual, cast(uint) depth, ZPixmap,
null, &b.
b.shminfo
shminfo
, cast(uint) w, cast(uint) h);
if (b.
b.ximg
ximg
!is null)
{ const
_error_ nbytes
nbytes
= cast(size_t)(b.
b.ximg
ximg
.bytes_per_line * b.
b.ximg
ximg
.
b.ximg.height
height
);
b.
b.shminfo
shminfo
.shmid = shmget(IPC_PRIVATE, nbytes, IPC_CREAT | 0x180 /* 0600 */ );
if (b.
b.shminfo
shminfo
.shmid >= 0)
{ b.
b.shminfo
shminfo
.shmaddr = cast(char*) shmat(b.
b.shminfo
shminfo
.shmid, null, 0);
if (b.
b.shminfo
shminfo
.shmaddr !is cast(char*)-1)
{ b.
b.ximg
ximg
.
b.ximg.data
data
= b.
b.shminfo
shminfo
.shmaddr;
b.
b.shminfo
shminfo
.readOnly = False;
XShmAttach(dpy, &b.
b.shminfo
shminfo
);
XSync(dpy, False); // server attached before ... shmctl(b.
b.shminfo
shminfo
.shmid, IPC_RMID, null); // ... mark-for-delete
b.
b.usingShm
usingShm
= true;
return b; } shmctl(b.
b.shminfo
shminfo
.shmid, IPC_RMID, null);
} b.
b.ximg
ximg
.f.destroy_image(b.
b.ximg
ximg
); // XDestroyImage is a macro
b.
b.ximg
ximg
= null;
} emit("step name=shm_fallback reason=alloc_or_attach_failed"); } import core.stdc.stdlib : malloc; auto
_error_ data
data
= cast(char*) malloc(cast(size_t) w * h * 4);
b.
b.ximg
ximg
= XCreateImage(dpy, visual, cast(uint) depth, ZPixmap, 0, data,
cast(uint) w, cast(uint) h, 32, 0); b.
b.usingShm
usingShm
= false;
return b; } void
app.destroyBackbuffer
destroyBackbuffer
(Display*
(parameter) Display* dpy
dpy
, ref
(struct) app.Backbuffer
Backbuffer
(parameter) Backbuffer b
b
) @nogc nothrow
undefined identifier `Display`
{ if (b.
b.ximg
ximg
is null)
return; if (b.
b.usingShm
usingShm
)
{ XSync(dpy, False); // let any in-flight XShmPutImage finish reading XShmDetach(dpy, &b.
b.shminfo
shminfo
);
} b.
b.ximg
ximg
.f.destroy_image(b.
b.ximg
ximg
);
if (b.
b.usingShm
usingShm
)
shmdt(b.
b.shminfo
shminfo
.shmaddr);
b.
b.ximg
ximg
= null;
} /// Full-window solid fill from an 8-bit hue phase: three 120°-offset triangle /// waves (R/G/B). Phase advances 8 steps per ~16 ms tick — a full cycle every /// 32 ticks, i.e. the spec's ~2 Hz color cycle at the 62.5 Hz tick rate. void
app.fillColorCycle

Full-window solid fill from an 8-bit hue phase: three 120°-offset triangle waves (R/G/B). Phase advances 8 steps per ~16 ms tick — a full cycle every 32 ticks, i.e. the spec's ~2 Hz color cycle at the 62.5 Hz tick rate.

fillColorCycle
(XImage*
(parameter) XImage* ximg
ximg
, int phase) @nogc nothrow
undefined identifier `XImage`
{ static uint
uint tri(int p) nothrow @nogc
tri
(int
(parameter) int p
p
) @nogc nothrow // triangle wave, period 256, 0..255
{ const
_error_ v
v
= p & 0xff;
return cast(uint)(v < 128 ? v * 2 : (255 - v) * 2); } const
_error_ rgb
rgb
= (tri(phase) << 16) | (tri(phase + 85) << 8) | tri(phase + 170);
const
_error_ w
w
= ximg.
ximg.width
width
,
_error_ h
h
= ximg.
ximg.height
height
;
if (ximg.bits_per_pixel != 32) return; foreach (
(parameter) y
y
; 0 .. h)
{ auto
_error_ row
row
= cast(uint*)(ximg.
ximg.data
data
+ y * ximg.bytes_per_line);
row[0 .. w] = rgb; } } int
int D main()
main
()
{
void instrument.initInstrument(const(char)* demoName) nothrow @nogc

Names the demo, starts the monotonic clock, and emits init_start. Call this first, before any platform API call.

initInstrument
("f03_x11");
const
(local variable) const(char*) envAuto
envAuto
=
char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
("WSI_AUTO_EXIT");
const
(local variable) const(bool) autoExit
autoExit
=
(local variable) const(char*) envAuto
envAuto
!is null &&
(local variable) const(char*) envAuto
envAuto
[0] == '1';
XSetErrorHandler(&onXError);
undefined identifier `XSetErrorHandler`
Display*
(local variable) _error_ dpy
dpy
= XOpenDisplay(null);
undefined identifier `Display`
undefined identifier `XOpenDisplay`
if (dpy is null) {
int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
("SKIP: no X11 display (XOpenDisplay returned null)\n");
return 0; }
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("step", "name=XOpenDisplay fd=%d", XConnectionNumber(dpy));
undefined identifier `XConnectionNumber`
const
(local variable) const(_error_) screen
screen
= XDefaultScreen(dpy);
undefined identifier `XDefaultScreen`
const
(local variable) const(_error_) root
root
= XRootWindow(dpy, screen);
undefined identifier `XRootWindow`
Visual*
(local variable) _error_ visual
visual
= XDefaultVisual(dpy, screen);
undefined identifier `Visual`
undefined identifier `XDefaultVisual`
const
(local variable) const(_error_) depth
depth
= XDefaultDepth(dpy, screen);
undefined identifier `XDefaultDepth`
bool
(local variable) bool haveShm
haveShm
= XShmQueryExtension(dpy) != 0 &&
char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
("WSI_NO_SHM") is null;
undefined identifier `XShmQueryExtension`
int
(local variable) int shmCompletionType
shmCompletionType
=
(local variable) bool haveShm
haveShm
? XShmGetEventBase(dpy) + ShmCompletion : -1;
undefined identifier `XShmGetEventBase`
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("step", "name=XShmQueryExtension using_shm=%d", cast(int)
(local variable) bool haveShm
haveShm
);
int
(local variable) int width
width
= 480,
(local variable) int height
height
= 320;
Window
(local variable) _error_ win
win
= XCreateSimpleWindow(dpy, root, 0, 0, width, height, 1,
undefined identifier `Window`
undefined identifier `XCreateSimpleWindow`
XBlackPixel(dpy, screen), XWhitePixel(dpy, screen));
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("step", "name=XCreateSimpleWindow xid=0x%lx", win);
XStoreName(dpy, win, "Sparkles · X11 F03");
undefined identifier `XStoreName`
Atom
(local variable) _error_ wmDelete
wmDelete
= XInternAtom(dpy, "WM_DELETE_WINDOW", False);
undefined identifier `Atom`
undefined identifier `XInternAtom`
XSetWMProtocols(dpy, win, &wmDelete, 1);
undefined identifier `XSetWMProtocols`
XSelectInput(dpy, win, ExposureMask | KeyPressMask | StructureNotifyMask);
undefined identifier `XSelectInput`
XMapWindow(dpy, win);
undefined identifier `XMapWindow`
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("window_created", "xid=0x%lx size=%dx%d", win,
(local variable) int width
width
,
(local variable) int height
height
);
GC
(local variable) _error_ gc
gc
= XDefaultGC(dpy, screen);
undefined identifier `GC`
undefined identifier `XDefaultGC`
auto
(local variable) _error_ buf
buf
= createBackbuffer(dpy, visual, depth, width, height, haveShm);
// -- The animation heartbeat: a timerfd at 16 ms (62.5 Hz) ---------------- // The clock the app OWNS — F03's point is that on X11 nothing the window // system does can stop this fd from firing or the loop from reading it. const
(local variable) const(_error_) tfd
tfd
= timerfd_create(CLOCK_MONOTONIC, 0);
undefined identifier `timerfd_create`
itimerspec
(local variable) _error_ its
its
;
undefined identifier `itimerspec`
its.it_interval.tv_sec = 0; its.it_interval.tv_nsec = 16_000_000; // 16 ms its.it_value = its.it_interval; timerfd_settime(tfd, 0, &its, null);
undefined identifier `timerfd_settime`
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("step", "name=timerfd_create fd=%d interval_ms=16", tfd);
Display*
(local variable) _error_ dpy2
dpy2
= null; // the "outside world" connection for the ext phase
undefined identifier `Display`
scope (exit) { if (dpy2 !is null) XCloseDisplay(dpy2);
undefined identifier `XCloseDisplay`
destroyBackbuffer(dpy, buf); XDestroyWindow(dpy, win);
undefined identifier `XDestroyWindow`
XCloseDisplay(dpy);
undefined identifier `XCloseDisplay`
} // -- Phase plan (auto-exit mode) ------------------------------------------ // calm ticks 1..31 no resizes (baseline tick cadence) // self ticks 32..81 XResizeWindow on dpy every other tick (25 reqs) // ext ticks 82..131 XResizeWindow on dpy2 every other tick (25 reqs) // drain ticks 132..156 no resizes (recovery), then exit static immutable int[2][6]
(immutable global) immutable(int[2][6]) app.main.sizes
sizes
= [
[640, 400], [320, 240], [800, 520], [400, 300], [720, 480], [360, 260], ]; enum
(constant) int app.main.calmEnd = 31
calmEnd
= 31,
(constant) int app.main.selfEnd = 81
selfEnd
= 81,
(constant) int app.main.extEnd = 131
extEnd
= 131,
(constant) int app.main.lastTick = 156
lastTick
= 156;
static immutable
(alias) object.string = string
string
[4]
(immutable global) immutable(string[4]) app.main.phaseNames
phaseNames
= ["calm", "self", "ext", "drain"];
long[4]
(local variable) long[4] maxGap
maxGap
= 0;
int[4]
(local variable) int[4] phaseTicks
phaseTicks
= 0,
(local variable) int[4] phaseResizes
phaseResizes
= 0;
const
(local variable) const(_error_) xfd
xfd
= XConnectionNumber(dpy);
undefined identifier `XConnectionNumber`
bool
(local variable) bool running
running
= true,
(local variable) bool awaitingCompletion
awaitingCompletion
= false,
(local variable) bool sawFirstPixel
sawFirstPixel
= false;
int
(local variable) int ticks
ticks
= 0,
(local variable) int colorPhase
colorPhase
= 0,
(local variable) int sizeIdx
sizeIdx
= 0;
long
(local variable) long lastTickUs
lastTickUs
= 0;
while (
(local variable) bool running
running
)
{ while (XPending(dpy) > 0) // XPending also flushes the output buffer
undefined identifier `XPending`
{ XEvent
(local variable) _error_ ev
ev
;
undefined identifier `XEvent`
XNextEvent(dpy, &ev);
undefined identifier `XNextEvent`
switch (ev.type) { case MapNotify: emitf("map_notify", "serial=%lu", ev.xany.serial); break; case ReparentNotify: // a WM adopted us (never seen on bare Xvfb) emitf("reparent_notify", "parent=0x%lx", ev.xreparent.parent); break; case ConfigureNotify: const
_error_ cw
cw
= ev.xconfigure.
ev.xconfigure.width
width
,
_error_ ch
ch
= ev.xconfigure.
ev.xconfigure.height
height
;
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); emitf("buffer_realloc", "size=%dx%d shm=%d", width, height, cast(int) buf.
buf.usingShm
usingShm
);
} break; case Expose: if (ev.xexpose.count == 0 && !sawFirstPixel) { // Present the very first frame eagerly so the run is // anchored; afterwards only ticks present. fillColorCycle(buf.
buf.ximg
ximg
, colorPhase);
if (buf.
buf.usingShm
usingShm
)
{ XShmPutImage(dpy, win, gc, buf.
buf.ximg
ximg
, 0, 0, 0, 0,
cast(uint) buf.
buf.width
width
, cast(uint) buf.
buf.height
height
, True);
XFlush(dpy); awaitingCompletion = true; } else { XPutImage(dpy, win, gc, buf.
buf.ximg
ximg
, 0, 0, 0, 0,
cast(uint) buf.
buf.width
width
, cast(uint) buf.
buf.height
height
);
XSync(dpy, False); } sawFirstPixel = true; emit("first_pixel_presented"); } break; case ClientMessage: if (cast(Atom) ev.xclient.
ev.xclient.data
data
.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.usingShm
usingShm
&& ev.type == shmCompletionType)
awaitingCompletion = false; break; } } // -- Wait for either X traffic or the next animation tick ------------- pollfd[2]
(local variable) _error_ pfds
pfds
;
undefined identifier `pollfd`
pfds[0].fd = xfd; pfds[0].events = POLLIN; pfds[0].revents = 0; pfds[1].fd = tfd; pfds[1].events = POLLIN; pfds[1].revents = 0; poll(pfds.
pfds.ptr
ptr
, 2, -1);
undefined identifier `poll`
if (!(pfds[1].revents & POLLIN) || !
(local variable) bool sawFirstPixel
sawFirstPixel
)
continue; // X traffic only — loop back to drain it ulong
(local variable) ulong expirations
expirations
;
long core.sys.posix.unistd.read(int, void*, ulong) nothrow @nogc
read
(tfd, &
(local variable) ulong expirations
expirations
,
(local variable) ulong expirations
expirations
.
(constant) ulong ulong.sizeof = 8LU
sizeof
);
// -- One animation tick ------------------------------------------------ ++
(local variable) int ticks
ticks
;
(local variable) int colorPhase
colorPhase
+= 8; // 8/256 per 16 ms tick ≈ 2 full cycles per second
const
(local variable) const(int) phaseIdx
phaseIdx
=
(local variable) int ticks
ticks
<=
(constant) int app.main.calmEnd = 31
calmEnd
? 0 :
(local variable) int ticks
ticks
<=
(constant) int app.main.selfEnd = 81
selfEnd
? 1
:
(local variable) int ticks
ticks
<=
(constant) int app.main.extEnd = 131
extEnd
? 2 : 3;
// The storm driver: during `self`/`ext`, fire a resize every other // tick while the animation must keep its cadence. if (
(local variable) const(bool) autoExit
autoExit
&& (
(local variable) const(int) phaseIdx
phaseIdx
== 1 ||
(local variable) const(int) phaseIdx
phaseIdx
== 2) && (
(local variable) int ticks
ticks
& 1) == 0)
{ const
(local variable) immutable(int[2]) s
s
=
(immutable global) immutable(int[2][6]) app.main.sizes
sizes
[
(local variable) int sizeIdx
sizeIdx
% $];
++
(local variable) int sizeIdx
sizeIdx
;
if (
(local variable) const(int) phaseIdx
phaseIdx
== 1)
{ XResizeWindow(dpy, win, cast(uint) s[0], cast(uint) s[1]);
undefined identifier `XResizeWindow`
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("step", "name=XResizeWindow conn=self n=%d size=%dx%d",
(local variable) int[4] phaseResizes
phaseResizes
[1] + 1,
(local variable) immutable(int[2]) s
s
[0],
(local variable) immutable(int[2]) s
s
[1]);
} else { if (dpy2 is null) { dpy2 = XOpenDisplay(null);
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("step", "name=XOpenDisplay conn=external fd=%d",
dpy2 !is null ? XConnectionNumber(dpy2) : -1);
undefined identifier `XConnectionNumber`
} if (dpy2 !is null) { XResizeWindow(dpy2, win, cast(uint) s[0], cast(uint) s[1]);
undefined identifier `XResizeWindow`
XSync(dpy2, False);
undefined identifier `XSync`
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("step", "name=XResizeWindow conn=external n=%d size=%dx%d",
(local variable) int[4] phaseResizes
phaseResizes
[2] + 1,
(local variable) immutable(int[2]) s
s
[0],
(local variable) immutable(int[2]) s
s
[1]);
} } ++
(local variable) int[4] phaseResizes
phaseResizes
[
(local variable) const(int) phaseIdx
phaseIdx
];
} // Present this tick's color. With MIT-SHM the segment must not be // rewritten while the server still reads it; a tick that lands inside // that sub-millisecond window is logged presented=0 (the heartbeat // still beat — only the pixels waited one frame). bool
(local variable) bool presented
presented
= false;
if (!
(local variable) bool awaitingCompletion
awaitingCompletion
&& buf.
(field) _error_ buf.ximg
ximg
!is null)
{ fillColorCycle(buf.
buf.ximg
ximg
, colorPhase);
if (buf.
(field) _error_ buf.usingShm
usingShm
)
{ XShmPutImage(dpy, win, gc, buf.
buf.ximg
ximg
, 0, 0, 0, 0,
undefined identifier `XShmPutImage`
cast(uint) buf.
buf.width
width
, cast(uint) buf.
buf.height
height
, True);
XFlush(dpy);
undefined identifier `XFlush`
(local variable) bool awaitingCompletion
awaitingCompletion
= true;
} else { XPutImage(dpy, win, gc, buf.
buf.ximg
ximg
, 0, 0, 0, 0,
undefined identifier `XPutImage`
cast(uint) buf.
buf.width
width
, cast(uint) buf.
buf.height
height
);
XSync(dpy, False);
undefined identifier `XSync`
}
(local variable) bool presented
presented
= true;
} const
(local variable) const(long) now
now
=
long instrument.nowUs() nothrow @nogc

Microseconds elapsed since initInstrument.

nowUs
();
const
(local variable) const(long) gap
gap
=
(local variable) long lastTickUs
lastTickUs
== 0 ? 0 :
(local variable) const(long) now
now
-
(local variable) long lastTickUs
lastTickUs
;
(local variable) long lastTickUs
lastTickUs
=
(local variable) const(long) now
now
;
++
(local variable) int[4] phaseTicks
phaseTicks
[
(local variable) const(int) phaseIdx
phaseIdx
];
if (
(local variable) const(long) gap
gap
>
(local variable) long[4] maxGap
maxGap
[
(local variable) const(int) phaseIdx
phaseIdx
])
(local variable) long[4] maxGap
maxGap
[
(local variable) const(int) phaseIdx
phaseIdx
] =
(local variable) const(long) gap
gap
;
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("tick", "t=%lld n=%d phase=%s presented=%d gap_us=%lld",
(local variable) const(long) now
now
,
(local variable) int ticks
ticks
,
(immutable global) immutable(string[4]) app.main.phaseNames
phaseNames
[
(local variable) const(int) phaseIdx
phaseIdx
].
(field) immutable(char)* immutable(string).ptr
ptr
, cast(int)
(local variable) bool presented
presented
,
(local variable) const(long) gap
gap
);
if (
(local variable) const(bool) autoExit
autoExit
&&
(local variable) int ticks
ticks
>=
(constant) int app.main.lastTick = 156
lastTick
)
break; } // -- The F03 verdict: per-phase tick cadence under resize fire ------------- foreach (
(parameter) ulong i
i
,
(parameter) immutable(string) name
name
;
(immutable global) immutable(string[4]) app.main.phaseNames
phaseNames
)
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("gap_summary", "phase=%s ticks=%d resizes=%d max_gap_us=%lld",
(local variable) immutable(string) name
name
.
(field) immutable(char)* immutable(string).ptr
ptr
,
(local variable) int[4] phaseTicks
phaseTicks
[
(local variable) ulong i
i
],
(local variable) int[4] phaseResizes
phaseResizes
[
(local variable) ulong i
i
],
(local variable) long[4] maxGap
maxGap
[
(local variable) ulong i
i
]);
const
(local variable) const(long) stormMax
stormMax
=
(local variable) long[4] maxGap
maxGap
[1] >
(local variable) long[4] maxGap
maxGap
[2] ?
(local variable) long[4] maxGap
maxGap
[1] :
(local variable) long[4] maxGap
maxGap
[2];
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

Emit an event with a printf-formatted key=value ... payload.

emitf
("finding", "modal_loop=absent max_gap_storm_us=%lld errors=%d",
(local variable) const(long) stormMax
stormMax
,
(__gshared global) int app.g_xErrors
g_xErrors
);
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("teardown");
return
(__gshared global) int app.g_xErrors
g_xErrors
== 0 ? 0 : 1;
}