app.dhover×206 error×60all
// X11 F08 demo — DPI / runtime rescale (../../../features/f08-dpi-scaling.md).
// Built on the scaffold (../scaffold/app.d): same ImportC binding style, same
// poll(2)-driven readiness loop, same instrument.d event log (plain XPutImage
// presentation — MIT-SHM is irrelevant to this row).
//
// X11's answer to "what happens when the scale changes under a live window"
// is THE deliverable: there is no runtime mechanism. The demo proves it by
// measurement rather than assertion:
//
//   * At startup it snapshots everything a toolkit can know: `Xft.dpi` from
//     the RESOURCE_MANAGER root property (XResourceManagerString +
//     XrmGetResource), the core screen's pixel + millimeter size (=> computed
//     DPI), and per-output RandR physical/pixel sizes (=> per-monitor DPI).
//   * It then keeps running while the run.sh driver changes everything that
//     is changeable (`xrdb -merge` a new Xft.dpi, `xrandr --dpi`), and logs
//     (a) every event delivered to its own window — expecting NONE related to
//     the change — and (b) the root-window PropertyNotify on RESOURCE_MANAGER
//     it gets ONLY because it explicitly selected PropertyChangeMask on the
//     root: the live channel some toolkits use, a convention, not a protocol.
//   * On that PropertyNotify it re-reads the property two ways:
//     XResourceManagerString (Xlib's snapshot, cached at connect time — stays
//     STALE) and XGetWindowProperty (fresh) — the trap is part of the proof.
//   * RandR change events (RRScreenChangeNotify) are selected too, so if the
//     server CAN signal a geometry/physical-size change, it is captured.
//
// Rendering: gradient + a crisp 1-px black hairline at the window edge and a
// horizontal bar sized `dpi` pixels (F08 requirement 1: scaling artifacts
// must be visible). WSI_AUTO_EXIT=1 bounds the run (WSI_DURATION_MS, default
// 10 s). Headless-safe: no X server -> prints `SKIP:` and exits 0.
// Findings: ../../f08-dpi-scaling.md.
module 
(module) app
app
;
import
(module) c
c
; // ImportC: Xlib + Xutil + Xatom + Xresource + Xrandr + poll
C preprocess command `cpp` failed for file `/home/runner/work/sparkles/sparkles/docs/research/window-system-integration/os-apis/x11/examples/f08-dpi-scaling/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
,
(alias) app.snprintf = int core.stdc.stdio.snprintf(scope char* s, ulong n, scope const(char*) format, scope const ...) nothrow @nogc
snprintf
;
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.atoi = int core.stdc.stdlib.atoi(scope const(char*) nptr) nothrow @nogc
atoi
,
(alias) app.free = void core.stdc.stdlib.free(void* ptr) nothrow @nogc
free
,
(alias) app.getenv = char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
,
(alias) app.malloc = void* core.stdc.stdlib.malloc(ulong size) nothrow @nogc
malloc
;
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.string

D header file for C99.

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

Source

core/stdc/string.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)
string
:
(alias) app.strstr = inout(char)* core.stdc.string.strstr(return scope inout(char)* s1, scope const(char*) s2) pure nothrow @nogc
strstr
;
// --------------------------------------------------------------------------- // Constants Xlib/Xatom/Xrandr expose as macros that ImportC cannot import; // re-declared per the scaffold gotcha. 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 value) app.PropertyChangeMask = 4194304L
PropertyChangeMask
= 1L << 22,
} 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.ConfigureNotify = 22
ConfigureNotify
= 22,
(enum value) app.PropertyNotify = 28
PropertyNotify
= 28,
(enum value) app.ClientMessage = 33
ClientMessage
= 33,
} 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.ZPixmap = 2
ZPixmap
= 2;
enum
(constant) int app.AnyPropertyType = 0
AnyPropertyType
= 0;
enum Atom
(constant) _error_ app.XA_RESOURCE_MANAGER = __error
XA_RESOURCE_MANAGER
= 23; // Xatom.h cast-expression macro
undefined identifier `Atom`
enum Atom
(constant) _error_ app.XA_STRING = __error
XA_STRING
= 31;
undefined identifier `Atom`
enum // Xrandr.h {
(enum value) app.RRScreenChangeNotify = 0
RRScreenChangeNotify
= 0, // event offset from the extension's event base
(enum value) app.RRScreenChangeNotifyMask = 1L << 0
RRScreenChangeNotifyMask
= 1L << 0,
(enum value) app.RRCrtcChangeNotifyMask = 1L << 1
RRCrtcChangeNotifyMask
= 1L << 1,
(enum value) app.RROutputChangeNotifyMask = 1L << 2
RROutputChangeNotifyMask
= 1L << 2,
(enum value) app.RR_Connected = 0
RR_Connected
= 0,
} // --------------------------------------------------------------------------- // Reading Xft.dpi out of a resource string ("Xft.dpi:\t144\n..."). /// Parse `Xft.dpi` from a RESOURCE_MANAGER-style resource string via the Xrm /// machinery (XrmGetStringDatabase + XrmGetResource — the same lookup /// toolkits do). Returns the value or -1 when the resource is absent. /// `who` labels the source in the log (startup / stale / fresh). double
double app.readXftDpi(const(char)* resStr, const(char)* who) nothrow @nogc

Parse Xft.dpi from a RESOURCE_MANAGER-style resource string via the Xrm machinery (XrmGetStringDatabase + XrmGetResource — the same lookup toolkits do). Returns the value or -1 when the resource is absent. who labels the source in the log (startup / stale / fresh).

readXftDpi
(const(char)*
(parameter) const(char)* resStr
resStr
, const(char)*
(parameter) const(char)* who
who
) @nogc nothrow
{ if (
(parameter) const(char)* resStr
resStr
is 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
("xft_dpi", "source=%s present=0 (no RESOURCE_MANAGER property)",
(parameter) const(char)* who
who
);
return -1; } XrmDatabase
(local variable) _error_ db
db
= XrmGetStringDatabase(resStr);
undefined identifier `XrmDatabase`
undefined identifier `XrmGetStringDatabase`
char*
(local variable) char* type
type
;
XrmValue
(local variable) _error_ val
val
;
undefined identifier `XrmValue`
double
(local variable) double dpi
dpi
= -1;
if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &val) && val.addr !is null)
undefined identifier `XrmGetResource`
{ 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) strtod = double core.stdc.stdlib.strtod(scope inout(char)* nptr, scope inout(char)** endptr) nothrow @nogc
strtod
;
(local variable) double dpi
dpi
=
double core.stdc.stdlib.strtod(scope inout(char)* nptr, scope inout(char)** endptr) nothrow @nogc
strtod
(cast(const char*) val.addr, 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
("xft_dpi", "source=%s present=1 value=%s scale_vs_96=%.2f",
(parameter) const(char)* who
who
, cast(const char*) val.addr,
(local variable) double dpi
dpi
/ 96.0);
} else
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

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

emitf
("xft_dpi", "source=%s present=0 (property exists, no Xft.dpi key)",
(parameter) const(char)* who
who
);
XrmDestroyDatabase(db);
undefined identifier `XrmDestroyDatabase`
return
(local variable) double dpi
dpi
;
} /// Fetch the RESOURCE_MANAGER property *fresh* off the root window. /// XResourceManagerString does NOT do this — it returns the value Xlib /// snapshotted inside XOpenDisplay; this is the live read. char*
app.fetchResourceManager

Fetch the RESOURCE_MANAGER property fresh off the root window. XResourceManagerString does NOT do this — it returns the value Xlib snapshotted inside XOpenDisplay; this is the live read.

fetchResourceManager
(Display*
(parameter) Display* dpy
dpy
, Window
(parameter) Window root
root
) @nogc nothrow
undefined identifier `Display`
undefined identifier `Window`
{ Atom
_error_ actualType
actualType
;
int
_error_ actualFormat
actualFormat
;
c_ulong
_error_ nitems
nitems
,
_error_ bytesAfter
bytesAfter
;
ubyte*
_error_ prop
prop
;
const
_error_ r
r
= XGetWindowProperty(dpy, root, XA_RESOURCE_MANAGER, 0, 1 << 20,
False, XA_STRING, &actualType, &actualFormat, &nitems, &bytesAfter, &prop); if (r != 0 /*Success*/ || prop is null) return null; return cast(char*) prop; // NUL-terminated by Xlib; caller XFree()s } /// Log the core screen + every RandR output's pixel/physical size and the /// DPI each implies. This is the complete startup snapshot a toolkit gets. void
app.logDpiSnapshot

Log the core screen + every RandR output's pixel/physical size and the DPI each implies. This is the complete startup snapshot a toolkit gets.

logDpiSnapshot
(Display*
(parameter) Display* dpy
dpy
, int
(parameter) int screen
screen
, Window
(parameter) Window root
root
, bool
(parameter) bool haveRandr
haveRandr
) @nogc nothrow
undefined identifier `Display`
undefined identifier `Window`
{ // Core protocol: one screen-wide size in pixels and millimeters, fixed at // connection setup (Xlib caches it; DisplayWidthMM is the function form // XDisplayWidthMM since the macro is not ImportC-able). const
_error_ px
px
= XDisplayWidth(dpy, screen),
_error_ py
py
= XDisplayHeight(dpy, screen);
const
_error_ mmx
mmx
= XDisplayWidthMM(dpy, screen),
_error_ mmy
mmy
= XDisplayHeightMM(dpy, screen);
emitf("core_screen", "px=%dx%d mm=%dx%d dpi=%.1fx%.1f", px, py, mmx, mmy, mmx > 0 ? px * 25.4 / mmx : -1.0, mmy > 0 ? py * 25.4 / mmy : -1.0); if (!haveRandr) return; XRRScreenResources*
_error_ res
res
= XRRGetScreenResourcesCurrent(dpy, root);
if (res is null) return; foreach (
(parameter) i
i
; 0 .. res.noutput)
{ XRROutputInfo*
_error_ oi
oi
= XRRGetOutputInfo(dpy, res, res.outputs[i]);
if (oi is null) continue; int
_error_ cw
cw
= 0,
_error_ ch
ch
= 0;
if (oi.crtc != 0) { XRRCrtcInfo*
_error_ ci
ci
= XRRGetCrtcInfo(dpy, res, oi.crtc);
if (ci !is null) { cw = ci.
ci.width
width
;
ch = ci.
ci.height
height
;
XRRFreeCrtcInfo(ci); } } emitf("randr_output", "name=%s connected=%d px=%dx%d mm=%lux%lu dpi=%.1fx%.1f", oi.
oi.name
name
, cast(int)(oi.connection == RR_Connected), cw, ch,
oi.mm_width, oi.mm_height, oi.mm_width > 0 ? cw * 25.4 / oi.mm_width : -1.0, oi.mm_height > 0 ? ch * 25.4 / oi.mm_height : -1.0); XRRFreeOutputInfo(oi); } XRRFreeScreenResources(res); } // --------------------------------------------------------------------------- // Rendering: gradient, 1-px hairline border, and a dpi-length bar. void
app.draw
draw
(XImage*
(parameter) XImage* img
img
, double
(parameter) double xftDpi
xftDpi
) @nogc nothrow
undefined identifier `XImage`
{ const
_error_ w
w
= img.
img.width
width
,
_error_ h
h
= img.
img.height
height
;
if (img.bits_per_pixel != 32) return; foreach (
(parameter) y
y
; 0 .. h)
{ auto
_error_ row
row
= cast(uint*)(img.data + y * img.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);
uint
_error_ pixel
pixel
= (r << 16) | (g << 8) | 0xc0;
// 1-physical-px black hairline at the very edge (F08 req 1): // under any kind of scaling/stretching it stops being 1 px. if (x == 0 || y == 0 || x == w - 1 || y == h - 1) pixel = 0; // The dpi bar: a white bar `xftDpi` pixels long (96 -> short, // 144 -> visibly longer) so a live Xft.dpi change WOULD be // visible — it never is, because no event triggers a redraw. if (y >= 10 && y < 26 && x >= 8 && x < 8 + cast(int)(xftDpi > 0 ? xftDpi : 0)) pixel = 0xffffff; row[x] = pixel; } } } 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
("f08_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';
const
(local variable) const(char*) envDur
envDur
=
char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
("WSI_DURATION_MS");
const
(local variable) const(int) durationMs
durationMs
=
(local variable) const(char*) envDur
envDur
!is null ?
int core.stdc.stdlib.atoi(scope const(char*) nptr) nothrow @nogc
atoi
(
(local variable) const(char*) envDur
envDur
) : 10_000;
XrmInitialize();
undefined identifier `XrmInitialize`
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`
Window
(local variable) _error_ root
root
= XRootWindow(dpy, screen);
undefined identifier `Window`
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`
// -- RandR availability ---------------------------------------------------- int
(local variable) int rrEventBase
rrEventBase
= -1,
(local variable) int rrErrorBase
rrErrorBase
= -1,
(local variable) int rrMajor
rrMajor
= 0,
(local variable) int rrMinor
rrMinor
= 0;
const
(local variable) const(_error_) haveRandr
haveRandr
= XRRQueryExtension(dpy, &rrEventBase, &rrErrorBase) != 0;
undefined identifier `XRRQueryExtension`
if (haveRandr) XRRQueryVersion(dpy, &rrMajor, &rrMinor);
undefined identifier `XRRQueryVersion`
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=XRRQueryExtension available=%d version=%d.%d event_base=%d",
cast(int) haveRandr,
(local variable) int rrMajor
rrMajor
,
(local variable) int rrMinor
rrMinor
,
(local variable) int rrEventBase
rrEventBase
);
// -- The startup snapshot: everything a toolkit can ever know ------------- const(char)*
(local variable) const(char)* rmSnapshot
rmSnapshot
= XResourceManagerString(dpy); // cached at connect
undefined identifier `XResourceManagerString`
double
(local variable) double xftDpi
xftDpi
=
double app.readXftDpi(const(char)* resStr, const(char)* who) nothrow @nogc

Parse Xft.dpi from a RESOURCE_MANAGER-style resource string via the Xrm machinery (XrmGetStringDatabase + XrmGetResource — the same lookup toolkits do). Returns the value or -1 when the resource is absent. who labels the source in the log (startup / stale / fresh).

readXftDpi
(
(local variable) const(char)* rmSnapshot
rmSnapshot
, "startup_XResourceManagerString");
logDpiSnapshot(dpy, screen, root, haveRandr); // -- Subscribe to the only live channels that exist ------------------------ // (a) PropertyNotify on the ROOT window: RESOURCE_MANAGER is a root // property, so a client that explicitly selects PropertyChangeMask on // the root sees `xrdb -merge` happen. No standard says it must look. XSelectInput(dpy, root, PropertyChangeMask);
undefined identifier `XSelectInput`
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("step name=XSelectInput window=root mask=PropertyChangeMask");
// (b) RandR change events (screen size / output / crtc changes). if (haveRandr) { XRRSelectInput(dpy, root, RRScreenChangeNotifyMask
undefined identifier `XRRSelectInput`
| RRCrtcChangeNotifyMask | RROutputChangeNotifyMask);
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("step name=XRRSelectInput mask=screen_change|crtc|output");
} // -- Window + backbuffer (plain XPutImage; SHM is noise here) ------------- 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)); XStoreName(dpy, win, "Sparkles · X11 F08 dpi");
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`
| PropertyChangeMask); // PropertyChangeMask on the WINDOW too — to // prove nothing DPI-ish ever arrives there either. 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 scale=assumed_1", 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`
XImage*
(local variable) _error_ img
img
= XCreateImage(dpy, visual, cast(uint) depth, ZPixmap, 0,
undefined identifier `XImage`
undefined identifier `XCreateImage`
cast(char*) malloc(cast(size_t) width * height * 4), cast(uint) width, cast(uint) height, 32, 0); 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 snapshotDone
snapshotDone
= false;
int
(local variable) int windowEventsAfterStartup
windowEventsAfterStartup
= 0,
(local variable) int rootPropertyNotifies
rootPropertyNotifies
= 0,
(local variable) int randrNotifies
randrNotifies
= 0;
while (
(local variable) bool running
running
)
{ while (XPending(dpy) > 0)
undefined identifier `XPending`
{ XEvent
(local variable) _error_ ev
ev
;
undefined identifier `XEvent`
XNextEvent(dpy, &ev);
undefined identifier `XNextEvent`
// RandR's RRScreenChangeNotify arrives at a dynamic type code. if (haveRandr && ev.
(field) _error_ ev.type
type
==
(local variable) int rrEventBase
rrEventBase
+
(enum value) app.RRScreenChangeNotify = 0
RRScreenChangeNotify
)
{ ++
(local variable) int randrNotifies
randrNotifies
;
auto
(local variable) _error_ rr
rr
= cast(XRRScreenChangeNotifyEvent*)&ev;
undefined identifier `XRRScreenChangeNotifyEvent`
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

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

emitf
("randr_screen_change", "px=%dx%d mm=%dx%d dpi=%.1fx%.1f",
rr.
(field) _error_ rr.width
width
, rr.
(field) _error_ rr.height
height
, rr.mwidth, rr.mheight,
rr.mwidth > 0 ? rr.
(field) _error_ rr.width
width
* 25.4 / rr.mwidth : -1.0,
rr.mheight > 0 ? rr.
(field) _error_ rr.height
height
* 25.4 / rr.mheight : -1.0);
// Refresh Xlib's cached core-screen values (they are a connect- // time snapshot too) and log what the core API now reports. XRRUpdateConfiguration(&ev);
undefined identifier `XRRUpdateConfiguration`
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

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

emitf
("core_screen_after_update", "px=%dx%d mm=%dx%d",
XDisplayWidth(dpy, screen), XDisplayHeight(dpy, screen),
undefined identifier `XDisplayWidth`
undefined identifier `XDisplayHeight`
XDisplayWidthMM(dpy, screen), XDisplayHeightMM(dpy, screen));
undefined identifier `XDisplayWidthMM`
undefined identifier `XDisplayHeightMM`
continue; } // Root-window events: the RESOURCE_MANAGER live channel. if (ev.xany.window == root && ev.
(field) _error_ ev.type
type
==
(enum value) app.PropertyNotify = 28
PropertyNotify
)
{ ++
(local variable) int rootPropertyNotifies
rootPropertyNotifies
;
char*
(local variable) char* name
name
= XGetAtomName(dpy, ev.xproperty.atom);
undefined identifier `XGetAtomName`
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

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

emitf
("root_property_notify", "atom=%s state=%s",
(local variable) char* name
name
,
ev.xproperty.state == 0 ? "NewValue".ptr : "Deleted".ptr); XFree(name);
undefined identifier `XFree`, did you mean alias `free`?
if (ev.xproperty.atom == XA_RESOURCE_MANAGER) { // The trap: Xlib's own accessor still returns the value // cached at XOpenDisplay time ...
double app.readXftDpi(const(char)* resStr, const(char)* who) nothrow @nogc

Parse Xft.dpi from a RESOURCE_MANAGER-style resource string via the Xrm machinery (XrmGetStringDatabase + XrmGetResource — the same lookup toolkits do). Returns the value or -1 when the resource is absent. who labels the source in the log (startup / stale / fresh).

readXftDpi
(XResourceManagerString(dpy),
undefined identifier `XResourceManagerString`
"stale_XResourceManagerString"); // ... a fresh XGetWindowProperty sees the new one. char*
(local variable) char* fresh
fresh
= fetchResourceManager(dpy, root);
(local variable) double xftDpi
xftDpi
=
double app.readXftDpi(const(char)* resStr, const(char)* who) nothrow @nogc

Parse Xft.dpi from a RESOURCE_MANAGER-style resource string via the Xrm machinery (XrmGetStringDatabase + XrmGetResource — the same lookup toolkits do). Returns the value or -1 when the resource is absent. who labels the source in the log (startup / stale / fresh).

readXftDpi
(
(local variable) char* fresh
fresh
, "fresh_XGetWindowProperty");
if (
(local variable) char* fresh
fresh
!is null)
XFree(fresh);
undefined identifier `XFree`, did you mean alias `free`?
(local variable) bool needsRedraw
needsRedraw
= true; // ONLY because we chose to watch root
} continue; } // Everything else is addressed to our window. After startup // settles, each one is logged — the absence of any DPI-related // event here is the finding. if (ev.xany.window == win &&
(local variable) bool snapshotDone
snapshotDone
)
{ ++
(local variable) int windowEventsAfterStartup
windowEventsAfterStartup
;
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_event", "type=%d", ev.
(field) _error_ ev.type
type
);
} switch (ev.
(field) _error_ ev.type
type
)
{ case Expose: if (ev.xexpose.count == 0) needsRedraw = true; break; case ConfigureNotify: if (ev.xconfigure.
ev.xconfigure.width
width
!= width || ev.xconfigure.
ev.xconfigure.height
height
!= height)
{ width = ev.xconfigure.
ev.xconfigure.width
width
;
height = ev.xconfigure.
ev.xconfigure.height
height
;
emitf("resize", "size=%dx%d scale=still_assumed_1", width, height); img.f.destroy_image(img); // XDestroyImage macro's body img = XCreateImage(dpy, visual, cast(uint) depth, ZPixmap, 0, cast(char*) malloc(cast(size_t) width * height * 4), cast(uint) width, cast(uint) height, 32, 0); needsRedraw = true; } break; case MapNotify: snapshotDone = true; emit("startup_snapshot_complete (window events are counted from here)"); break; case ClientMessage: if (cast(Atom) ev.xclient.data.l[0] == wmDelete) { emit("close_requested via=WM_DELETE_WINDOW"); running = false; } break; case KeyPress: running = false; break; default: break; } } if (
(local variable) bool needsRedraw
needsRedraw
&& img !is null)
{ draw(img, xftDpi); XPutImage(dpy, win, gc, img, 0, 0, 0, 0,
undefined identifier `XPutImage`
cast(uint) width, cast(uint) height); XFlush(dpy); // push the put before sleeping in poll()
undefined identifier `XFlush`
(local variable) bool needsRedraw
needsRedraw
= false;
} if (
(local variable) const(bool) autoExit
autoExit
&&
long instrument.nowUs() nothrow @nogc

Microseconds elapsed since initInstrument.

nowUs
() > cast(long)
(local variable) const(int) durationMs
durationMs
* 1000)
{
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("auto_exit");
break; } pollfd
(local variable) _error_ pfd
pfd
;
undefined identifier `pollfd`
pfd.
pfd.fd
fd
= fd;
pfd.events = POLLIN; pfd.revents = 0; poll(&pfd, 1, autoExit ? 100 : -1);
undefined identifier `poll`
}
void instrument.emitf(scope const(char)* kind, scope const(char)* fmt, ...) nothrow @nogc

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

emitf
("summary", "root_property_notifies=%d randr_notifies=%d "
~ "window_events_after_startup=%d final_xft_dpi=%.1f",
(local variable) int rootPropertyNotifies
rootPropertyNotifies
,
(local variable) int randrNotifies
randrNotifies
,
(local variable) int windowEventsAfterStartup
windowEventsAfterStartup
,
(local variable) double xftDpi
xftDpi
);
img.f.destroy_image(img); XDestroyWindow(dpy, win);
undefined identifier `XDestroyWindow`
XCloseDisplay(dpy);
undefined identifier `XCloseDisplay`
void instrument.emit(scope const(char)* kind) nothrow @nogc

Emit an event with no key=value payload.

emit
("teardown");
return 0; }