Skip to main content

Extensions

Most interesting X functionality lives in protocol extensions. node-x11 loads them at runtime with X.require(name, callback). The callback receives an extension object carrying the extension's requests, enums and version info; any extension events are registered on the client automatically:

X.require('randr', (err, Randr) => {
if (err) throw err; // extension missing on this server
Randr.GetScreenResources(display.screen[0].root, (err, res) => {
console.log(res.outputs);
});
});

name is the module name below (the file in lib/ext/), not the on-the-wire extension name. Requiring an extension twice returns the cached instance.

An absent extension gives you an err rather than throwing, so the callback is also where you put your fallback. This demo requires RENDER and uses it to do something the core protocol cannot — blend two translucent rectangles:

Loading live demo…
The in-page X server implements three of these

The live demos on this site run against the pure-JavaScript X server in lib/xserver, which registers BIG-REQUESTS, XC-MISC and RENDER (plus GLX in the browser build, backed by WebGL). X.require('randr') and friends will report the extension as missing here — the client supports all of them, but you need a real server to talk to.

Available extensions

moduleX namewhat it does
apple-wmApple-WMXQuartz window-manager integration
big-requestsBIG-REQUESTSrequests larger than 256 KiB (enabled automatically at connect)
compositeCompositeredirect window rendering off-screen
damageDAMAGEbe notified when drawables change
dbeDOUBLE-BUFFERflicker-free double buffering
dpmsDPMSmonitor power management
fixesXFIXESregions, cursor names, selection tracking
geGeneric Event Extensionframing for extensions with large events
glxGLXOpenGL rendering over the X protocol
presentPresentvsynced pixmap presentation
randrRANDRoutputs, CRTCs, modes, rotation
recordRECORDrecord/replay of the protocol stream
renderRENDERanti-aliased compositing, gradients, glyphs
resX-Resourceper-client server resource usage
screen-saverMIT-SCREEN-SAVERscreen-saver control and notification
shapeSHAPEnon-rectangular windows
shmMIT-SHMshared-memory images
syncSYNCcounters, alarms, fences
xc-miscXC-MISCXID range recycling
xineramaXINERAMAmulti-head screen layout
xinputXInputExtensioninput devices beyond core pointer/keyboard
xkbXKEYBOARDkeyboard maps, controls, indicators
xtestXTESTsynthesize input events for testing
xvXVideovideo output adaptors

Each extension has its own reference page with every request, event and enum — see the Extensions section of the API reference.