SGI's migration to X

Gretchen Helms ghelms at sgi.com
Sat Sep 1 05:34:17 AEST 1990


(Tim Moore) writes:
>(Steve Lehar) writes:
>Like the man said, see XSetWMNormalHints.
>
>>
>>  win = XCreateWindow(display, RootWindow(display, screen),
>>                      xsh.x, xsh.y, xsh.width, xsh.height,
>>                      bw, vTemplate.depth, InputOutput, visual,
>>                      valuemask, &attrib);
>>
>>Note that there is no argument for x and y screen location!  How do I
>>tell this XWindow where to appear?
>
>It is true that you can't specify with certainty where your window
>will end up on the screen. The rationale for this is that your window
>manager might have a different idea about where the newly created
>window should go. Hence, you give the window manager "hints".

As an example, please consider the following code.
This code will place the window correctly if you
are either executing it under 4Sight, or if you 
execute it under UWM.   My apologies for the not-so-hot
commenting, I haven't gotten to the full comments on
this one yet.

----------------------mangle here-----------------------
/*	6/11/90	G. "Murdock" Helms, SGI Product Support
 *	
 *  First run:  This file is a sample X program designed to
 *  show how to start up a basic X window in a specified position.
 */


#include <X11/Xlib.h>		 /* Xlib include files */
#include <X11/Xutil.h>		 /* Must have these included */
#include <stdio.h> 	 	 /* have to include this to know about NULL */

/* Display and screen are used as arguments to nearly every Xlib
 * routine, so it simplifies things to declare them global. */

Display *display;
int screen;

main()
{
    Window win, rootwin;
    XSizeHints sizehints;
    char *window_name = "Placed Window";
    char *icon_name = "bwin";
    char *display_name = NULL;
    int x=100,y=100;
    unsigned int width=400, height=400;

/* Connect to  X server ... this is kind of a fancy test to make
 * sure the server is running, but it produces a nicer error code
 * than you normally get. */


    if ( (display=XOpenDisplay(display_name)) == NULL )
    {
	fprintf( stderr, "bwin: cannot connect to X server %s,",
			XDisplayName(display_name));
	fprintf( stderr, "did you remember to set the DISPLAY?\n");
        exit ( -1 );
    }

    /* Get screen from display structure macro */
    screen = DefaultScreen(display);

    /* Create opaque window ... note that BlackPixel and WhitePixel
     * are macros.
     */

    rootwin = RootWindow(display, screen);
    win = XCreateSimpleWindow (display, rootwin, x, y, width, height, 5,
	    BlackPixel(display, screen),
	    WhitePixel(display, screen));

    sizehints.flags=USPosition;             /* so it can be either/or */
        sizehints.x=x;                      /* this is part of XSizeHints */
        sizehints.y=y;                      /* see manual on structure of */

    /* Set properties for window manager (always before mapping!)  */
    XSetStandardProperties(display, win, window_name, icon_name, None,
	    0, 0, &sizehints); 
    
    /* Display window */
    XMapWindow(display, win);

    XFlush(display); 

    while (1) {}		/* loopity loop */
}                  		/* end main   */
-------------------------------mangle here---------------

--
G. "Murdock" Helms				Is it so frightening	
Silicon Graphics				to have me at your shoulder?
Product Support Engineer			Thunder and lightning
ghelms at sgi.sgi.com				couldn't be bolder.



More information about the Comp.sys.sgi mailing list