Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!hp-pcd!hpfcso!hpfcdq!brown From: brown@hpfcdq.HP.COM (John Brown) Newsgroups: comp.sys.hp Subject: Re: xwcreate question Message-ID: <17330030@hpfcdq.HP.COM> Date: 7 Apr 91 23:41:50 GMT References: <1991Apr04.141312.10371@eye.com> Organization: Hewlett-Packard - Fort Collins, CO Lines: 189 Dan Loewus writes . . . > The xwcreate app creates a graphic window that can be used by starbase. > When running X11 in combine mode on a hp98731 and executing xwcreate > with a depth of 24 ( xwcreate graphwin -depth 24 ) two windows are > created, the first being a transparent window in the overlay planes > and the second being the 24 depth window in the image planes ( correct > me if this is wrong ). My question is how come the transparent window > is needed? The server itself doesn't automatically create two windows. However, if you're running a reparenting window manager (like mwm) then the window manager will indeed create additional windows associated with the window of interest. If you're running the server in combined mode these windows will reside in the overlay planes. One of these windows would directly obscure (overlay) the image plane window, and so it must be "transparent" in order that you can see the image data beneath it. I'm sure one of the X server guru-folk could give you a more technical and accurate answer -- perhaps one of them will also respond. > A followup question is how can I create my own 24 depth window using > XCreateWindow with DirectColor? Do I also need a transparent window? I've attached a sample program which opens a 24-bit window. It is not necessary to create a special transparent window (the window manager will do that for you :-) Hope this helps! John Brown Graphics Technology Division Fort Collins, CO This response does not represent the official position of, or statement by, the Hewlett-Packard Company. The above data is provided for informational purposes only. It is supplied without warranty of any kind. ================================== cut here ================================== #include #include #include #include /* Sample program to illustrate how to create a 24-bit X window and then gopen it with Starbase. If running on 8.0 or greater, use shared libraries and compile as: cc -o 24bit 24bit.c -DHPUX_80 -L/usr/lib/X11R4 -lXwindow \ -lsb -ldld -lXhp11 -lX11 -lm If running on pre-8.0, compile as (where xxxx is the driver for your display device, e.g. 98731): cc -o 24bit 24bit.c -lddxxxx -lXwindow -lsb1 -lsb2 -lXhp11 -lX11 -lm To run the program on an 8.0 or greater system, simply invoke as "24bit". If running on pre-8.0, either set the SB_OUTDRIVER environment variable first, or invoke as "24bit drivername" (where drivername is the appropriate driver name for your device, e.g. hp98731). ****************************************************************** * This program does not represent the official position of, * * or statement by, the Hewlett-Packard Company. This program * * is provided for informational purposes only. It is supplied * * without warranty of any kind. * ****************************************************************** */ main(argc, argv) int argc; char *argv[]; { Display *display; int screen, fildes; XVisualInfo my_visualinfo; Visual *my_visual; XSetWindowAttributes my_attributes; Window my_window; Colormap my_colormap; XEvent my_event; char *device, *driver, reply[80]; /* Open the X display */ if ( (display = XOpenDisplay(NULL)) == NULL ) { printf("ERROR: Could not open the X display.\n"); printf(" Check the DISPLAY environment variable.\n"); exit(-1); } screen = DefaultScreen( display ); /* Then, see if the desired visual exists. Although this sample program checks specifically for the 24-bit visual, a well-behaved application should really be willing to use other visuals if it can't find the ideal one. */ if ( XMatchVisualInfo(display,screen,24,DirectColor,&my_visualinfo) ) { my_visual = my_visualinfo.visual; } else { printf("ERROR: Could not create a 24-bit DirectColor window.\n"); exit(-1); } /* Next, it is necessary to create a colormap for the window */ my_colormap = XCreateColormap( display, RootWindow(display,screen), my_visual, AllocAll ); /* Finally, we need to specify a few other window attributes so that we can successfully create the 24-bit window */ my_attributes.colormap = my_colormap; my_attributes.border_pixel = 0; my_attributes.background_pixel = 0; my_window = XCreateWindow( display, RootWindow(display,screen), 10,10, 1024, 800, 0, 24, InputOutput, my_visual, CWBorderPixel|CWColormap|CWBackPixel, &my_attributes ); /* Map the window, and wait for the map to occur */ XSelectInput(display, my_window, ExposureMask | StructureNotifyMask ); XMapWindow( display, my_window ); XWindowEvent( display, my_window, ExposureMask, &my_event ); /* Create a device string for a Starbase gopen */ device = make_X11_gopen_string( display, my_window ); /* Now, do the actual gopen. Notice that, beginning with 8.0 (including the initial release on the s700) the actual driver name can be replaced with NULL and the gopen is smart enough to determine the correct driver name. */ #ifdef HPUX_80 /* We're being complied for 8.0 or greater */ fildes = gopen( device, OUTDEV, NULL, INIT ); #else /* We must be on a pre-8.0 system. Try to get the drivername from the arg list if possible, then look for the env var if not in the arg list */ if ( argc > 1 ) driver = argv[1]; else driver = (char *) getenv("SB_OUTDRIVER"); fildes = gopen( device, OUTDEV, driver, INIT ); #endif /* Check to verify that we did indeed open the device correctly. */ if ( fildes >= 0 ) { /* Let the user know about the gopen */ printf("gopen was successful . . . clearing window to red\n"); /* Clear the window to red just to show that we did open it */ shade_mode( fildes, CMAP_FULL|INIT, FALSE ); background_color( fildes, 1.0, 0.0, 0.0 ); clear_view_surface( fildes ); make_picture_current( fildes ); printf("Hit return when finished viewing . . ."); gets( reply ); gclose( fildes ); } else { /* Let the user know about the failure */ printf("ERROR: Could not gopen window with driver '%s'\n", driver ); exit( -1 ); } } /* end of main */