### X Window System command examples Source: https://xorg.freedesktop.org/archive/current/doc/man/man7/X.7.xhtml These are sample command lines for common X Window System commands. The commands cover resource loading, key remapping, font setup, display settings, utility tools, and windows. Most commands can be run in a shell session; some are interactive or require an X server. ```bash % xrdb $HOME/.Xresources ``` ```bash % xmodmap −e "keysym BackSpace = Delete" ``` ```bash % mkfontdir /usr/local/lib/X11/otherfonts ``` ```bash % xset fp+ /usr/local/lib/X11/otherfonts ``` ```bash % xmodmap $HOME/.keymap.km ``` ```bash % xsetroot −solid ’rgbi:.8/.8/.8’ ``` ```bash % xset b 100 400 c 50 s 1800 r on ``` ```bash % xset q ``` ```bash % twm ``` ```bash % xmag ``` ```bash % xclock −geometry 48x48-0+0 −bg blue −fg white ``` ```bash % xeyes −geometry 48x48−48+0 ``` ```bash % xbiff −update 20 ``` ```bash % xlsfonts ’*helvetica*’ ``` ```bash % xwininfo −root ``` ```bash % xdpyinfo −display joesworkstation:0 ``` ```bash % xhost −joesworkstation ``` ```bash % xrefresh ``` ```bash % xwd | xwud ``` ```bash % bitmap companylogo.bm 32x32 ``` ```bash % xcalc −bg blue −fg magenta ``` ```bash % xterm −geometry 80x66−0−0 −name myxterm $* ``` -------------------------------- ### Accelerated Axis Example Source: https://xorg.freedesktop.org/archive/current/doc/man/man4/joystick.4.xhtml Example setting up an axis as scrolling vertically inverted at half speed. ```xorg.conf Option "MapAxis1" "mode=accelerated axis=-0.5zy" ``` -------------------------------- ### Get MaxCmapsOfScreen Source: https://xorg.freedesktop.org/archive/current/doc/libxcb/tutorial/index.html Retrieves the maximum installed colormaps from the xcb_screen_t structure. ```c xcb_connection_t *c; xcb_screen_t *screen; int screen_nbr; uint16_t max_installed_maps = 0; /* the returned maximum installed colormaps */ /* you init the connection and screen_nbr */ screen = screen_of_display (c, screen_nbr); if (screen) max_installed_maps = screen->max_installed_maps; /* max_installed_maps contains now the maximum installed colormaps, or 0 if no screen is found */ ``` -------------------------------- ### XtOpenApplication Source: https://xorg.freedesktop.org/archive/current/doc/man/man3/XtOpenApplication.3.xhtml Initializes the X Toolkit, creates an application context, opens a display, and creates a shell widget. Returns the created shell widget. ```APIDOC ## XtOpenApplication ### Description Initializes the X Toolkit, creates an application context, opens a display, and creates a shell widget. Returns the created shell widget. ### Syntax ```c Widget XtOpenApplication(XtAppContext *app_context_return, String application_class, XrmOptionDescRec *options, Cardinal num_options, int *argc_in_out, String *argv_in_out, String *fallback_resources, WidgetClass widget_class, ArgList args, Cardinal num_args); ``` ### Arguments - **app_context_return** (XtAppContext*) - Specifies the application context. If not NULL, the created application context is returned. - **application_class** (String) - Specifies the class name of this application, usually the generic name for all instances. - **options** (XrmOptionDescRec*) - Specifies how to parse the command line for application-specific resources. Passed to XrmParseCommand. - **num_options** (Cardinal) - Specifies the number of entries in the options list. - **argc_in_out** (int*) - Specifies a pointer to the number of command line parameters. Modified argc is returned. - **argv_in_out** (String*) - Specifies the command line parameters. Modified argv is returned. - **fallback_resources** (String) - Specifies resource values to be used if the application class resource file cannot be opened or read, or NULL. - **widget_class** (WidgetClass) - Specifies the widget class of the shell to be created. - **args** (ArgList) - Specifies the argument list to override any other resource specification for the created shell widget. - **num_args** (Cardinal) - Specifies the number of entries in the argument list. ### Returns - **Widget** - The created shell widget. ### Description Calls XtToolkitInitialize, XtCreateApplicationContext, XtOpenDisplay with display_string NULL and application_name NULL, and XtAppCreateShell with application_name NULL, the specified widget_class, and the specified args and num_args. Returns the created shell. If the display cannot be opened, an error message is issued and the application terminates. If fallback_resources is non-NULL, XtAppSetFallbackResources is called prior to XtOpenDisplay. ``` -------------------------------- ### Complete XCB window and button example Source: https://xorg.freedesktop.org/archive/current/doc/libxcb/tutorial/index.html A full implementation demonstrating window creation, button drawing, and dynamic cursor changes based on user interaction. ```c #include #include #include #include #define WIDTH 300 #define HEIGHT 150 static xcb_gc_t gc_font_get (xcb_connection_t *c, xcb_screen_t *screen, xcb_window_t window, const char *font_name); static void button_draw (xcb_connection_t *c, xcb_screen_t *screen, xcb_window_t window, int16_t x1, int16_t y1, const char *label); static void text_draw (xcb_connection_t *c, xcb_screen_t *screen, xcb_window_t window, int16_t x1, int16_t y1, const char *label); static void cursor_set (xcb_connection_t *c, xcb_screen_t *screen, xcb_window_t window, int cursor_id); static void button_draw (xcb_connection_t *c, xcb_screen_t *screen, xcb_window_t window, int16_t x1, int16_t y1, const char *label) { xcb_point_t points[5]; xcb_void_cookie_t cookie_gc; xcb_void_cookie_t cookie_line; xcb_void_cookie_t cookie_text; xcb_generic_error_t *error; xcb_gcontext_t gc; int16_t width; int16_t height; uint8_t length; int16_t inset; length = strlen (label); inset = 2; gc = gc_font_get(c, screen, window, "7x13"); width = 7 * length + 2 * (inset + 1); height = 13 + 2 * (inset + 1); points[0].x = x1; points[0].y = y1; points[1].x = x1 + width; points[1].y = y1; points[2].x = x1 + width; points[2].y = y1 - height; points[3].x = x1; points[3].y = y1 - height; points[4].x = x1; points[4].y = y1; cookie_line = xcb_poly_line_checked (c, XCB_COORD_MODE_ORIGIN, window, gc, 5, points); error = xcb_request_check (c, cookie_line); if (error) { fprintf (stderr, "ERROR: can't draw lines : %d\n", error->error_code); xcb_disconnect (c); exit (-1); } cookie_text = xcb_image_text_8_checked (c, length, window, gc, x1 + inset + 1, y1 - inset - 1, label); error = xcb_request_check (c, cookie_text); if (error) { fprintf (stderr, "ERROR: can't paste text : %d\n", error->error_code); xcb_disconnect (c); exit (-1); } cookie_gc = xcb_free_gc (c, gc); error = xcb_request_check (c, cookie_gc); if (error) { fprintf (stderr, "ERROR: can't free gc : %d\n", error->error_code); xcb_disconnect (c); exit (-1); } } static void text_draw (xcb_connection_t *c, xcb_screen_t *screen, xcb_window_t window, int16_t x1, int16_t y1, const char *label) { xcb_void_cookie_t cookie_gc; xcb_void_cookie_t cookie_text; xcb_generic_error_t *error; xcb_gcontext_t gc; uint8_t length; length = strlen (label); gc = gc_font_get(c, screen, window, "7x13"); cookie_text = xcb_image_text_8_checked (c, length, window, gc, x1, y1, label); error = xcb_request_check (c, cookie_text); if (error) { fprintf (stderr, "ERROR: can't paste text : %d\n", error->error_code); xcb_disconnect (c); exit (-1); } ``` -------------------------------- ### Get MinCmapsOfScreen Source: https://xorg.freedesktop.org/archive/current/doc/libxcb/tutorial/index.html Retrieves the minimum installed colormaps from the xcb_screen_t structure. ```c xcb_connection_t *c; xcb_screen_t *screen; int screen_nbr; uint16_t min_installed_maps = 0; /* the returned minimum installed colormaps */ /* you init the connection and screen_nbr */ screen = screen_of_display (c, screen_nbr); if (screen) min_installed_maps = screen->min_installed_maps; /* min_installed_maps contains now the minimum installed colormaps, or 0 if no screen is found */ ``` -------------------------------- ### ScreenInit() example: initialize screen and wrap CloseScreen Source: https://xorg.freedesktop.org/archive/current/doc/xorg-server/ddxDesign.txt Shows the body of a typical ScreenInit() function for an Xorg driver. It overrides visual masks/offsets for DirectColor, initializes banking, backing store, black/white pixels, cursor, and default colormap, then wraps CloseScreen and sets SaveScreen. Returns FALSE on failure and TRUE on success. ```c /* Override the default mask/offset settings */ if (pScrn->bitsPerPixel > 8) { for (i = 0, visual = pScreen->visuals; i < pScreen->numVisuals; i++, visual++) { if ((visual->class | DynamicClass) == DirectColor) { visual->offsetRed = pScrn->offset.red; visual->offsetGreen = pScrn->offset.green; visual->offsetBlue = pScrn->offset.blue; visual->redMask = pScrn->mask.red; visual->greenMask = pScrn->mask.green; visual->blueMask = pScrn->mask.blue; } } } /* * If banking is needed, initialise an miBankInfoRec (defined in * "mibank.h"), and call miInitializeBanking(). */ if (!miInitializeBanking(pScreen, pScrn->virtualX, pScrn->virtualY, pScrn->displayWidth, pBankInfo)) return FALSE; /* * If backing store is to be supported (as is usually the case), * initialise it. */ miInitializeBackingStore(pScreen); /* * Set initial black & white colourmap indices. */ xf86SetBlackWhitePixels(pScreen); /* * Install colourmap functions. If using the vgahw module, * vgaHandleColormaps would usually be called here. */ ... /* * Initialise cursor functions. This example is for the mi * software cursor. */ miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); /* Initialise the default colourmap */ switch (pScrn->depth) { case 1: if (!xf1bppCreateDefColormap(pScreen)) return FALSE; break; case 4: if (!xf4bppCreateDefColormap(pScreen)) return FALSE; break; default: if (!cfbCreateDefColormap(pScreen)) return FALSE; break; } /* * Wrap the CloseScreen vector and set SaveScreen. */ ZZZPTR(pScrn)->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = ZZZCloseScreen; pScreen->SaveScreen = ZZZSaveScreen; /* Report any unused options (only for the first generation) */ if (serverGeneration == 1) { xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); } /* Done */ return TRUE; } ``` -------------------------------- ### Mapping section targets Source: https://xorg.freedesktop.org/archive/current/doc/xorg-docs/fonts/fonts.txt Examples of starting a mapping section for different targets. ```text STARTMAPPING unicode STARTMAPPING cmap 3 1 STARTMAPPING postscript ``` -------------------------------- ### Minimal X Toolkit application setup Source: https://xorg.freedesktop.org/archive/current/doc/libXaw/libXaw.html Shows the essential calls for creating a managed widget, realizing the top-level shell, and entering the main event loop. This is the typical pattern after setting up argument lists and creating the widget hierarchy. ```c XtCreateManagedWidget(_name_, _class_, _parent_, _args_, _num_args_); XtRealizeWidget(_shell_); XtAppMainLoop(_app_context_); ``` -------------------------------- ### line command example Source: https://xorg.freedesktop.org/archive/current/doc/man/man3/Xaw.3.xhtml Draws a line with the current foreground color. Requires four arguments: the starting and ending coordinate pairs. ```text line +0,+0, -1,-1 ``` -------------------------------- ### ImageText8 function signature Source: https://xorg.freedesktop.org/archive/current/doc/xorg-server/Xserver-spec.txt Draws text in the foreground color; the background color fills the remainder of the character rectangles. Coordinates specify the baseline and start of the text. An example implementation is miImageText8() in Xserver/mi/mipolytext.c. ```c void pGC->ops->ImageText8(pDraw, pGC, x, y, count, chars) DrawablePtr pDraw; GCPtr pGC; int x, y; int count; char *chars; ``` -------------------------------- ### XtOpenApplication Source: https://xorg.freedesktop.org/archive/current/doc/libXaw/libXaw.html Initializes the toolkit, opens the X server connection, parses the command line, and creates an initial widget that serves as the root of the application's widget tree. This function must be called before any other toolkit routines (besides locale setting). ```APIDOC Widget XtOpenApplication(XtAppContext * app_context_return, String application_class, XrmOptionDescList options, Cardinal num_options, int *argc_in_out, String *argv_in_out, String *fallback_resources, WidgetClass widget_class, ArgList args, Cardinal num_args); ``` -------------------------------- ### image command example Source: https://xorg.freedesktop.org/archive/current/doc/man/man3/Xaw.3.xhtml Copies a pixmap into the widget. The pixmap-spec is defined in the PIXMAPS section. xs and ys are the starting coordinates; xe and ye are optional and default to xs + pixmap.width and ys + pixmap.height. If the pixmap has a mask, the copy is masked accordingly. ```text image pixmap.xpm,0,0,20,20 ``` -------------------------------- ### Starting an Xlib stub procedure Source: https://xorg.freedesktop.org/archive/current/doc/libX11/libX11/libX11.html Starter template for an Xlib stub procedure. Includes the Xlibint.h header and declares a pointer to the request structure. If the protocol request has a reply, the variable declarations should also include the reply structure, for example: xDoSomethingReply rep; ```c #include " XDoSomething (arguments, ... ) /* argument declarations */ { register XDoSomethingReq *req; ... ``` -------------------------------- ### Configuration file: virtual display examples (example0-example3) Source: https://xorg.freedesktop.org/archive/current/doc/man/man1/Xdmx.1.xhtml Shows four alternative syntaxes for defining two displays in a virtual display configuration. The first uses explicit sizes and offsets, the second omits size for the second display, the third uses quoted display names, and the fourth uses the 'wall' keyword with a 2x1 layout. ```xorg.conf virtual example0 { display d0:0 1280x1024 @0x0; display d1:0 1280x1024 @1280x0; } ``` ```xorg.conf virtual example1 { display d0:0 1280x1024; display d1:0 @1280x0; } ``` ```xorg.conf virtual example2 { display "d0:0"; display "d1:0" @1280x0; } ``` ```xorg.conf virtual example3 { wall 2x1 d0:0 d1:0; } ``` -------------------------------- ### ScreenInit example: process options, validate modes, load submodules Source: https://xorg.freedesktop.org/archive/current/doc/xorg-server/ddxDesign.txt Example of a driver's ScreenInit function that processes options, probes PCI info, validates modes, and loads submodules. It uses xf86ProcessOptions, xf86IsOptionSet, xf86GetOptValInteger, xf86GetPciInfoForScreen, xf86ValidateModes, xf86PruneDriverModes, xf86SetCrtcForModes, xf86PrintModes, xf86SetDpi, and xf86LoadSubModule. Note the placeholder 'print error message' and ellipses indicate omitted sections. ```c /* * Process the options based on the information in ZZZOptions. * The results are written to pZzz->Options. If all of the options * processing is done within this function a local variable "options" * can be used instead of pZzz->Options. */ if (!(pZzz->Options = xalloc(sizeof(ZZZOptions)))) return FALSE; (void)memcpy(pZzz->Options, ZZZOptions, sizeof(ZZZOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pZzz->Options); /* * Set various fields of ScrnInfoRec and/or ZZZRec based on * the options found. */ from = X_DEFAULT; pZzz->hwCursor = FALSE; if (xf86IsOptionSet(pZzz->Options, OPTION_HW_CURSOR)) { from = X_CONFIG; pZzz->hwCursor = TRUE; } xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", pZzz->hwCursor ? "HW" : "SW"); if (xf86IsOptionSet(pZzz->Options, OPTION_NOACCEL)) { pZzz->noAccel = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); } else { pZzz->noAccel = FALSE; } if (xf86IsOptionSet(pZzz->Options, OPTION_PCI_RETRY)) { pZzz->UsePCIRetry = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PCI retry enabled\n"); } pZzz->fooHack = 0; if (xf86GetOptValInteger(pZzz->Options, OPTION_FOO_HACK, &pZzz->fooHack)) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Foo Hack set to %d\n", pZzz->fooHack); } /* * Find the PCI slot(s) that this screen claimed in the probe. * In this case, exactly one is expected, so complain otherwise. * Note in this case we're not interested in the card types so * that parameter is set to NULL. */ if ((i = xf86GetPciInfoForScreen(pScrn->scrnIndex, &pciList, NULL)) != 1) { print error message; ZZZFreeRec(pScrn); if (i > 0) xfree(pciList); return FALSE; } /* Note that pciList should be freed below when no longer needed */ /* * Determine the chipset, allowing config file chipset and * chipid values to override the probed information. The config * chipset value has precedence over its chipid value if both * are present. * * It isn't necessary to fill in pScrn->chipset if the driver * keeps track of the chipset in its ZZZRec. */ ... /* * Determine video memory, fb base address, I/O addresses, etc, * allowing the config file to override probed values. * * Set the appropriate pScrn fields (videoRam is probably the * most important one that other code might require), and * print out the settings. */ ... /* Initialise a clockRanges list. */ ... /* Set any other chipset specific things in the ZZZRec */ ... /* Select valid modes from those available */ i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, pScrn->display->modes, clockRanges, NULL, minPitch, maxPitch, rounding, minHeight, maxHeight, pScrn->display->virtualX, pScrn->display->virtualY, pScrn->videoRam * 1024, LOOKUP_BEST_REFRESH); if (i == -1) { ZZZFreeRec(pScrn); return FALSE; } /* Prune the modes marked as invalid */ xf86PruneDriverModes(pScrn); /* If no valid modes, return */ if (i == 0 || pScrn->modes == NULL) { print error message; ZZZFreeRec(pScrn); return FALSE; } /* * Initialise the CRTC fields for the modes. This driver expects * vertical values to be halved for interlaced modes. */ xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); /* Set the current mode to the first in the list. */ pScrn->currentMode = pScrn->modes; /* Print the list of modes being used. */ xf86PrintModes(pScrn); /* Set the DPI */ xf86SetDpi(pScrn, 0, 0); /* Load bpp-specific modules */ switch (pScrn->bitsPerPixel) { case 1: mod = "xf1bpp"; break; case 4: mod = "xf4bpp"; break; case 8: mod = "cfb"; break; case 16: mod = "cfb16"; break; case 24: mod = "cfb24"; break; case 32: mod = "cfb32"; break; } if (mod && !xf86LoadSubModule(pScrn, mod)) ZZZFreeRec(pScrn); return FALSE; /* Load XAA if needed */ if (!pZzz->noAccel || pZzz->hwCursor) if (!xf86LoadSubModule(pScrn, "xaa")) { ZZZFreeRec(pScrn); return FALSE; } /* Done */ return TRUE; } ``` -------------------------------- ### Get window geometry with xcb_get_geometry_reply Source: https://xorg.freedesktop.org/archive/current/doc/libxcb/tutorial/index.html Usage example for retrieving a window's geometry. It initializes c and win, calls xcb_get_geometry_reply with the cookie from xcb_get_geometry, then frees the returned structure. The coordinates are relative to the parent window, so they are not directly useful for screen manipulation. ```c xcb_connection_t *c; xcb_drawable_t win; xcb_get_geometry_reply_t *geom; /* You initialize c and win */ geom = xcb_get_geometry_reply (c, xcb_get_geometry (c, win), NULL); /* Do something with the fields of geom */ free (geom); ``` -------------------------------- ### AllocColor function signature Source: https://xorg.freedesktop.org/archive/current/doc/xorg-server/Xserver-spec.txt Declares the DIX function AllocColor used to fill in a colormap. It takes pointers to 16-bit color values and a suggested pixel value. If the colormap starts empty and you don't pick the same value twice, you get your suggested pixel. Set *pPix to 0 to allocate sequentially from entry 0. ```c int AllocColor (pmap, pred, pgreen, pblue, pPix, client) ColormapPtr pmap; unsigned short *pred, *pgreen, *pblue; Pixel *pPix; int client; ``` -------------------------------- ### Sample device control routine (extproc) for DEVICE_INIT Source: https://xorg.freedesktop.org/archive/current/doc/xorg-server/Xinput.txt Shows a device control routine that is called by InitAndStartDevices with mode DEVICE_INIT. It retrieves the device's private data and checks the device name against XI_TABLET to decide initialization steps. The snippet is incomplete as it ends mid-comment, but it illustrates the structure for handling device initialization. ```c Bool extproc (dev, mode) DeviceIntPtr dev; int mode; { LocalDevice *localdev = (LocalDevice *) dev->devicePrivate; switch (mode) { case DEVICE_INIT: if (strcmp(localdev->name, XI_TABLET) == 0) { /**************************************************** * This device reports proximity, has buttons, * reports two axes of motion, and can be focused. * It also supports the same feedbacks as the X pointer * (acceleration and threshold can be set). ****************************************************/ ``` -------------------------------- ### Sample InitInput implementation Source: https://xorg.freedesktop.org/archive/current/doc/xorg-server/Xinput.txt Shows a typical InitInput function that opens input devices, registers a block/wakeup handler, and registers each device with DIX using AddInputDevice and the appropriate Register*Device call. It demonstrates how to handle keyboard, pointer, and extension devices, and calls FatalError if too many devices are added. ```c InitInput(argc,argv) { int i, numdevs, ReadInput(); DeviceIntPtr dev; LocalDevice localdevs[LOCAL_MAX_DEVS]; DeviceProc kbdproc, ptrproc, extproc; /************************************************************** * Open the appropriate input devices, determine which are * available, and choose an X pointer and X keyboard device * in some implementation-dependent manner. ***************************************************************/ open_input_devices (&numdevs, localdevs); /************************************************************** * Register a WakeupHandler to handle input when it is generated. ***************************************************************/ RegisterBlockAndWakeupHandlers (NoopDDA, ReadInput, NULL); /************************************************************** * Register the input devices with DIX. ***************************************************************/ for (i=0; idevicePrivate = (pointer) &localdevs[i]; } ``` -------------------------------- ### Protocol Encoding: Example Component (depth: CARD8) Source: https://xorg.freedesktop.org/archive/current/doc/xproto/x11protocol.html Example of a component described as name: TYPE. This becomes the encode-form shown in the next example. ```text depth: CARD8 ``` -------------------------------- ### XIQueryVersion example usage Source: https://xorg.freedesktop.org/archive/current/doc/man/man3/XIQueryVersion.3.xhtml Example showing how to call XIQueryVersion and handle the return status. It checks for Success, BadRequest, and other errors, printing the supported version accordingly. ```c int rc; int major = 2; int minor = 0; rc = XIQueryVersion(dpy, &major, &minor); if (rc == Success) printf("XI2 supported. (%d.%d)\n", major, minor); else if (rc == BadRequest) printf("No XI2 support. (%d.%d only)\n", major, minor); else printf("Internal error\n"); ``` -------------------------------- ### Retrieving window attributes example Source: https://xorg.freedesktop.org/archive/current/doc/libxcb/tutorial/index.html Example usage of retrieving and cleaning up window attributes. ```c xcb_connection_t *c; xcb_drawable_t win; xcb_get_window_attributes_reply_t *attr; /* You initialize c and win */ attr = xcb_get_window_attributes_reply (c, xcb_get_window_attributes (c, win), NULL); if (!attr) return 0; /* Do something with the fields of attr */ free (attr); ``` -------------------------------- ### Create and map a 150x150 window with xcb_create_window() and xcb_map_window() Source: https://xorg.freedesktop.org/archive/current/doc/libxcb/tutorial/index.html Complete C program that opens an X connection, creates a 150x150 window at the top-left corner, maps it, flushes requests, and pauses until Ctrl-C. The window has an undefined background and no event handling, so Ctrl-C is required to exit. ```c #include /* pause() */ #include int main () { xcb_connection_t *c; xcb_screen_t *screen; xcb_window_t win; /* Open the connection to the X server */ c = xcb_connect (NULL, NULL); /* Get the first screen */ screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data; /* Ask for our window's Id */ win = xcb_generate_id(c); /* Create the window */ xcb_create_window (c, /* Connection */ XCB_COPY_FROM_PARENT, /* depth (same as root)*/ win, /* window Id */ screen->root, /* parent window */ 0, 0, /* x, y */ 150, 150, /* width, height */ 10, /* border_width */ XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */ screen->root_visual, /* visual */ 0, NULL); /* masks, not used yet */ /* Map the window on the screen */ xcb_map_window (c, win); /* Make sure commands are sent before we pause, so window is shown */ xcb_flush (c); pause (); /* hold client until Ctrl-C */ return 0; } ```