app.dhover×226 error×40all
// X11 windowing-demo scaffold — the evolved form of ../../example/app.d (the
// irreducible Xlib window). On top of the minimal sequence it implements the
// full demo contract every feature demo (F01..F17) in this tree follows:
//
//   * WM_PROTOCOLS / WM_DELETE_WINDOW close handshake (graceful close)
//   * software gradient presented through MIT-SHM (XShmCreateImage /
//     XShmPutImage with a requested XShmCompletionEvent); when the extension
//     is absent (or attach fails) it logs `step name=shm_fallback` and uses
//     plain XPutImage + XSync instead
//   * readiness event loop: poll(2) on the connection fd
//     (ConnectionNumber(dpy), reached via its function form XConnectionNumber
//     since the macro is not ImportC-able), draining with XPending/XNextEvent
//     after readiness — never blocking inside XNextEvent
//   * redraw on Expose; image + SHM segment reallocation on ConfigureNotify
//     size changes; clean teardown (XShmDetach -> destroy_image -> shmdt)
//   * instrumentation per the F01 spec (../../../features/f01-first-pixel.md)
//     via instrument.d: init_start, step name=<api>, window_created,
//     first_configure, first_pixel_presented, resize, frame_callback,
//     close_requested
//   * WSI_AUTO_EXIT=1 -> bounded run (~120 redraws or ~2 s) including a
//     10-step programmatic XResizeWindow storm (F02 spec), then exit 0;
//     otherwise runs until the WM delivers WM_DELETE_WINDOW
//
// Headless-safe: if no X server is reachable, prints `SKIP:` to stdout and
// exits 0. See ../../index.md (the X11 OS-API survey) and ../../scaffold.md
// (the findings this program produced).
module 
(module) app
app
;
import
(module) c
c
; // ImportC: Xlib + Xutil + Xatom + XShm + sys/ipc + sys/shm + poll
C preprocess command `cpp` failed for file `/home/runner/work/sparkles/sparkles/docs/research/window-system-integration/os-apis/x11/examples/scaffold/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
;
// --------------------------------------------------------------------------- // Constants Xlib/glibc expose as macros that ImportC does not reliably import // (expression macros like `(1L<<15)` and cast-expressions like IPC_PRIVATE). // Re-declared per the ImportC guide; module-local declarations shadow any // same-named enums the shim may have imported. 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.MapNotify = 19
MapNotify
= 19,
(enum value) app.ConfigureNotify = 22
ConfigureNotify
= 22,
(enum value) app.Expose = 12
Expose
= 12,
(enum value) app.ClientMessage = 33
ClientMessage
= 33,
} enum
(constant) int app.ZPixmap = 2
ZPixmap
= 2; // XImage format
enum
(constant) int app.ShmCompletion = 0
ShmCompletion
= 0; // event 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;
// --------------------------------------------------------------------------- // The software framebuffer: an XImage either backed by a SysV shared-memory // segment the X server attaches (MIT-SHM, zero protocol-stream copies) or by // a malloc'd buffer pushed through the wire with XPutImage. 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
;
} /// (Re)allocate the backbuffer at `w`x`h`. Tries MIT-SHM when `wantShm`; /// falls back to a plain client-side XImage (and reports it) on any failure. /// `logSteps` makes the first allocation emit one `step` line per API call.
(struct) app.Backbuffer
Backbuffer
app.createBackbuffer

(Re)allocate the backbuffer at wxh. Tries MIT-SHM when wantShm; falls back to a plain client-side XImage (and reports it) on any failure. logSteps makes the first allocation emit one step line per API call.

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, bool logSteps) @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 (logSteps && b.
b.ximg
ximg
!is null)
emitf("step", "name=XShmCreateImage size=%dx%d bpl=%d bpp=%d", w, h, b.
b.ximg
ximg
.bytes_per_line, b.
b.ximg
ximg
.bits_per_pixel);
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 (logSteps) emitf("step", "name=shmget shmid=%d bytes=%zu", b.
b.shminfo
shminfo
.shmid, nbytes);
if (b.
b.shminfo
shminfo
.shmid >= 0)
{ b.
b.shminfo
shminfo
.shmaddr = cast(char*) shmat(b.
b.shminfo
shminfo
.shmid, null, 0);
if (logSteps) emitf("step", "name=shmat ok=%d", cast(int)(b.
b.shminfo
shminfo
.shmaddr !is cast(char*)-1));
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
); // async request: server maps the segment
XSync(dpy, False); // round-trip so the server has attached ... shmctl(b.
b.shminfo
shminfo
.shmid, IPC_RMID, null); // ... before we mark-for-delete
if (logSteps) { emit("step name=XShmAttach"); emit("step name=XSync"); emit("step name=shmctl_IPC_RMID"); } 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; call its body
b.
b.ximg
ximg
= null;
} emitf("step", "name=shm_fallback reason=%s", b.
b.ximg
ximg
is null ? "alloc_failed".ptr : "attach_failed".ptr);
} // Plain path: client-side buffer, pixels travel through the X byte stream. 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); if (logSteps) emitf("step", "name=XCreateImage size=%dx%d bpl=%d bpp=%d", w, h, b.
b.ximg
ximg
.bytes_per_line, b.
b.ximg
ximg
.bits_per_pixel);
b.
b.usingShm
usingShm
= false;
return b; } /// Tear down in the order the MIT-SHM spec prescribes: /// XShmDetach -> XDestroyImage -> shmdt (the segment id was already /// IPC_RMID-marked at creation, so the kernel frees it once both detach). void
app.destroyBackbuffer

Tear down in the order the MIT-SHM spec prescribes: XShmDetach -> XDestroyImage -> shmdt (the segment id was already IPC_RMID-marked at creation, so the kernel frees it once both detach).

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
); // shm variant frees only the struct; plain variant frees data too
if (b.
b.usingShm
usingShm
)
shmdt(b.
b.shminfo
shminfo
.shmaddr);
b.
b.ximg
ximg
= null;
} /// Corner-anchored diagonal gradient so stretching / stale buffers during the /// resize storm are visible (F02 requirement 1). `phase` animates the blue /// channel so successive frames are distinguishable. void
app.drawGradient

Corner-anchored diagonal gradient so stretching / stale buffers during the resize storm are visible (F02 requirement 1). phase animates the blue channel so successive frames are distinguishable.

drawGradient
(XImage*
(parameter) XImage* ximg
ximg
, int
(parameter) int phase
phase
) @nogc nothrow
undefined identifier `XImage`
{ const
_error_ w
w
= ximg.
ximg.width
width
,
_error_ h
h
= ximg.
ximg.height
height
;
if (ximg.bits_per_pixel == 32) { foreach (
(parameter) y
y
; 0 .. h)
{ auto
_error_ row
row
= cast(uint*)(ximg.
ximg.data
data
+ y * ximg.bytes_per_line);
const
_error_ g
g
= cast(uint)(h > 1 ? (y * 255) / (h - 1) : 0);
foreach (
(parameter) x
x
; 0 .. w)
{ const
_error_ r
r
= cast(uint)(w > 1 ? (x * 255) / (w - 1) : 0);
const
_error_ bl
bl
= cast(uint)((x + y + phase) & 0xff);
row[x] = (r << 16) | (g << 8) | bl; } } } else // unexpected visual: visible flat fill rather than garbage { import core.stdc.string : memset; memset(ximg.
ximg.data
data
, 0x55, cast(size_t)(ximg.bytes_per_line * h));
} } 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
("x11_scaffold");
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';
// -- Connect ------------------------------------------------------------ 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`
// -- MIT-SHM availability (this query is a round-trip) ------------------- // WSI_NO_SHM=1 forces the plain-XPutImage path (what a TCP/remote display // would get: MIT-SHM only works when client and server share a kernel). bool
(local variable) bool haveShm
haveShm
= XShmQueryExtension(dpy) != 0;
undefined identifier `XShmQueryExtension`
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 available=%d", cast(int)
(local variable) bool haveShm
haveShm
);
int
(local variable) int shmCompletionType
shmCompletionType
= -1;
if (
(local variable) bool haveShm
haveShm
&&
char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
("WSI_NO_SHM") !is null)
{
(local variable) bool haveShm
haveShm
= false;
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("step name=shm_fallback reason=WSI_NO_SHM");
} else if (
(local variable) bool haveShm
haveShm
)
{
(local variable) int shmCompletionType
shmCompletionType
= XShmGetEventBase(dpy) + ShmCompletion;
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=XShmGetEventBase completion_event=%d",
(local variable) int shmCompletionType
shmCompletionType
);
} else
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("step name=shm_fallback reason=extension_absent");
// -- Window + WM close handshake ----------------------------------------- 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 scaffold");
undefined identifier `XStoreName`
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("step name=XStoreName");
Atom
(local variable) _error_ wmDelete
wmDelete
= XInternAtom(dpy, "WM_DELETE_WINDOW", False); // round-trip
undefined identifier `Atom`
undefined identifier `XInternAtom`
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=XInternAtom atom=%lu", wmDelete);
XSetWMProtocols(dpy, win, &wmDelete, 1);
undefined identifier `XSetWMProtocols`
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("step name=XSetWMProtocols");
XSelectInput(dpy, win, ExposureMask | KeyPressMask | StructureNotifyMask);
undefined identifier `XSelectInput`
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("step name=XSelectInput");
XMapWindow(dpy, win);
undefined identifier `XMapWindow`
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("step name=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`
// -- Backbuffer ----------------------------------------------------------- auto
(local variable) _error_ buf
buf
= createBackbuffer(dpy, visual, depth, width, height, haveShm, true);
scope (exit) { destroyBackbuffer(dpy, buf); XDestroyWindow(dpy, win);
undefined identifier `XDestroyWindow`
XCloseDisplay(dpy);
undefined identifier `XCloseDisplay`
} // -- Event loop: poll(2) the connection fd, drain with XPending ----------- // The resize storm the F02 spec asks for: 10 XResizeWindow calls of // varying sizes, one every ~10 frames, so event-loop turns interleave. static immutable int[2][10]
(immutable global) immutable(int[2][10]) app.main.storm
storm
= [
[640, 400], [320, 240], [800, 520], [400, 300], [720, 480], [360, 260], [900, 560], [480, 300], [560, 380], [640, 420], ]; const
(local variable) const(_error_) fd
fd
= XConnectionNumber(dpy);
undefined identifier `XConnectionNumber`
bool
(local variable) bool running
running
= true,
(local variable) bool needsRedraw
needsRedraw
= false,
(local variable) bool awaitingCompletion
awaitingCompletion
= false;
bool
(local variable) bool sawFirstConfigure
sawFirstConfigure
= false,
(local variable) bool sawFirstPixel
sawFirstPixel
= false;
int
(local variable) int frames
frames
= 0,
(local variable) int phase
phase
= 0,
(local variable) int resizesIssued
resizesIssued
= 0;
while (
(local variable) bool running
running
)
{ // Drain everything already queued / readable. XPending flushes the // output buffer as a side effect, so buffered requests always reach // the server before we sleep in poll(). while (XPending(dpy) > 0)
undefined identifier `XPending`
{ XEvent
(local variable) _error_ ev
ev
;
undefined identifier `XEvent`
XNextEvent(dpy, &ev); // does not block: an event is pending
undefined identifier `XNextEvent`
switch (ev.type) { case MapNotify: if (!sawFirstConfigure) { sawFirstConfigure = true; emitf("first_configure", "kind=MapNotify size=%dx%d", width, height); } break; case ConfigureNotify: const
_error_ cw
cw
= ev.xconfigure.
ev.xconfigure.width
width
,
_error_ ch
ch
= ev.xconfigure.
ev.xconfigure.height
height
;
if (!sawFirstConfigure) { sawFirstConfigure = true; emitf("first_configure", "kind=ConfigureNotify size=%dx%d", cw, ch); } 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, false); emitf("buffer_realloc", "size=%dx%d shm=%d bytes=%d", width, height, cast(int) buf.
buf.usingShm
usingShm
, buf.
buf.ximg
ximg
.bytes_per_line * buf.
buf.ximg
ximg
.
buf.ximg.height
height
);
needsRedraw = true; } break; case Expose: emitf("expose", "count=%d area=%dx%d+%d+%d", ev.xexpose.count, ev.xexpose.
ev.xexpose.width
width
, ev.xexpose.
ev.xexpose.height
height
, ev.xexpose.
ev.xexpose.x
x
, ev.xexpose.
ev.xexpose.y
y
);
if (ev.xexpose.count == 0) // last Expose of the batch needsRedraw = true; 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; if (!sawFirstPixel) { sawFirstPixel = true; const
_error_ sh
sh
= cast(const XShmCompletionEvent*)&ev;
emitf("first_pixel_presented", "method=XShmCompletionEvent drawable=0x%lx", sh.drawable); } } break; } } // Auto-exit drive: animate continuously and feed the resize storm. if (
(local variable) const(bool) autoExit
autoExit
&&
(local variable) bool sawFirstPixel
sawFirstPixel
&& !
(local variable) bool awaitingCompletion
awaitingCompletion
)
{ if (
(local variable) int resizesIssued
resizesIssued
<
(immutable global) immutable(int[2][10]) app.main.storm
storm
.
(constant) ulong immutable(int[2][10]).length = 10LU
length
&&
(local variable) int frames
frames
>= (
(local variable) int resizesIssued
resizesIssued
+ 1) * 10)
{ const
(local variable) immutable(int[2]) s
s
=
(immutable global) immutable(int[2][10]) app.main.storm
storm
[
(local variable) int resizesIssued
resizesIssued
];
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 n=%d size=%dx%d",
(local variable) int resizesIssued
resizesIssued
+ 1,
(local variable) immutable(int[2]) s
s
[0],
(local variable) immutable(int[2]) s
s
[1]);
++
(local variable) int resizesIssued
resizesIssued
;
} ++
(local variable) int phase
phase
;
(local variable) bool needsRedraw
needsRedraw
= true;
} // Present a frame. With MIT-SHM the segment must not be rewritten // until the server is done reading it, so we request a completion // event (send_event=True) and gate the next draw on it. if (
(local variable) bool needsRedraw
needsRedraw
&& !
(local variable) bool awaitingCompletion
awaitingCompletion
&& buf.
(field) _error_ buf.ximg
ximg
!is null)
{ drawGradient(buf.
buf.ximg
ximg
, phase);
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); // push the put before sleeping in poll()
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); // no completion contract: round-trip instead
undefined identifier `XSync`
if (!
(local variable) bool sawFirstPixel
sawFirstPixel
)
{
(local variable) bool sawFirstPixel
sawFirstPixel
= true;
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("first_pixel_presented method=XPutImage_XSync");
} } ++
(local variable) int frames
frames
;
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

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

