@begin(header)
author: ackerman=ag@ics.uci.edu
show_author: ShowNone
author_organization: MIT
node_expert: ackerman=ag@ics.uci.edu 
expiration_date: 10/10/93
last_modifier: ackerman=ag@ics.uci.edu
last_mod_date: 10/10/91
mod_num: 1
@end(header)
-----------------
Creating a Window
-----------------

Windows are the coin of the realm in X.  After all, it is the X *Window* System,
right?  That means that windows are created everywhere and for any occasion.

To create a window at the Xlib level, use:

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

The most obvious problem with using this routine is that it requires a window.  You
may wonder, "But, I'm trying to create my first window.  Where am I going to get a
previously existing window from?"  Answer:  Use the RootWindow, which is always
available.  (This works as long as you are not on a variable-depth or a
variable-visual display.  See the visual and color tutorials for more information.)

So, some sample code might be:

	Window win;
	int scr;

	scr = DefaultScreen(the_display);

	win = XCreateSimpleWindow(the_display,DefaultRootWindow(the_display),
				  0,0,100,100,
				  1,
				  BlackPixel(the_display,scr),
				  WhitePixel(the_display,scr));

where the_display was returned from an XOpenDisplay call previously.  This
creates a window at screen location (0,0), a height of 100 and a width of 100, a
border width of 1, a black border, and a white background (interior).

Because of the interaction with the window manager, your window may or may not
appear at (0,0).  Moreover, not only is it possible with some window managers
to position the window when it is first created, some window managers will
even allow the user to resize it when created.  In any case, your code
should be prepared to not be the size nor be at the position you specified.

If this doesn't answer your questions about creating a window, please click
on the "I'm Unhappy" button below and ask your question. 
