XCreateWindow, XCreateSimpleWindow, XSetWindowAttributes − create windows and window attributes structure


Window XCreateWindow(Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth, unsigned int class, Visual *visual, unsigned long valuemask, XSetWindowAttributes *attributes);

Window XCreateSimpleWindow(Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, unsigned long border, unsigned long background);



Specifies the structure from which the values (as specified by the value mask) are to be taken. The value mask should have the appropriate bits set to indicate which attributes have been set in the structure.


Specifies the background pixel value of the window.


Specifies the border pixel value of the window.


Specifies the width of the created window’s border in pixels.


Specifies the created window’s class. You can pass InputOutput, InputOnly, or CopyFromParent. A class of CopyFromParent means the class is taken from the parent.


Specifies the window’s depth. A depth of CopyFromParent means the depth is taken from the parent.


Specifies the connection to the X server.


Specifies the parent window.


Specifies which window attributes are defined in the attributes argument. This mask is the bitwise inclusive OR of the valid attribute mask bits. If valuemask is zero, the attributes are ignored and are not referenced.


Specifies the visual type. A visual of CopyFromParent means the visual type is taken from the parent.



Specify the width and height, which are the created window’s inside dimensions and do not include the created window’s borders.



Specify the x and y coordinates, which are the top-left outside corner of the window’s borders and are relative to the inside of the parent window’s borders.


The XCreateWindow function creates an unmapped subwindow for a specified parent window, returns the window ID of the created window, and causes the X server to generate a CreateNotify event. The created window is placed on top in the stacking order with respect to siblings.

The coordinate system has the X axis horizontal and the Y axis vertical with the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms of pixels, and coincide with pixel centers. Each window and pixmap has its own coordinate system. For a window, the origin is inside the border at the inside, upper-left corner.

The border_width for an InputOnly window must be zero, or a BadMatch error results. For class InputOutput, the visual type and depth must be a combination supported for the screen, or a BadMatch error results. The depth need not be the same as the parent, but the parent must not be a window of class InputOnly, or a BadMatch error results. For an InputOnly window, the depth must be zero, and the visual must be one supported by the screen. If either condition is not met, a BadMatch error results. The parent window, however, may have any depth and class. If you specify any invalid window attribute for a window, a BadMatch error results.

The created window is not yet displayed (mapped) on the user’s display. To display the window, call XMapWindow. The new window initially uses the same cursor as its parent. A new cursor can be defined for the new window by calling XDefineCursor. The window will not be visible on the screen unless it and all of its ancestors are mapped and it is not obscured by any of its ancestors.

XCreateWindow can generate BadAlloc BadColor, BadCursor, BadMatch, BadPixmap, BadValue, and BadWindow errors.

The XCreateSimpleWindow function creates an unmapped InputOutput subwindow for a specified parent window, returns the window ID of the created window, and causes the X server to generate a CreateNotify event. The created window is placed on top in the stacking order with respect to siblings. Any part of the window that extends outside its parent window is clipped. The border_width for an InputOnly window must be zero, or a BadMatch error results. XCreateSimpleWindow inherits its depth, class, and visual from its parent. All other window attributes, except background and border, have their default values.

XCreateSimpleWindow can generate BadAlloc, BadMatch, BadValue, and BadWindow errors.


The XSetWindowAttributes structure contains:

/* Window attribute value mask bits */

/* Values */

typedef struct {

Pixmap background_pixmap;/* background, None, or ParentRelative */

unsigned long background_pixel;/* background pixel */

Pixmap border_pixmap;

/* border of the window or CopyFromParent */

unsigned long border_pixel;/* border pixel value */

int bit_gravity;

/* one of bit gravity values */

int win_gravity;

/* one of the window gravity values */

int backing_store;

/* NotUseful, WhenMapped, Always */

unsigned long backing_planes;/* planes to be preserved if possible */

unsigned long backing_pixel;/* value to use in restoring planes */

Bool save_under;

/* should bits under be saved? (popups) */

long event_mask;

/* set of events that should be saved */

long do_not_propagate_mask;/* set of events that should not propagate */

Bool override_redirect;

/* boolean value for override_redirect */

Colormap colormap;

/* color map to be associated with window */

Cursor cursor;

/* cursor to be displayed (or None) */

} XSetWindowAttributes;

For a detailed explanation of the members of this structure, see Xlib − C Language X Interface.



The server failed to allocate the requested resource or server memory.


A value for a Colormap argument does not name a defined Colormap.


A value for a Cursor argument does not name a defined Cursor.


The values do not exist for an InputOnly window.


Some argument or pair of arguments has the correct type and range but fails to match in some other way required by the request.


A value for a Pixmap argument does not name a defined Pixmap.


Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argument, the full range defined by the argument’s type is accepted. Any argument defined as a set of alternatives can generate this error.


A value for a Window argument does not name a defined Window.


XChangeWindowAttributes(3), XConfigureWindow(3), XDefineCursor(3), XDestroyWindow(3), XMapWindow(3), XRaiseWindow(3), XUnmapWindow(3)
Xlib − C Language X Interface

More Linux Commands

xdr_authunix_parms(3) - library routines for remote procedur
These routines allow C programs to make procedure calls on other machines across the network. First, the client calls a procedure to send a data packet to the s

gluNurbsSurface(3gl) - define the shape of a NURBS surface
Use gluNurbsSurface within a NURBS (Non-Uniform Rational B-Spline) surface definition to describe the shape of a NURBS surface (before any trimming). To mark th

sane-gt68xx(5) - SANE backend for GT-68XX based USB flatbed
The sane-gt68xx library implements a SANE (Scanner Access Now Easy) backend that provides access to USB flatbed scanners based on the Grandtech GT-6801 and GT-6

systemd-hostnamed.service(8) Host name bus mechanism........
systemd-hostnamed is a system service that may be used as a mechanism to change the systems hostname. systemd-hostnamed is automatically activated on request an

menu_request_name(3menu) - handle printable menu request nam
The function menu_request_name returns the printable name of a menu request code. The function menu_request_by_name searches in the name-table for a request wit

XSelectionRequestEvent(3) - SelectionRequest event structure
The structure for SelectionRequest events contains: typedef struct { int type; /* SelectionRequest */ unsigned long serial; /* # of last request processed by se

iwgetid(8) - Report ESSID, NWID or AP/Cell Address of wirele
iwgetid is used to find out the NWID, ESSID or AP/Cell Address of the wireless network that is currently used. The information reported is the same as the one s

CPU_AND_S(3) - macros for manipulating CPU sets (Man Page)
The cpu_set_t data structure represents a set of CPUs. CPU sets are used by sched_setaffinity(2) and similar interfaces. The cpu_set_t data type is implemented

curl_formadd(3) - add a section to a multipart/formdata HTTP
curl_formadd() is used to append sections when building a multipart/formdata HTTP POST (sometimes referred to as RFC2388-style posts). Append one section at a t

gnutls_certificate_get_issuer(3) - API function (Man Page)
This function will return the issuer of a given certificate. RETURNS On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a negative error value. SINCE 3.0.0

asn1_parser2array(3) - function that generates a C structure
Function that generates a C structure from an ASN1 file. Creates a file containing a C vector to use to manage the definitions included in inputFileName file. I

nexttoward(3) - floating-point number manipulation (ManPage)
The nextafter(), nextafterf(), and nextafterl() functions return the next representable floating-point value following x in the direction of y. If y is less tha

We can't live, work or learn in freedom unless the software we use is free.