XCreateWindow(3X) XCreateWindow(3X)
NAME
XCreateWindow, XCreateSimpleWindow - create windows and
manipulate the XSetWindowAttributes structure
SYNOPSIS
Window XCreateWindow (display, parent, x, y, width, height,
border-width, depth, class, visual, valuemask,
attributes)
Display *display;
Window parent;
int x,y;
unsigned int width,height;
unsigned int border-width;
int depth;
unsigned int class;
Visual *visual
unsigned long valuemask;
XSetWindowAttributes *attributes;
Window XCreateSimpleWindow (display, parent, x, y, width,
height, border-width, border, background)
Display *display;
Window parent;
int x,y;
unsigned int width,height,border-width
unsigned long border;
unsigned long background;
DESCRIPTION
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 sibling stacking order. The border-width for an InputOn-
ly window must be 0, or a BadMatch error results.
For class InputOutput, visual and depth must be a combina-
tion 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, depth must be 0, and 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
November, 1990 1
XCreateWindow(3X) XCreateWindow(3X)
unless it and all of its ancestors are mapped and it is not
obscured by any of its ancestors.
The XCreateSimpleWindow function creates an unmapped Inpu-
tOutput 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 0,
or a BadMatch error results. The XCreateSimpleWindow func-
tion inherits its depth, class, and visual from its parent.
All other window attributes, except background and border,
have their default values.
Arguments
These functions accept the following arguments:
attributes
Specifies the structure from which the values (as
specified by the value mask) are to be taken. The
values of this structure are used to set the attri-
butes of a window at creation time. The valuemask
should have the appropriate bits set to indicate
which attributes have been set in the structure.
background
Specifies the window's background pixel value.
border Specifies the window's border pixel value.
border-width
Specifies, in pixels, the width of the created
window's border. The border-width for an InputOnly
window must be 0. Otherwise, a BadMatch error is
returned.
2 November, 1990
XCreateWindow(3X) XCreateWindow(3X)
class Specifies the created window's class. One of the
following constants can be passed: InputOutput,
InputOnly, or CopyFromParent. A class of CopyFrom-
Parent means the class is taken from the parent.
depth Specifies the window's depth. A depth of 0 for
class CopyFromParent or InputOutput means the depth
is taken from the parent.
display Specifies the connection to the X server.
parent Specifies the parent window ID.
valuemask
Specifies which window attributes are defined in the
attributes argument. This mask is the bitwise in-
clusive OR of the valid attribute mask bits. If
valuemask is 0, the attributes are ignored and are
not referenced.
visual Specifies the visual type. A visual of
CopyFromParent means the visual type is taken from
the parent.
width, height
Specify the width and height, which are the created
window's inside dimensions and do not include the
created window's borders.
x, y 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 bord-
ers.
Structures
The XSetWindow Attributes structure is defined as follows.
/* Window attribute value mask bits */
#define CWBackPixmap(1L<<0)
#define CWBackPixel(1L<<1)
#define CWBorderPixmap(1L<<2)
#define CWBorderPixel(1L<<3)
#define CWBitGravity(1L<<4)
#define CWWinGravity(1L<<5)
#define CWBackingStore(1L<<6)
#define CWBackingPlanes(1L<<7)
#define CWBackingPixel(1L<<8)
#define CWOverrideRedirect(1L<<9)
#define CWSaveUnder(1L<<10)
#define CWEventMask(1L<<11)
#define CWDontPropagate(1L<<12)
#define CWColormap(1L<<13)
November, 1990 3
XCreateWindow(3X) XCreateWindow(3X)
#define CWCursor (1L<<14)
/* 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; /* colormap to be */
/* associated with */
/* window */
4 November, 1990
XCreateWindow(3X) XCreateWindow(3X)
Cursor cursor; /* cursor to be */
/* displayed */
/* (or None) */
} XSetWindowAttributes;
For a detailed explanation of the members of this structure,
see Xlib - C Language Interface.
ERRORS
BadAlloc
The server failed to allocate the requested resource
or server memory.
BadColor
A value for a Colormap argument does not name a de-
fined colormap.
BadCursor
A value for a Cursor argument does not name a de-
fined pointer.
BadMatch
The values do not exist for an InputOnly window; or,
an argument or pair of arguments has the correct
type and range but fails to match in some other re-
quired way.
BadPixmap
A value for a Pixmap argument does not name a de-
fined pixel map.
BadValue
A numeric value falls outside the range of values
accepted by the request. Unless a range is speci-
fied 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.
BadWindow
A value for a Window argument does not name a de-
fined window.
The XCreateWindow function can generate BadAlloc,
BadColor, BadCursor, BadMatch, BadPixmap,
BadValue, and BadWindow errors.
The XCreateSimpleWindow function can generate
BadAlloc, BadMatch, BadValue, and BadWindow errors.
SEE ALSO
XChangeWindowAttributes(3X),
XConfigureWindow(3X), XDefineCursor(3X), XDestroyWindow(3X),
November, 1990 5
XMapWindow(3X), XRaiseWindow(3X),
XUnmapWindow(3X)
Xlib - C Language Interface
6 November, 1990