XTEST(3)

πŸ’– XTEST β€” XTest extension functions πŸ’–

okay bestie so this is the manual page for XTEST(3) from libXtst, and it's literally the whole toolkit for making the X server do stuff for you, no human hands required. yes we're in the X11 section, yes it's giving wizard energy, let's go ✨


🌸 NAME 🌸

XTestQueryExtension, XTestCompareCursorWithWindow, XTestCompareCurrentCursorWithWindow, XTestFakeKeyEvent, XTestFakeButtonEvent, XTestFakeMotionEvent, XTestFakeRelativeMotionEvent, XTestGrabControl, XTestSetGContextOfGC, XTestSetVisualIDOfVisual, XTestDiscard β€” XTest extension functions 🫢


✨ SYNOPSIS ✨

link it up like this, bestie:

cc [ flag ... ] file ... -lXtst  [ library ... ]

#include <X11/extensions/XTest.h>

and here's every single one of the signatures, verbatim, no cap:

Bool XTestQueryExtension(display, event_base_return, error_base_return,
                         major_version_return, minor_version_return);

                          Display *display;
                          int *event_base_return;
                          int *error_base_return;
                          int *major_version_return;
                          int *minor_version_return;

Bool XTestCompareCursorWithWindow(display, window, cursor);

                                   Display *display;
                                   Window window;
                                   Cursor cursor;

Bool XTestCompareCurrentCursorWithWindow(display, window);

                                          Display *display;
                                          Window window;

int XTestFakeKeyEvent(display, keycode, is_press, delay);

                       Display *display;
                       unsigned int keycode;
                       Bool is_press;
                       unsigned long delay;

int XTestFakeButtonEvent(display, button, is_press, delay);

                          Display *display;
                          unsigned int button;
                          Bool is_press;
                          unsigned long delay;

int XTestFakeMotionEvent(display, screen_number, x, y, delay);

                          Display *display;
                          int screen_number;
                          int x, y;
                          unsigned long delay;

int XTestFakeRelativeMotionEvent(display, screen_number, x, y, delay);

                                  Display *display;
                                  int screen_number;
                                  int x, y;
                                  unsigned long delay;

int XTestGrabControl(display, impervious);

                      Display *display;
                      Bool impervious;

void XTestSetGContextOfGC(gc, gid);

                           GC gc;
                           GContext gid;

void XTestSetVisualIDOfVisual(visual, visualid);

                               Visual *visual;
                               VisualID visualid;

Status XTestDiscard(display);

                     Display *display;

🌈 DESCRIPTION 🌈

so the tea is: this extension is a minimal set of client and server extensions required to completely test the X11 server with no user intervention. like, zero humans touching anything. πŸ’…

⚠️ important: this extension is not intended to support general journaling and playback of user actions. it's for testing, not for being your little macro recorder, ok?

the functions in this extension fall into two groups, and yes they're both iconic in their own way:

πŸŽ€ Client Operations πŸŽ€

these routines manipulate otherwise hidden client-side behavior. the actual implementation will depend on the details of the actual language binding and what degree of request buffering, GContext caching, and so on, is provided.

in the C binding, routines are provided to:

  • access the internals of two opaque data structures β€” GCs and Visuals
  • discard any requests pending within the output buffer of a connection

the exact details can be expected to differ for other language bindings, so don't come for me if your binding does its own thing. πŸ™ˆ

πŸ¦‹ Server Requests πŸ¦‹

the first of these requests is similar to that provided in most extensions: it lets a client specify a major and minor version number to the server, and lets the server respond with major and minor versions of its own.

the remaining two requests allow the following:

  • access to an otherwise write-only server resource: the cursor associated with a given window πŸ‘€
  • perhaps most importantly, limited synthesis of input device events, almost as if a cooperative user had moved the pointing device or pressed a key or button. main character energy fr πŸ”₯

also, housekeeping: all XTEST extension functions and procedures, and all manifest constants and macros, will start with the string XTest. and all operations are classified as server/client (Server) or client-only (Client). iykyk.


⭐ the functions, one by one ⭐

