A CLIPS X11 library
This library can be installed manually via git and make
or by
CLIPSenv.
To install manually, git clone this repo and run make.
This will:
- Download the CLIPS 6.4.2 source code
- Untar it to the
vendor/clipsdir - Copy the
userfunctions.cfile into thevendor/clipsdir - Run
makein thevendor/clipsdir
Now you have an executable vendor/clips/clips file that has X11-related
functions available in it.
To take this a step further, you can install the executable
CLIPSX11 system-wide by running sudo make install.
Check out CLIPS1wm, a minimal X11 window manager implemented using CLIPSX11.
All example programs and tests are in the tests directory.
There are two files program.clp program2.clp
showcasing some of the other functions provided by this library.
There are a few test .bat files that you may run to see the basic library in action:
CLIPSX11 -f2 ./error_handling.bat
CLIPSX11 -f2 ./x_send_event_test.bat
- Display Management
- Window Creation & Management
- Cursor, Font & Color
- Graphics Context & Drawing
- Event Handling
- Keyboard Utilities
- Screen Conversion
- Utility
- Error Handling
(x-open-display [<display-name>]) → <DISPLAY-ADDRESS> | FALSEConnects to the X server.
display-name(SYMBOL, optional) - hostname and display number (e.g."localhost:0"). If omitted, usesDISPLAYenv var.
- External address wrapping
Display*on success. FALSEif connection fails (prints error to STDERR).
(bind ?d (x-open-display ":0"))(x-close-display <display pointer>) → <VOID>Closes previously opened display.
(default-screen <display>) → <screen-number>Retrieves the default screen index for a display.
display(EXTERNAL-ADDRESS) - aDisplay*returned byx-open-display.
- Integer index of the default screen.
(default-screen-of-display <display>) → <screen-address>Returns the Screen* pointer for the default screen.
display(EXTERNAL-ADDRESS)
- External address wrapping
Screen*.
(default-root-window <display>) → <window-id>Fetches the root window ID of the default screen.
display(EXTERNAL-ADDRESS)
- Window ID (INTEGER).
(root-window <display> <screen>) → <window-id>Fetches the root window ID for a specified screen index.
display(EXTERNAL-ADDRESS)screen(INTEGER)
- Window ID (INTEGER).
(x-create-simple-window <display> <parent> <x> <y> <width> <height> <border-width> <border> <background>) → <window-id>Creates a basic window.
display(EXTERNAL-ADDRESS) -Display*parent(INTEGER) - parent window IDx,y(INTEGER) - positionwidth,height(INTEGER) - dimensionsborder-width(INTEGER)border,background(INTEGER) - pixel values
- New window ID (INTEGER).
(bind ?w (x-create-simple-window ?d ?parent 10 10 400 300 1 0 65535))(x-create-window <display> <parent> <x> <y> <width> <height> <border-width> <depth> <class> <visual> <valuemask> <attributes>) → <window-id>Creates a window with full attribute control.
- Same as
XCreateWindow: includesdepth,class,visual(EXTERNAL-ADDRESS),valuemask, and pointer toXSetWindowAttributes.
- New window ID (INTEGER).
(x-destroy-window <display> <window>)Destroys a window. Immediately unmaps it. Does nothing if is Root window.
display(EXTERNAL-ADDRESS)screen(INTEGER)
(x-map-window <display> <window>) → VOIDMaps (shows) a window.
display(EXTERNAL-ADDRESS)window(INTEGER)
(x-unmap-window <display> <window>) → VOIDUnmaps (hides) a window.
display(EXTERNAL-ADDRESS)window(INTEGER)
(x-reparent-window <display> <window> <parent> <x> <y>) → VOIDReparents a window and positions it within the new parent at the x, y coordinates.
display(EXTERNAL-ADDRESS)window(INTEGER)parent(INTEGER)x(INTEGER)y(INTEGER)
(x-move-resize-window <display> <window> <x> <y> <width> <height>) → <status>Moves and resizes a window in one call.
<display>- External address to an X11 Display object. Represents the connection to the X server.<window>- Integer handle identifying the window to move/resize.<x>- Integer specifying the new X coordinate (position) of the window’s origin relative to its parent.<y>- Integer specifying the new Y coordinate of the window’s origin relative to its parent.<width>- Integer giving the new width of the window in pixels.<height>- Integer giving the new height of the window in pixels.
- Status code (INTEGER, non-zero on success).
(x-circulate-subwindows-up <display> <window>) → <status>Raises all child windows of window.
<display>- External address to an X11Displayobject.<window>- Integer representing the X11Windowto bring to the top.
(x-circulate-subwindows-down <display> <window>) → <status>Lowers all child windows of window.
<display>- External address to an X11Displayobject.<window>- Integer representing the X11Windowto bring to the bottom.
(x-raise-window <display> <window>) → <void>Raises window to the top of its siblings.
<display>- External address to an X11Displayobject.<window>- Integer representing the X11Windowto bring to the top.
(x-lower-window <display> <window>) → <void>Lowers window to the bottom of its siblings.
<display>- External address to an X11Displayobject.<window>- Integer representing the X11Windowto lower to the bottom.
clips (x-kill-client <display> <resource>) → <status>
Forces the X server to close a client identified by resource (window or pixmap).
(remove-hints-flags-from-window <display> <window> [<hint-symbol> ...])
void
Clears (removes) one or more size/position-related hint flags from the WM_NORMAL_HINTS property of a given X11 window. These hints influence how window managers position, size, and interpret the window; removing flags allows the application or window manager to ignore previously set constraints.
<display>- External address to an X11Displayobject.<window>- Integer representing the X11Windowwhose hints are to be modified.- Zero or more of the following hint symbols indicating which bits to remove from the current
XSizeHints.flags:USPosition- User-specified position.USSize- User-specified size.PPosition- Program-specified position.PSize- Program-specified size.PMinSize- Program-specified minimum size.PMaxSize- Program-specified maximum size.PResizeInc- Resize increment.PAspect- Aspect ratio.PBaseSize- Base size.PWinGravity- Window gravity.
(remove-hints-flags-from-window ?display ?window USPosition PSize)(set-window-gravity <display> <window> <gravity-symbol>)
void (v)
Sets the window gravity in the WM_NORMAL_HINTS property for a given X11 window. Window gravity controls how the window's position is interpreted when its size or parent changes—for example, whether the origin stays fixed or is adjusted relative to a particular corner or edge.
- - External address to an X11 Display object.
- - Integer representing the X11 Window whose gravity is to be set.
- - One of the supported gravity symbols:
- ForgetGravity
- NorthWestGravity
- NorthGravity
- NorthEastGravity
- WestGravity
- CenterGravity
- EastGravity
- SouthWestGravity
- SouthGravity
- SouthEastGravity
- StaticGravity
(set-window-gravity ?display ?window CenterGravity)
(x-list-properties <display> <window>)
<display>: External address toDisplay *.<window>: Integer window ID.
A multifield of symbols: each is the string name of a property currently set on the window. If no properties or on failure, returns an empty multifield.
- Internally calls
XListProperties. - Converts each returned atom to its name via
XGetAtomName. - Returns names as CLIPS symbols.
(x-get-property <display> <window> <name>)
<display>: External address toDisplay *.<window>: Integer window ID.<name>: Name of the property
- MULTIFIELD containing:
- SYMBOL representing the actual type of the value
- INTEGER representing the actual format of the value
- A series of STRINGs or INTEGERs which are the actual values
(x-change-property <display> <window> <property-name> <type-name> <format> <mode> [?data])
<display>: External address of the opened X display (fromx-open-display).<window>: Integer window ID to operate on.<property-name>: Symbol/string naming the property to change (will be interned viaXInternAtom).<type-name>: Symbol/string naming the type of the property (interned similarly).<format>: Integer; one of8,16, or32. Specifies the data format bits per item.<mode>: One of the symbols"Replace","Append", or"Prepend". Determines how the new data is combined with existing property data.?data(optional): The value to set. Accepts:- A single integer (interpreted according to
format). - A string or symbol (automatically coerced to format
8). - A multifield of integers (each mapped according to
format).
- A single integer (interpreted according to
If ?data is omitted, the property is updated with zero elements (effectively clearing it or setting an empty value depending on mode).
(x-change-property ?display ?window "_NET_WM_NAME" "UTF8_STRING" 8 "Replace" "MyWindow")
(x-change-property ?display ?window "_NET_WM_NAME" "UTF8_STRING" 8 Append " - more")
(x-change-property ?display ?window "MY_PROP" "CARDINAL" 32 Prepend (create$ 1 2 3 4))
(x-change-property ?display ?window "MY_PROP" "CARDINAL" 32 "Replace")(x-delete-property <display> <window> <name>)
<display>: External address toDisplay *.<window>: Integer window ID.<name>: Name of the property
(x-get-geometry <display> <window>)
<display>: External address toDisplay *.<window>: Integer window ID.
- A multifield with the following ordered values:
rootWindow ID of the window passedxposition of the Window ID relative toroot's originyposition of the Window ID relative toroot's originwidthof the Window IDheightof the Window IDborder_widthof the Window ID in pixelsdepthof the drawable (bits per pixels of the object)
Returns attributes about the window as either a multifield, a fact, or an instance.
For a multifield, use x-get-window-attributes. The attributes will be returned
in this order:
- x, y - location of window
- width, height - width and height of window
- border_width - border width of window
- depth - depth of window
- visual - the associated visual structure
- root - root of screen containing window
- class - InputOutput, InputOnly
- bit_gravity - one of the bit gravity values
- win_gravity - one of the window gravity values
- backing_store - NotUseful, WhenMapped, Always
- backing_planes - planes to be preserved if possible
- backing_pixel - value to be used when restoring planes
- save_under - boolean, should bits under be saved?
- colormap - color map to be associated with window
- map_installed - boolean, is color map currently installed
- map_state - IsUnmapped, IsUnviewable, IsViewable
- all_event_masks - set of events all people have interest in
- your_event_mask - my event mask
- do_not_propagate_mask - set of events that should not propagate
- override_redirect - boolean value for override-redirect
- screen - back pointer to correct screen
For x-get-window-attributes-to-fact, a fact will be asserted with the above slots.
For x-get-window-attributes-to-instance, an instance will be made with the above slots.
(x-configure-window <display> <window> <value-mask>
<x> <y> <width> <height> <border-width> <sibling> <stack-mode>)
→ <status>Wrapper for XConfigureWindow. Applies geometry/stacking changes to a window.
<display>— EXTERNAL-ADDRESS (XlibDisplay*).<window>— INTEGER (Xlib Window id).<value-mask>— which fields to apply. Accepts:- INTEGER bitmask, or
- single SYMBOL/STRING, or
- MULTIFIELD of SYMBOL/STRING/INTEGER items (all OR’ed together).
Supported tokens:
CWX,CWY,CWWidth,CWHeight,CWBorderWidth,CWSibling,CWStackMode.
<x>— INTEGER<y>— INTEGER<width>— INTEGER<height>— INTEGER<border-width>— INTEGER<sibling>— INTEGER (Xlib Window id; only used if CWSibling is set)<stack-mode>— INTEGER or SYMBOL one of: Above, Below, TopIf, BottomIf, Opposite
(x-query-tree <display> <window>)Returns multifield whose members are:
- root - the root window
- parent - the parent window
- children - a list of windows that are children of the ` argument listed in stacking order (bottom-most first)
(x-fetch-name ?display ?window)
<display>: External address toDisplay *.<window>: Integer window ID.
STRING of the window name
(x-store-name <display> <window> <name>) → VOID
<display>: External address toDisplay *.<window>: Integer window ID.<name>: The new name to set on the window
(x-store-name ?window ?display "My new window!")(x-query-pointer <display>) → MULTIFIELDReturns the x, y coordinates of the cursor.
<display>: External address toDisplay *.
A MULTIFIELD with two values x and y which are the coordinates of the cursor
(x-create-font-cursor <display> <shape-symbol>) → <cursor-id> | FALSECreates a cursor from the X11 font cursor set.
display(EXTERNAL-ADDRESS)shape-symbol- The following symbol strings are recognised and mapped to their respective X cursor shapes:XC_X_cursorXC_arrowXC_based_arrow_downXC_based_arrow_upXC_boatXC_bogosityXC_bottom_left_cornerXC_bottom_right_cornerXC_bottom_sideXC_bottom_teeXC_box_spiralXC_center_ptrXC_circleXC_clockXC_coffee_mugXC_crossXC_cross_reverseXC_crosshairXC_diamond_crossXC_dotXC_dotboxXC_double_arrowXC_draft_largeXC_draft_smallXC_draped_boxXC_exchangeXC_fleurXC_gobblerXC_gumbyXC_hand1XC_hand2XC_heartXC_iconXC_iron_crossXC_left_ptrXC_left_sideXC_left_teeXC_leftbuttonXC_ll_angleXC_lr_angleXC_manXC_middlebuttonXC_mouseXC_pencilXC_pirateXC_plusXC_question_arrowXC_right_ptrXC_right_sideXC_right_teeXC_rightbuttonXC_rtl_logoXC_sailboatXC_sb_down_arrowXC_sb_h_double_arrowXC_sb_left_arrowXC_sb_right_arrowXC_sb_up_arrowXC_sb_v_double_arrowXC_shuttleXC_sizingXC_spiderXC_spraycanXC_starXC_targetXC_tcrossXC_top_left_arrowXC_top_left_cornerXC_top_right_cornerXC_top_sideXC_top_teeXC_trekXC_ul_angleXC_umbrellaXC_ur_angleXC_watchXC_xterm
(x-define-cursor <display> <window> <cursor>) → VOIDAssociates a cursor with a window.
Retrieves the current input focus window and the revert-to setting for the specified display.
<display>: External address to an X11Display(as returned byx-open-display).
A multifield containing two elements:
- The focus window (integer).
- The revert-to policy as a symbol. Possible values:
RevertToParentRevertToPointerRootRevertToNone
(x-set-input-focus <display> <focus> <revert_to> [<time>]) → INTEGERSets the current input focus window and the revert-to setting for the specified display.
<display>: External address to an X11Display(as returned byx-open-display).<focus>: The new window to set focus to<revert_to>: The revert-to policy as a symbol. Possible values:RevertToParentRevertToPointerRootRevertToNone
<time>: Timestamp integer,CurrentTimeif missing (0)
(x-select-input <display> <window> <mask1> <mask2> ... <maskn>)Requests the X Server to report events associated with the supplied event masks.
(x-select-input ?display ?window SubstructureRedirectMask)
(x-warp-pointer <display> <src-window> <dest-window> <src-x> <src-y> <src-width> <src-height> <dest-x> <dest-y>) => <lexeme or integer>Moves the pointer (mouse cursor) to a specified location, either relative to a source window or directly into a destination window. NOTE: Does not necessarily move the visual cursor icon on the screen; check the coordinates with x-query-pointer after x-warp-pointer.
display: External address to the X11 Display.src-window: Source window (integer). The pointer is warped relative to this window’s coordinate system. Use 0 if not constraining to a source region.dest-window: Destination window (integer) where the pointer will be moved. Use 0 to indicate the root or global coordinate space depending on your semantics.src-x/src-y/src-width/src-height: Defines a source rectangle within src-window. If the current pointer position is outside this rectangle, the warp does not occur. To ignore the source restriction, supply zeros appropriately (as per X11 API).dest-x/dest-y: Coordinates within dest-window to which the pointer will be moved.
(black-pixel <display> <screen>) → <pixel>
(white-pixel <display> <screen>) → <pixel>Fetches the black or white pixel value for a screen.
(x-create-gc <display> <drawable> <valuemask>) → <GC-ADDRESS>Creates a graphics context; returns an external address. Uses default XGCValues.
(x-set-foreground <display> <gc> <pixel>) → <status>Sets the foreground color for drawing operations in a GC.
(x-draw-arc <display> <drawable> <gc> <x> <y> <width> <height> <angle1> <angle2>)
(x-draw-line <display> <drawable> <gc> <x1> <y1> <x2> <y2>)
(x-draw-point <display> <drawable> <gc> <x> <y>)
(x-draw-rectangle <display> <drawable> <gc> <x> <y> <width> <height>)
(x-draw-string <display> <drawable> <gc> <x> <y> <text>)Each wraps the corresponding XDraw* call and returns VOID.
(x-pending <display>) → <count>Checks how many events are queued.
(x-peek-event <display>) → <multifield>
(x-next-event <display>) → <multifield>Retrieves (or waits for) the next XEvent, converts it into a CLIPS multifield:
[ <xany> <type-symbol> <typed-detail> ]
A multifield consisting of fields combined from the XAny event as well as the type-specific event.
(x-peek-event-to-fact <display>) → <fact>
(x-next-event-to-fact <display>) → <fact>As above, but asserts an x-event, x-any-event, and a typed fact template.
Check deftemplates.clp to see the structure of these deftemplates.
(x-peek-event-to-instance <display>) → <instance>
(x-next-event-to-instance <display>) → <instance>As above, but asserts an X-EVENT-* typed COOL instance.
Check defclasses.clp to see the structure of these defclasses.
(x-pop-event <display>) → VOIDRemoves the next event without returning it. Useful after an x-peek-event
to remove it from the event queue.
(x-send-event <display> <window> <propagate> <event-mask> <event>) → INTEGERSends the event specified as the last argument to the display/window.
Can be received with x-next-event if the event mask is selected
using x-select-input.
<display>- A c-pointer to the display object to send the event to<window>- A window ID to send the event to<propagate>- A boolean to determine whether or not to propagate the event if not received.<event-mask>- One of:- An integer representing the event mask. Use
lexeme-to-event-maskormultifield-to-event-maskto generate anINTEGERfor this argument. - A symbol or string representing the event mask modifier.
- A multifield of symbols or strings representing values to
|(or) for the event mask modifier
- An integer representing the event mask. Use
<event>- A MULTIFIELD, FACT, or INSTANCE that contains the event details
If using FACT or INSTANCE as <event>, refer to the
deftemplates.clp or defclasses.clp respectively
to determine which slots need to be set. In all casses,
c-pointer, serial, send-event and display slot values
will not be used.
If using a MULTIFIELD, refer to the following to determine
the order in which you must append values to the multifield
for them to be received by the appropriate event types
(all values are INTEGERs unless otherwise noted):
(KeyPress <window> <root> <subwindow> <time> <x> <y> <x_root> <y_root> <state> <keycode> <same_screen>)
(KeyRelease <window> <root> <subwindow> <time> <x> <y> <x_root> <y_root> <state> <keycode> <same_screen>)
(ButtonPress <window> <root> <subwindow> <time> <x> <y> <x_root> <y_root> <state> <keycode> <same_screen>)
(ButtonRelease <window> <root> <subwindow> <time> <x> <y> <x_root> <y_root> <state> <keycode> <same_screen>)
same_screen-TRUEorFALSEstate- anINTEGERfor a mask. Retrievable bylexeme-to-maskormultifield-to-mask
(MotionNotify <window> <root> <subwindow> <time> <x> <y> <x_root> <y_root> <state> <is_hint> <same_screen>)
is_hint-NotifyNormalorNotifyHintsame_screen-TRUEorFALSEstate- anINTEGERfor a mask. Retrievable bylexeme-to-maskormultifield-to-mask
(EnterNotify <window> <root> <subwindow> <time> <x> <y> <x_root> <y_root> <mode> <detal> <same_screen> <focus> <state>)
(LeaveNotify <window> <root> <subwindow> <time> <x> <y> <x_root> <y_root> <mode> <detal> <same_screen> <focus> <state>)
mode-NotifyNormal,NotifyGrab, orNotifyUngrabdetail-NotifyAncestor,NotifyVirtual,NotifyInferior,NotifyNonlinear,NotifyNonlinearVirtual,NotifyPointer,NotifyPointerRoot, orNotifyDetailNonesame_screen-TRUEorFALSEfocus-TRUEorFALSEstate- anINTEGERfor a mask. Retrievable bylexeme-to-maskormultifield-to-mask
(FocusIn <window> <mode> <detail>)
(FocusOut <window> <mode> <detail>)
mode-NotifyNormal,NotifyGrab, orNotifyUngrabdetail-NotifyAncestor,NotifyVirtual,NotifyInferior,NotifyNonlinear,NotifyNonlinearVirtual,NotifyPointer,NotifyPointerRoot, orNotifyDetailNone
(KeymapNotify <display> <window> <bool>...<bool>)
display- C Pointer toDisplay
(Expose <window> <x> <y> <width> <height> <count>)
(GraphicsExpose <drawable> <x> <y> <width> <height> <count> <major_code> <minor_code>)
(NoExpose <drawable> <major_code> <minor_code>)
(VisibilityNotify <window> <state>)
state-VisibilityUnobscured,VisibilityPartiallyObscured, orVisibilityFullyObscured
(CreateNotify <parent> <window> <x> <y> <width> <height> <border_width> <override_redirect>)
override_redirect-TRUEorFALSE
(DestroyNotify <event> <window>)
(UnmapNotify <event> <window> <from_configure>)
from_configure-TRUEorFALSE
(MapNotify <event> <window> <override_redirect>)
override_redirect-TRUEorFALSE
(MapRequest <parent> <window>)
(ReparentNotify <event> <window> <parent> <x> <y> <override_redirect>)
(ConfigureNotify <event> <window> <parent> <x> <y> <width> <height> <border_width> <above> <override_redirect>)
override_redirect-TRUEorFALSE
(ConfigureRequest <parent> <window> <x> <y> <width> <height> <border_width> <above> <detail> <value_mask>)
detail-Above,Below,TopIf,BottomIf,Opposite
(GravityNotify <event> <window> <x> <y>)
(ResizeRequest <window> <width> <height>)
(CirculateNotify <event> <window> <place>)
(CirculateRequest <parent> <window> <place>)
place-PlaceOnToporPlaceOnBottom
(PropertyNotify <window> <atom> <time> <state>)
state-PropertyNewValueorPropertyDelete
(SelectionClear <window> <selection> <time>)
(SelectionRequest <owner> <requestor> <selection> <target> <property> <time>)
(SelectionNotify <requestor> <selection> <target> <property> <time>)
(ColormapNotify <window> <colormap> <new> <state>)
state-ColormapInstalledorColormapUninstalled
(ClientMessage <window> <message_type> <format> <b or s or l integers>...<b or s or l integers>)
format-8,16, or32
(MappingNotify <window> <request> <first_keycode> <count>)
request-MappingModifier,MappingKeyboard, orMappingPointer
(GenericEvent <extension> <evtype>)
(x-lookup-string <event-address>) → [ <string> <keysym> ]Converts a KeyPress event to its text and keysym.
(x-string-to-keysym <symbol>) → <keysym>Maps a key name (e.g. "Return") to its keysym.
(x-keysym-to-keycode <display> <keysym>) → <keycode>(x-grab-server <display>) → VOIDDisables processing of requests and close downs on all other connections than the one this request arrived on
(x-ungrab-server <display>) → VOIDRestarts processing of requests and close downs on other connections.
(x-grab-button <display> <button> <modifiers> <grab_window> <owner-events?> <event_mask> <pointer-mode> <keyboard-mode> <confine_to> <cursor>) → <status>Grabs a specific button (with optional modifier masks) on a given window so that the application receives button events even if another client would normally have focus. This is an X11 passive button grab.
<display>- External address to an X11 Display object.<button>- Integer button to grab.<modifiers>- One of:- An integer representing the mask modifier. Use
lexeme-to-maskormultifield-to-maskto generate anINTEGERfor this argument. - A symbol or string representing the mask modifier.
- A multifield of symbols or strings representing values to
|(or) for the mask modifier
- An integer representing the mask modifier. Use
<grab-window>- Integer representing the X11 window in which the button is to be grabbed.<owner-events?>- Boolean; if TRUE, events are reported as if the grabbing client owned the events (owner_events argument to XGrabButton).<event_mask>- One of:- An integer representing the event mask. Use
lexeme-to-event-maskormultifield-to-event-maskto generate anINTEGERfor this argument. - A symbol or string representing the event mask modifier.
- A multifield of symbols or strings representing values to
|(or) for the event mask modifier
- An integer representing the event mask. Use
<pointer-mode-symbol>- Symbol controlling pointer freezing behavior during the grab. Recognized value:- "GrabModeSync" - pointer is frozen until explicitly released (maps to X11 GrabModeSync)
- anything else (typically "GrabModeAsync") - pointer operates asynchronously (maps to GrabModeAsync)
<keyboard-mode-symbol>- Symbol controlling keyboard freezing behavior during the grab. Same semantics as pointer-mode-symbol.<confine_to>- Window to confine the grab to<cursor>- Specifies the cursor to be displayed
;grabs button t when mod4 (typically windows button) is held down
(x-grab-button ?display (x-buttonsym-to-buttoncode ?display (x-string-to-buttonsym "t")) Mod4Mask ?window TRUE GrabModeAsync GrabModeAsync)))(x-ungrab-button <display> <button> <modifiers> <grab_window>) → VOIDReleases a specific button (with optional modifier masks) on a given window if it was grabbed by this client.
<display>- External address to an X11 Display object.<button>- Integer button to grab.<modifiers>- One of:- An integer representing the mask modifier. Use
lexeme-to-maskormultifield-to-maskto generate anINTEGERfor this argument. - A symbol or string representing the mask modifier.
- A multifield of symbols or strings representing values to
|(or) for the mask modifier
- An integer representing the mask modifier. Use
<grab-window>- Integer representing the X11 window in which the button is to be grabbed.
(x-grab-key <display> <keycode> <modifiers> <window> <owner-events?> <pointer-mode> <keyboard-mode>) → <status>Grabs a specific key (with optional modifier masks) on a given window so that the application receives key events even if another client would normally have focus. This is an X11 passive key grab.
<display>- External address to an X11 Display object.<keycode>- Integer keycode to grab.<modifiers>- One of:- An integer representing the mask modifier. Use
lexeme-to-maskormultifield-to-maskto generate anINTEGERfor this argument. - A symbol or string representing the mask modifier.
- A multifield of symbols or strings representing values to
|(or) for the mask modifier
- An integer representing the mask modifier. Use
<grab-window>- Integer representing the X11 window in which the key is to be grabbed.<owner-events?>- Boolean; if TRUE, events are reported as if the grabbing client owned the events (owner_events argument to XGrabKey).<pointer-mode-symbol>- Symbol controlling pointer freezing behavior during the grab. Recognized value:- "GrabModeSync" - pointer is frozen until explicitly released (maps to X11 GrabModeSync)
- anything else (typically "GrabModeAsync") - pointer operates asynchronously (maps to GrabModeAsync)
<keyboard-mode-symbol>- Symbol controlling keyboard freezing behavior during the grab. Same semantics as pointer-mode-symbol.
;grabs key t when mod4 (typically windows key) is held down
(x-grab-key ?display (x-keysym-to-keycode ?display (x-string-to-keysym "t")) Mod4Mask ?window TRUE GrabModeAsync GrabModeAsync)))(x-ungrab-key <display> <keycode> <modifiers> <grab_window>) → VOIDReleases a specific key (with optional modifier masks) on a given window if it was grabbed by this client.
<display>- External address to an X11 Display object.<keycode>- Integer keycode to grab.<modifiers>- One of:- An integer representing the mask modifier. Use
lexeme-to-maskormultifield-to-maskto generate anINTEGERfor this argument. - A symbol or string representing the mask modifier.
- A multifield of symbols or strings representing values to
|(or) for the mask modifier
- An integer representing the mask modifier. Use
<grab-window>- Integer representing the X11 window in which the key is to be grabbed.
(x-grab-pointer <display> <grab_window> <owner_events?> <event_mask> <pointer-mode> <keyboard-mode> <confine_to> <cursor> [<time>]) → <status>Grabs control of the pointer. Further pointer events are reported only to the grabbing client.
<display>- External address to an X11 Display object.<grab-window>- Integer representing the X11 window in which the pointer is to be grabbed.<owner-events?>- Boolean; if TRUE, events are reported as if the grabbing client owned the events (owner_events argument to XGrabPointer).<event_mask>- One of:- An integer representing the event mask. Use
lexeme-to-event-maskormultifield-to-event-maskto generate anINTEGERfor this argument. - A symbol or string representing the event mask modifier.
- A multifield of symbols or strings representing values to
|(or) for the event mask modifier
- An integer representing the event mask. Use
<pointer-mode-symbol>- Symbol controlling pointer freezing behavior during the grab. Recognized value:- "GrabModeSync" - pointer is frozen until explicitly released (maps to X11 GrabModeSync)
- anything else (typically "GrabModeAsync") - pointer operates asynchronously (maps to GrabModeAsync)
<keyboard-mode-symbol>- Symbol controlling keyboard freezing behavior during the grab. Same semantics as pointer-mode-symbol.<confine_to>- Window to confine the grab to<cursor>- Specifies the cursor to be displayed<time>- Specifies the time of the grab.CurrentTimeif not provided.
(x-ungrab-pointer <display> [<time>]) → VOIDReleases the pointer and any queued events.
<display>- External address to an X11 Display object.<time>- Specifies the time.CurrentTimeif not provided.
(screen-to-fact <screen-address>) → <fact>Builds and asserts a screen fact with slots:
c-pointerext-datadisplayrootwidthheightmwidthmheightndepthsroot-depthwhite-pixelblack-pixelmax-mapsmin-mapsbacking-storesave-undersroot-input-mask
(screen-to-instance <screen-address>) → <instance>Builds and asserts a SCREEN instance with the same slots listed above.
(screen-to-multifield <screen-address>) → <multifield>Returns the same information as a multifield vector.
(event-mask-to-symbol <mask integer>) → <symbol>Converts an integer event mask to a symbol representing the event mask name. Possible event masks that will return:
KeyPressMaskKeyReleaseMaskButtonPressMaskButtonReleaseMaskEnterWindowMaskLeaveWindowMaskPointerMotionMaskPointerMotionHintMaskButton1MotionMaskButton2MotionMaskButton3MotionMaskButton4MotionMaskButton5MotionMaskButtonMotionMaskKeymapStateMaskExposureMaskVisibilityChangeMaskStructureNotifyMaskResizeRedirectMaskSubstructureNotifyMaskSubstructureRedirectMaskFocusChangeMaskPropertyChangeMaskColormapChangeMaskOwnerGrabButtonMask
(mask-to-symbol <mask integer>) → <symbol>Converts an integer mask to a symbol representing the mask names. Possible masks that will return:
ShiftMaskLockMaskControlMaskMod1MaskMod2MaskMod3MaskMod4MaskMod5MaskButton1MaskButton2MaskButton3MaskButton4MaskButton5MaskAnyModifier
(event-mask-to-multifield <mask integer>) → <multifield>Converts an integer event mask to a multifield of symbols
representing the event mask names. Refer to event-mask-to-symbol
for possible values that will return in the multifield.
(mask-to-multifield <mask integer>) → <multifield>Converts an integer mask to a multifield of symbols
representing the mask names. Refer to mask-to-symbol
for possible values that will return in the multifield.
(lexeme-to-event-mask <symbol or string>) → <integer>Converts a symbol or string of an event mask
to the integer mask for the event mask.
See event-mask-to-symbol for a list of possible symbols
that may be passed as the argument.
(lexeme-to-mask <symbol or string>) → <integer>Converts a symbol or string of a mask
to the integer mask for the mask.
See mask-to-symbol for a list of possible symbols
that may be passed in the multifield.
(multifield-to-event-mask <multifield>) → <integer>Converts a multifield containing symbols of event masks
to the integer mask containing all event masks specified.
See event-mask-to-symbol for a list of possible symbols
that may be passed in the multifield.
(multifield-to-mask <multifield>) → <integer>Converts a multifield containing symbols of masks
to the integer mask containing all masks specified.
See mask-to-symbol for a list of possible symbols
that may be passed in the multifield.
(x-translate-coordinates <display> <src_window> <dest_window> <src_x> <src_y>) → <multifield> or FALSETranslate a coordinate in one window to the coordinate space of another window.
Takes the src_x and src_y coordinates relative to the src_window's origin
and returns these coordinates as the first 2 values in a multifield
relative to the destination window's origin.
If the coordinates are contained in a mapped child of dest_window,
that child is returned as the last value in the returned multifield.
(x-allow-events <display> <event_mode> [<time>])Releases some queued events if the client has caused a device to freeze. It has no effect if the specified time is earlier than the last-grab time of the most recent active grab for the client or if the specified time is later than the current X server time
display- Specifies the connection to the X server.event_mode- Specifies the event mode. You can pass an integer or one of the symbolsAsyncPointer,SyncPointer,AsyncKeyboard,SyncKeyboard,ReplayPointer,ReplayKeyboard,AsyncBoth, orSyncBoth.time- Optional. Specifies the time. Omitting this specifiesCurrentTime(0).
(x-allow-events <display> <windows> [<nwindows>])Restacks the windows in the order specified, from top to bottom.
display- Specifies the connection to the X server.windows- Specifies a multifield containing the windowINTEGERs to be restacked.nwindows- Optional. Specifies the number of windows to be restacked. Will use the length ofwindowsmultifield if omitted.
(x-sync <display> [<discard?>]) → <status>Synchronizes with the X server. Sends all pending requests and waits until they are processed. Optionally discards any events already in the queue.
<display>- External address to an X11Display*.<discard?>- Optional boolean.TRUEdiscards all queued events.FALSE(default) keeps queued events.
Integer status (non-zero on success).
(x-flush <display>) → <status>Flushes the output buffer of the X server connection, ensuring all pending requests are sent. Does not wait for responses from the server.
<display>- External address to an X11Display*.
Integer status (always non-zero).
(x-set-window-background <display> <window> <pixel>) → <status>Sets the background color of a window to the specified pixel value. The window background is used when the window is cleared.
<display>- External address to an X11Display*.<window>- Integer window ID.<pixel>- Integer pixel value to set as the background. Typically retrieved from black-pixel, white-pixel, or x-alloc-color.
VOID
(x-set-window-background ?display ?window (white-pixel ?display (default-screen ?display)))
(x-change-window-attributes <display> <window> <value-mask> [<attr1> <attr2> ...]) → <status>Updates one or more attributes of a window. The <value-mask> determines which fields are modified.
Arguments for the attributes must be supplied in the canonical struct order and only for the bits set in <value-mask>.
<display>- External address toDisplay*.<window>- Integer window ID.<value-mask>- One of:- Integer bitmask
- Symbol (e.g. "CWBackPixel")
- Multifield of symbols/strings/integers (all OR'ed together)
Supported mask bits and their corresponding arguments:
CWBackPixmap- Pixmap ID or None/ParentRelativeCWBackPixel- Integer pixel valueCWBorderPixmap- Pixmap IDCWBorderPixel- Integer pixel valueCWBitGravity- Symbol or integer gravity valueCWWinGravity- Symbol or integer gravity valueCWBackingStore- Symbol (NotUseful | WhenMapped | Always) or integerCWBackingPlanes- IntegerCWBackingPixel- IntegerCWOverrideRedirect- Boolean or integer (0/1)CWSaveUnder- Boolean or integer (0/1)CWEventMask- Integer mask of event bitsCWDontPropagate- Integer maskCWColormap- Colormap IDCWCursor- Cursor ID
Integer status code (non-zero on success).
; Set only override-redirect
(x-change-window-attributes ?display ?window CWOverrideRedirect TRUE)
; Set background pixel and event mask
(x-change-window-attributes ?display ?window (create$ CWBackPixel CWEventMask)
0
(multifield-to-event-mask (create$ SubstructureRedirectMask StructureNotifyMask)))(x-clear-window <display> <window>) → <status>Clears the entire window to its background. Exposes regions of the window according to its current background settings.
<display>- External address toDisplay*.<window>- Integer window ID.
VOID
(x-clear-area <display> <window> <x> <y> <width> <height> [<exposures?>]) → <status>Clears a rectangular region of a window to the window’s background.
Optionally controls whether Expose events are generated.
<display>- External address toDisplay*.<window>- Integer window ID.<x>- X coordinate of top-left corner.<y>- Y coordinate of top-left corner.<width>- Width of the rectangle.<height>- Height of the rectangle.<exposures?>- Optional boolean or integer. If TRUE (default), generate Expose events; if FALSE, suppress them
(x-clear-area ?display ?window 10 10 200 100 FALSE)(x-set-selection-owner <display> <selection> <owner> [<time>]) → <status>Sets the window that “owns” a selection (e.g., PRIMARY, CLIPBOARD). Ownership means your window will provide the data when requested.
<display>- External address toDisplay*.<selection>- Atom name or ID (e.g., "PRIMARY", "CLIPBOARD").<owner>- Window ID that will own the selection.<time>- Optional timestamp (integer). Defaults to CurrentTime (0).
(x-set-selection-owner ?display "PRIMARY" ?mywin)(x-get-selection-owner <display> <selection>) → <window>Gets the current owner window of a selection.
<display>- External address toDisplay*.<selection>- Atom name or ID.
Window ID (integer) or 0 if no owner.
(bind ?owner (x-get-selection-owner ?display "CLIPBOARD"))(x-convert-selection <display> <selection> <target> <property> <requestor> [<time>]) → <status>Requests the current owner of a selection to convert its data to a given target (format)
and place the result into a property on your requestor window.
After SelectionNotify, read it with x-get-property.
<display>- External address toDisplay*.<selection>- Atom name or ID (e.g., "PRIMARY", "CLIPBOARD").<target>- Atom name or ID of desired format (e.g., "UTF8_STRING", "STRING", "TARGETS").<property>- Atom name or ID where data should be stored on the requestor (e.g., "XSEL_DATA").<requestor>- Your window ID.<time>- Optional timestamp. Defaults to CurrentTime (0).
; Ask for PRIMARY as UTF8 and store bytes in XSEL_DATA on our window
(x-convert-selection ?display "PRIMARY" "UTF8_STRING" "XSEL_DATA" ?mywin)
; Later, upon SelectionNotify, read it:
(x-get-property ?display ?mywin "XSEL_DATA")(x-get-wm-normal-hints <display> <window>) → <multifield> | FALSEThin wrapper over XGetWMNormalHints. Reads ICCCM WM_NORMAL_HINTS (size/position constraints).
<display>: EXTERNAL-ADDRESS toDisplay*<window>: INTEGER window id
A MULTIFIELD of 19 elements (order fixed):
- flags (INTEGER bitmask:
USPositionUSSizePPositionPSizePMinSizePMaxSizePResizeIncPAspectPBaseSizePWinGravity) - x
- y
- width
- height
- min_width
- min_height
- max_width
- max_height
- width_inc
- height_inc
- min_aspect_num
- min_aspect_den
- max_aspect_num
- max_aspect_den
- base_width
- base_height
- win_gravity (SYMBOL: ForgetGravity/NorthWestGravity/.../StaticGravity)
(bind ?hints (x-get-wm-normal-hints ?d ?w))
(if (neq ?hints FALSE) then
(printout t "flags=" (nth$ 1 ?hints) " min=(" (nth$ 6 ?hints) "," (nth$ 7 ?hints) ")" crlf))(x-get-wm-normal-hints-to-fact <display> <window>) → <fact-address> | FALSEReads WM_NORMAL_HINTS and asserts a fact using the x-size-hints deftemplate.
<display>: EXTERNAL-ADDRESS toDisplay*<window>: INTEGER window id
- Fact address of (x-size-hints ...) on success
- FALSE on failure
(bind ?f (x-get-wm-normal-hints-to-fact ?d ?w))
(if (neq ?f FALSE) then
(bind ?minw (fact-slot-value ?f min_width))
(bind ?minh (fact-slot-value ?f min_height)))(x-get-wm-normal-hints-to-instance <display> <window>) → <instance-address> | FALSEReads WM_NORMAL_HINTS and creates an instance of class X-SIZE-HINTS (you provide this class).
<display>: EXTERNAL-ADDRESS toDisplay*<window>: INTEGER window id
- Instance address of (make-instance of X-SIZE-HINTS ...) on success
- FALSE on failure
(bind ?i (x-get-wm-normal-hints-to-instance ?d ?w))
(if (neq ?i FALSE) then
(send ?i get-min_width))(x-get-wm-hints <display> <window>) → <multifield> | FALSEThin wrapper over XGetWMHints. Reads ICCCM WM_HINTS.
<display>: EXTERNAL-ADDRESS toDisplay*<window>: INTEGER window id
A MULTIFIELD of 9 elements (order fixed):
flags(INTEGER bitmask: InputHint, StateHint, IconPixmapHint, IconWindowHint, IconPositionHint, IconMaskHint, WindowGroupHint)input(SYMBOL TRUE|FALSE)initial_state(SYMBOL WithdrawnState|NormalState|IconicState)icon_pixmap(INTEGER)icon_window(INTEGER)icon_x(INTEGER)icon_y(INTEGER)icon_mask(INTEGER)window_group(INTEGER)
(bind ?h (x-get-wm-hints ?d ?w))
(if (neq ?h FALSE) then
(printout t "state=" (nth$ 3 ?h) " group=" (nth$ 9 ?h) crlf))(x-get-wm-hints-to-fact <display> <window>) → <fact-address> | FALSEReads WM_HINTS and asserts a fact using the x-wm-hints deftemplate.
<display>: EXTERNAL-ADDRESS toDisplay*<window>: INTEGER window id
- Fact address on success
FALSEon failure
(bind ?f (x-get-wm-hints-to-fact ?d ?w))
(if (neq ?f FALSE) then
(bind ?state (fact-slot-value ?f initial_state))
(printout t "initial_state=" ?state crlf))(x-get-wm-hints-to-instance <display> <window>) → <instance-address> | FALSEReads WM_HINTS and creates an instance of class X-WM-HINTS.
<display>: EXTERNAL-ADDRESS toDisplay*<window>: INTEGER window id
- Instance address on success
FALSEon failure
(bind ?i (x-get-wm-hints-to-instance ?d ?w))
(if (neq ?i FALSE) then
(send ?i get-window_group))(x-get-wm-protocols <display> <window>) → <multifield-of-atoms> | FALSEReturns the list of ICCCM WM_PROTOCOLS supported by a window (e.g., WM_DELETE_WINDOW, WM_TAKE_FOCUS) as integer Atom IDs.
<display>: EXTERNAL-ADDRESS toDisplay*<window>: INTEGER window id
MULTIFIELD of INTEGER atom IDs in server order, or FALSE if the property is absent/unavailable.
(bind ?protos (x-get-wm-protocols ?d ?w))
(if (neq ?protos FALSE) then
(bind ?del (x-intern-atom ?d "WM_DELETE_WINDOW" TRUE))
(if (member$ ?del ?protos) then
(printout t "Client supports WM_DELETE_WINDOW" crlf)))(x-intern-atom <display> <name> [<only-if-exists?>]) → <atom-id (INTEGER)>Interns an atom by name on the X server (ICCCM/EWMH rely on atoms).
<display>: EXTERNAL-ADDRESS toDisplay*.<name>: Symbol or string (e.g.,WM_DELETE_WINDOW,_NET_WM_NAME).<only-if-exists?>(optional): Boolean/symbol/int. If true, returns 0 when the atom doesn’t already exist. Default FALSE.
Integer atom ID (0 = None when only-if-exists? is true).
(bind ?UTF8 (x-intern-atom ?d "UTF8_STRING" TRUE))(x-intern-atoms <display> <names-mf> [<only-if-exists?>]) → <multifield-of-atom-ids>Batch version of x-intern-atom. Interns multiple names with a single round trip.
<display>: EXTERNAL-ADDRESS toDisplay*.<names-mf>: Multifield of symbols/strings (atom names).<only-if-exists?>(optional): Boolean/symbol/int. If true, returns 0 when the atom doesn’t already exist. Default FALSE.
- Multifield of INTEGER atom IDs (same order as
<names-mf>). - Empty multifield if
<names-mf>is empty or on validation error (error text is printed to STDERR if any element isn’t a symbol/string).
(bind ?atoms (x-intern-atoms ?d (create$ "_NET_WM_NAME" "UTF8_STRING" "WM_DELETE_WINDOW") TRUE))(x-get-atom-name <display> <atom>) → <string> | FALSEResolves an atom ID back to its server-side name.
<display>: EXTERNAL-ADDRESS toDisplay*.<atom>: INTEGER atom ID.
- String name on success.
- FALSE if the atom is invalid/unknown.
(bind ?name (x-get-atom-name ?d ?atom))(x-get-class-hint <display> <window>) → <multifield> | FALSEReturns the X resource instance (res_name) and class (res_class) of a window, used for rule matching (e.g., float dialogs, apply tags).
<display>: EXTERNAL-ADDRESS toDisplay*<window>: INTEGER window id
- MULTIFIELD of 2 strings:
res_nameres_class
FALSEif unavailable.
(bind ?rc (x-get-class-hint ?d ?w))
(if (neq ?rc FALSE) then
(bind ?name (nth$ 1 ?rc))
(bind ?class (nth$ 2 ?rc))
(printout t "class=" ?class " name=" ?name crlf))(x-start-collecting-errors <display>)Start capturing X11 errors into an internal per-Display queue handled by the library's error collector. If a queue already exists for this Display, it returns TRUE without creating a new one. Will store a maximum of 128 errors before discarding the oldest error.
<display>: EXTERNAL-ADDRESS toDisplay*
TRUEif the error queue is active (already existed or was created).FALSEif the queue could not be created.
(bind ?d (x-open-display ""))
(if (x-start-collecting-errors ?d) then
(printout t "Error collection enabled." crlf))(x-pop-error <display>) ;; -> (serial error-code request-code minor-code resourceid) | FALSEPop the oldest queued X11 error for a Display and return its fields.
<display>: EXTERNAL-ADDRESS toDisplay*
Returns
- A multifield of 5 integers on success:
serialerror-coderequest-codeminor-coderesourceid
FALSEif no queue exists for the Display or the queue is empty.
(bind ?d (x-open-display ""))
;; Start capturing errors once (usually at init)
(x-start-collecting-errors ?d)
;; ... make some X calls that might error ...
;; Try to pop one error
(bind ?err (x-pop-error ?d))
(if (neq ?err FALSE) then
(bind ?serial (nth$ 1 ?err))
(bind ?error-code (nth$ 2 ?err))
(bind ?request (nth$ 3 ?err))
(bind ?minor (nth$ 4 ?err))
(bind ?resourceid (nth$ 5 ?err))
(printout t "X error " ?error-code
" (req " ?request "/" ?minor
", serial " ?serial
", resource " ?resourceid ")" crlf)
)
;; Optionally resolve human-readable text
(printout t (x-get-error-text ?d ?error-code) crlf)
(printout t (error-code-to-symbol ?error-code) crlf)
(printout t (x-get-error-database-text ?d XRequest ?request))
(printout t (x-get-error-database-text ?d XProtoError ?request))(x-pop-error-to-fact <display>) ;; -> <fact-address> | FALSEPop the oldest queued X11 error for a Display, assert it as an x-error fact, and return the fact-address.
<display>: EXTERNAL-ADDRESS toDisplay*
- Fact-address of an asserted (x-error ...) fact on success.
FALSEif no queue exists for the Display, the queue is empty, or the fact could not be asserted.
(bind ?d (x-open-display ""))
;; Start collecting errors once
(x-start-collecting-errors ?d)
;; ... do X calls that may error ...
;; Pop to fact
(bind ?f (x-pop-error-to-fact ?d))
(if (neq ?f FALSE) then
(printout t "Got X error fact:"
" serial=" (fact-slot-value ?f serial)
" code=" (fact-slot-value ?f error-code)
" request=" (fact-slot-value ?f request-code)
" minor=" (fact-slot-value ?f minor-code)
" resourceid=" (fact-slot-value ?f resourceid)
crlf))
;; Optional: map code to text
;; (printout t (x-get-error-text ?d (fact-slot-value ?f error-code)) crlf)(x-pop-error-to-instance <display> [<name>]) ;; -> <instance-address> | FALSEPop the oldest queued X11 error for a Display, build an X-ERROR instance, and return the instance-address.
<display>: EXTERNAL-ADDRESS toDisplay*<name>: Optional name of the instance
- Instance-address of the created X-ERROR instance on success.
- FALSE if no queue exists for the Display, the queue is empty, or the instance could not be created.
(bind ?d (x-open-display ""))
;; Start once per Display
(x-start-collecting-errors ?d)
;; ... do X calls that may error ...
;; Pop into an instance (auto name)
(bind ?e (x-pop-error-to-instance ?d))
(if (neq ?e FALSE) then
(printout t
"X error:"
" serial=" (send ?e get-serial)
" code=" (send ?e get-error-code)
" request=" (send ?e get-request-code)
" minor=" (send ?e get-minor-code)
" resourceid=" (send ?e get-resourceid) crlf))
;; Or give it a specific name
(bind ?e2 (x-pop-error-to-instance ?d error-1))(x-stop-collecting-errors <display>) ;; -> TRUE | FALSEStop collecting X11 errors for a Display and free the per-display error queue.
<display>: EXTERNAL-ADDRESS toDisplay*
- TRUE on success.
- FALSE if no error queue/context was found for the given Display.
(bind ?d (x-open-display ""))
;; Start collecting first
(x-start-collecting-errors ?d)
;; ... perform X operations ...
;; Stop and free the queue
(if (eq (x-stop-collecting-errors ?d) TRUE)
then (printout t "Stopped collecting X errors." crlf)
else (printout t "Nothing to stop for this display." crlf))(x-set-default-error-handler) -> TRUESets the error handler to X11's default.
WARNING: will orphan error queues if you've previously created them
with x-start-collecting-errors calls.
(x-get-error-text <display> <error-code>) ;; -> <string>Return a human-readable description for an X11 error code.
<display>- external-address to an open Display* (from x-open-display).<error-code>- integer X error code (e.g., from x-pop-error, the error-code field).
A string with the error’s textual description (empty string if none is available).
;; Using a code directly
(bind ?d (x-open-display ""))
(printout t (x-get-error-text ?d 3) crlf) ;; e.g., "BadWindow" on most servers
;; From the error queue
(bind ?e (x-pop-error ?d))
(if ?e then
(bind ?code (nth$ 2 ?e)) ;; serial error-code request-code minor-code resourceid
(printout t "Error: " (x-get-error-text ?d ?code) crlf))(x-get-error-database-text <display> <name> <type-int>) ;; -> <string>Look up a formatted string from the X error database using a (name, type) key.
<display>- external-address to an open Display* (from x-open-display).<name>- symbol/string for the database “name” (commonly "XError" or "XRequest").<type-int>- integer key; converted to a string before lookup (e.g., an error code or request code).
A string from the X error database for the given key (empty string if no entry exists).
;; Get human text for an error code using the database
(bind ?d (x-open-display ""))
;; From the error queue (serial error-code request-code minor-code resourceid)
(bind ?e (x-pop-error ?d))
(if ?e then
(bind ?err (nth$ 2 ?e))
(bind ?req (nth$ 3 ?e))
(printout t "DB XError(" ?err "): "
(x-get-error-database-text ?d "XError" ?err) crlf)
(printout t "DB XRequest(" ?req "): "
(x-get-error-database-text ?d "XRequest" ?req) crlf))
;; Direct lookups
(printout t (x-get-error-database-text ?d "XError" 3) crlf) ;; often "BadWindow"
(printout t (x-get-error-database-text ?d "XRequest" 20) crlf)(error-code-to-symbol <code-int>) ;; -> <symbol> | <void><code-int>- integer X error code (e.g., 1..17 for core protocol).
- The corresponding symbol (e.g., BadWindow, BadAtom) if the code is recognized.
- void if the code is invalid; also prints "
<code>is not a valid error code" to STDERR.
(error-code->symbol 3) ;; => BadWindow
(error-code->symbol 1) ;; => BadRequest
(bind ?s (error-code->symbol 99)) ;; prints "99 is not a valid error code" and returns voidThis logo was created in GIMP and is based on the CLIPS logo and the X.Org logo (User:Sven CC BY-SA 3.0, via Wikimedia Commons).