emitf
("frame_callback", "t=%lld frame=%d size=%dx%d",
long instrument.nowUs() nothrow @nogc

Microseconds elapsed since initInstrument.

nowUs
(),
(local variable) int frames
frames
, buf.
(field) _error_ buf.width
width
, buf.
(field) _error_ buf.height
height
);
(local variable) bool needsRedraw
needsRedraw
= false;
} if (
(local variable) const(bool) autoExit
autoExit
&& (
(local variable) int frames
frames
>= 120 ||
long instrument.nowUs() nothrow @nogc

Microseconds elapsed since initInstrument.

nowUs
() > 2_000_000))
{
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

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

emitf
("auto_exit", "frames=%d resizes=%d",
(local variable) int frames
frames
,
(local variable) int resizesIssued
resizesIssued
);
break; } // Readiness wait on the X connection fd — the loop a real app would // multiplex with its own timers/sockets. Auto mode ticks at ~5 ms so // animation frames keep flowing even when the queue is silent. pollfd
(local variable) _error_ pfd
pfd
;
undefined identifier `pollfd`
pfd.
pfd.fd
fd
= fd;
pfd.events = POLLIN; pfd.revents = 0; poll(&pfd, 1, autoExit ? 5 : -1);
undefined identifier `poll`
}
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("teardown");
return 0; }