XTestQueryExtension returns True if the specified display supports the XTEST extension, else False. if the extension is supported, *event_base would be set to the event number for the first event for this extension, and *error_base would be set to the error number for the first error for this extension. and here's the thing bestie β€” as no errors or events are defined for this version of the extension, the values returned here are not defined (nor useful). πŸ’€ if the extension is supported, *major_version and *minor_version are set to the major and minor version numbers of the extension supported by the display. otherwise, none of the arguments are set.

XTestCompareCursorWithWindow β€” if the extension is supported, this performs a comparison of the cursor whose ID is specified by cursor (which may be None) with the cursor of the window specified by window, returning True if they are the same and False otherwise. if the extension is not supported, then the request is ignored and zero is returned.

XTestCompareCurrentCursorWithWindow β€” if the extension is supported, this performs a comparison of the current cursor with the cursor of the specified window, returning True if they are the same and False otherwise. if the extension is not supported, the request is ignored and zero is returned.

XTestFakeKeyEvent β€” if the extension is supported, this requests the server to simulate either a KeyPress (if is_press is True) or a KeyRelease (if is_press is False) of the key with the specified keycode; otherwise, the request is ignored.

if the extension is supported, the simulated event will not be processed until delay milliseconds after the request is received (if delay is CurrentTime, then this is interpreted as no delay at all). no other requests from this client will be processed until this delay, if any, has expired and subsequent processing of the simulated event has been completed. ⏳

XTestFakeButtonEvent β€” if the extension is supported, this requests the server to simulate either a ButtonPress (if is_press is True) or a ButtonRelease (if is_press is False) of the logical button numbered by the specified button; otherwise, the request is ignored.

if the extension is supported, the simulated event will not be processed until delay milliseconds after the request is received (if delay is CurrentTime, then this is interpreted as no delay at all). no other requests from this client will be processed until this delay, if any, has expired and subsequent processing of the simulated event has been completed. ⏳

XTestFakeMotionEvent β€” if the extension is supported, this requests the server to simulate a movement of the pointer to the specified position (x, y) on the root window of screen_number; otherwise, the request is ignored. if screen_number is -1, the current screen (that the pointer is on) is used. πŸ–±οΈ

if the extension is supported, the simulated event will not be processed until delay milliseconds after the request is received (if delay is CurrentTime, then this is interpreted as no delay at all). no other requests from this client will be processed until this delay, if any, has expired and subsequent processing of the simulated event has been completed. ⏳

XTestFakeRelativeMotionEvent β€” if the extension is supported, this requests the server to simulate a movement of the pointer by the specified offsets (x, y) relative to the current pointer position on screen_number; otherwise, the request is ignored. if screen_number is -1, the current screen (that the pointer is on) is used. πŸ–±οΈβœ¨

if the extension is supported, the simulated event will not be processed until delay milliseconds after the request is received (if delay is CurrentTime, then this is interpreted as no delay at all). no other requests from this client will be processed until this delay, if any, has expired and subsequent processing of the simulated event has been completed. ⏳

XTestGrabControl β€” if impervious is True, then the executing client becomes impervious to server grabs. if impervious is False, then the executing client returns to the normal state of being susceptible to server grabs. πŸ›‘οΈ

XTestSetGContextOfGC β€” sets the GContext within the opaque datatype referenced by gc to be that specified by gid.

XTestSetVisualIDOfVisual β€” sets the VisualID within the opaque datatype referenced by visual to be that specified by visualid.

XTestDiscard β€” discards any requests within the output buffer for the specified display. it returns True if any requests were discarded; otherwise, it returns False. πŸ—‘οΈ


πŸ‘‘ RETURN VALUES πŸ‘‘

all routines that have return type Status will return nonzero for success and zero for failure.

and listen β€” even if the XTEST extension is supported, the server may withdraw such facilities arbitrarily; in which case they will subsequently return zero. so like, don't build your entire personality on it, bestie. 😭


πŸ’œ AUTHOR πŸ’œ

Kieron Drake UniSoft Ltd. Author.


and that's the whole page, you ate it, go forth and fake some input events responsibly πŸ’…βœ¨

that's a wrap on XTEST(3) from libXtst, dated 6 June 2007 β€” mwah, periodt. πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from