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, un‐
11 signed int width, unsigned int height, unsigned int bor‐
12 der_width, int depth, unsigned int class, Visual *visual, un‐
13 signed 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 at‐
47 tributes argument. This mask is the bitwise inclusive OR of
48 the valid attribute mask bits. If valuemask is zero, the at‐
49 tributes 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 ob‐
92 scured 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 #de‐ CWBackPixmap (1L<<0)
116 fine
117 #de‐ CWBackPixel (1L<<1)
118 fine
119 #de‐ CWBorderPixmap (1L<<2)
120 fine
121 #de‐ CWBorderPixel (1L<<3)
122 fine
123 #de‐ CWBitGravity (1L<<4)
124 fine
125 #de‐ CWWinGravity (1L<<5)
126 fine
127 #de‐ CWBackingStore (1L<<6)
128 fine
129 #de‐ CWBackingPlanes (1L<<7)
130 fine
131
132
133 #de‐ CWBackingPixel (1L<<8)
134 fine
135 #de‐ CWOverrideRedirect (1L<<9)
136 fine
137 #de‐ CWSaveUnder (1L<<10)
138 fine
139 #de‐ CWEventMask (1L<<11)
140 fine
141 #de‐ CWDontPropagate (1L<<12)
142 fine
143 #de‐ CWColormap (1L<<13)
144 fine
145 #de‐ CWCursor (1L<<14)
146 fine
147 /* Values */
148
149 typedef struct {
150 Pixmap background_pixmap; /* background, None, or ParentRelative */
151 unsigned long background_pixel; /* background pixel */
152 Pixmap border_pixmap; /* border of the window or CopyFromParent */
153 unsigned long border_pixel; /* border pixel value */
154 int bit_gravity; /* one of bit gravity values */
155 int win_gravity; /* one of the window gravity values */
156 int backing_store; /* NotUseful, WhenMapped, Always */
157 unsigned long backing_planes; /* planes to be preserved if possible */
158 unsigned long backing_pixel; /* value to use in restoring planes */
159 Bool save_under; /* should bits under be saved? (popups) */
160 long event_mask; /* set of events that should be saved */
161 long do_not_propagate_mask; /* set of events that should not propagate */
162 Bool override_redirect; /* boolean value for override_redirect */
163 Colormap colormap; /* color map to be associated with window */
164 Cursor cursor; /* cursor to be displayed (or None) */
165 } XSetWindowAttributes;
166
167 For a detailed explanation of the members of this structure, see Xlib -
168 C Language X Interface.
169
171 BadAlloc The server failed to allocate the requested resource or
172 server memory.
173
174 BadColor A value for a Colormap argument does not name a defined Col‐
175 ormap.
176
177 BadCursor A value for a Cursor argument does not name a defined Cursor.
178
179 BadMatch The values do not exist for an InputOnly window.
180
181 BadMatch Some argument or pair of arguments has the correct type and
182 range but fails to match in some other way required by the
183 request.
184
185 BadPixmap A value for a Pixmap argument does not name a defined Pixmap.
186
187 BadValue Some numeric value falls outside the range of values accepted
188 by the request. Unless a specific range is specified for an
189 argument, the full range defined by the argument's type is
190 accepted. Any argument defined as a set of alternatives can
191 generate this error.
192
193 BadWindow A value for a Window argument does not name a defined Window.
194
196 XChangeWindowAttributes(3), XConfigureWindow(3), XDefineCursor(3), XDe‐
197 stroyWindow(3), XMapWindow(3), XRaiseWindow(3), XUnmapWindow(3)
198 Xlib - C Language X Interface
199
200
201
202X Version 11 libX11 1.7.3.1 XCreateWindow(3)