1XCreateWindow(3) XLIB FUNCTIONS XCreateWindow(3)
2
3
4
6 XCreateWindow, XCreateSimpleWindow, XSetWindowAttributes - create win‐
7 dows and window attributes structure
8
10 Window XCreateWindow(Display *display, Window parent, int x, int y,
11 unsigned int width, unsigned int height, unsigned int bor‐
12 der_width, int depth, unsigned int class, Visual *visual,
13 unsigned long valuemask, XSetWindowAttributes *attributes);
14
15 Window XCreateSimpleWindow(Display *display, Window parent, int x, int
16 y, unsigned int width, unsigned int height, unsigned int bor‐
17 der_width, unsigned long border, unsigned long background);
18
20 attributes
21 Specifies the structure from which the values (as specified
22 by the value mask) are to be taken. The value mask should
23 have the appropriate bits set to indicate which attributes
24 have been set in the structure.
25
26 background
27 Specifies the background pixel value of the window.
28
29
30 border Specifies the border pixel value of the window.
31
32 border_width
33 Specifies the width of the created window's border in pixels.
34
35 class Specifies the created window's class. You can pass InputOut‐
36 put, InputOnly, or CopyFromParent. A class of CopyFromParent
37 means the class is taken from the parent.
38
39 depth Specifies the window's depth. A depth of CopyFromParent
40 means the depth is taken from the parent.
41
42 display Specifies the connection to the X server.
43
44 parent Specifies the parent window.
45
46 valuemask Specifies which window attributes are defined in the
47 attributes argument. This mask is the bitwise inclusive OR
48 of the valid attribute mask bits. If valuemask is zero, the
49 attributes are ignored and are not referenced.
50
51 visual Specifies the visual type. A visual of CopyFromParent means
52 the visual type is taken from the parent.
53
54 width
55 height Specify the width and height, which are the created window's
56 inside dimensions and do not include the created window's
57 borders.
58
59 x
60 y Specify the x and y coordinates, which are the top-left out‐
61 side corner of the window's borders and are relative to the
62 inside of the parent window's borders.
63
65 The XCreateWindow function creates an unmapped subwindow for a speci‐
66 fied parent window, returns the window ID of the created window, and
67 causes the X server to generate a CreateNotify event. The created win‐
68 dow is placed on top in the stacking order with respect to siblings.
69
70 The coordinate system has the X axis horizontal and the Y axis vertical
71 with the origin [0, 0] at the upper-left corner. Coordinates are inte‐
72 gral, in terms of pixels, and coincide with pixel centers. Each window
73 and pixmap has its own coordinate system. For a window, the origin is
74 inside the border at the inside, upper-left corner.
75
76 The border_width for an InputOnly window must be zero, or a BadMatch
77 error results. For class InputOutput, the visual type and depth must
78 be a combination supported for the screen, or a BadMatch error results.
79 The depth need not be the same as the parent, but the parent must not
80 be a window of class InputOnly, or a BadMatch error results. For an
81 InputOnly window, the depth must be zero, and the visual must be one
82 supported by the screen. If either condition is not met, a BadMatch
83 error results. The parent window, however, may have any depth and
84 class. If you specify any invalid window attribute for a window, a
85 BadMatch error results.
86
87 The created window is not yet displayed (mapped) on the user's display.
88 To display the window, call XMapWindow. The new window initially uses
89 the same cursor as its parent. A new cursor can be defined for the new
90 window by calling XDefineCursor. The window will not be visible on the
91 screen unless it and all of its ancestors are mapped and it is not
92 obscured by any of its ancestors.
93
94 XCreateWindow can generate BadAlloc BadColor, BadCursor, BadMatch, Bad‐
95 Pixmap, BadValue, and BadWindow errors.
96
97 The XCreateSimpleWindow function creates an unmapped InputOutput sub‐
98 window for a specified parent window, returns the window ID of the cre‐
99 ated window, and causes the X server to generate a CreateNotify event.
100 The created window is placed on top in the stacking order with respect
101 to siblings. Any part of the window that extends outside its parent
102 window is clipped. The border_width for an InputOnly window must be
103 zero, or a BadMatch error results. XCreateSimpleWindow inherits its
104 depth, class, and visual from its parent. All other window attributes,
105 except background and border, have their default values.
106
107 XCreateSimpleWindow can generate BadAlloc, BadMatch, BadValue, and Bad‐
108 Window errors.
109
111 The XSetWindowAttributes structure contains:
112
113 /* Window attribute value mask bits */
114
115 #define CWBackPixmap (1L<<0)
116 #define CWBackPixel (1L<<1)
117 #define CWBorderPixmap (1L<<2)
118 #define CWBorderPixel (1L<<3)
119 #define CWBitGravity (1L<<4)
120 #define CWWinGravity (1L<<5)
121 #define CWBackingStore (1L<<6)
122 #define CWBackingPlanes (1L<<7)
123 #define CWBackingPixel (1L<<8)
124 #define CWOverrideRedirect (1L<<9)
125 #define CWSaveUnder (1L<<10)
126 #define CWEventMask (1L<<11)
127 #define CWDontPropagate (1L<<12)
128 #define CWColormap (1L<<13)
129 #define CWCursor (1L<<14)
130 /* Values */
131
132 typedef struct {
133 Pixmap background_pixmap; /* background, None, or ParentRelative */
134 unsigned long background_pixel; /* background pixel */
135 Pixmap border_pixmap; /* border of the window or CopyFromParent */
136 unsigned long border_pixel; /* border pixel value */
137 int bit_gravity; /* one of bit gravity values */
138 int win_gravity; /* one of the window gravity values */
139 int backing_store; /* NotUseful, WhenMapped, Always */
140 unsigned long backing_planes; /* planes to be preserved if possible */
141 unsigned long backing_pixel; /* value to use in restoring planes */
142 Bool save_under; /* should bits under be saved? (popups) */
143 long event_mask; /* set of events that should be saved */
144 long do_not_propagate_mask; /* set of events that should not propagate */
145 Bool override_redirect; /* boolean value for override_redirect */
146 Colormap colormap; /* color map to be associated with window */
147 Cursor cursor; /* cursor to be displayed (or None) */
148 } XSetWindowAttributes;
149
150 For a detailed explanation of the members of this structure, see Xlib -
151 C Language X Interface.
152
154 BadAlloc The server failed to allocate the requested resource or
155 server memory.
156
157 BadColor A value for a Colormap argument does not name a defined Col‐
158 ormap.
159
160 BadCursor A value for a Cursor argument does not name a defined Cursor.
161
162 BadMatch The values do not exist for an InputOnly window.
163
164 BadMatch Some argument or pair of arguments has the correct type and
165 range but fails to match in some other way required by the
166 request.
167
168 BadPixmap A value for a Pixmap argument does not name a defined Pixmap.
169
170 BadValue Some numeric value falls outside the range of values accepted
171 by the request. Unless a specific range is specified for an
172 argument, the full range defined by the argument's type is
173 accepted. Any argument defined as a set of alternatives can
174 generate this error.
175
176 BadWindow A value for a Window argument does not name a defined Window.
177
179 XChangeWindowAttributes(3), XConfigureWindow(3), XDefineCursor(3), XDe‐
180 stroyWindow(3), XMapWindow(3), XRaiseWindow(3), XUnmapWindow(3)
181 Xlib - C Language X Interface
182
183
184
185X Version 11 libX11 1.6.4 XCreateWindow(3)