dan@eye.com (Dan Loewus) (04/04/91)
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? A followup question is how can I create my own 24 depth window using XCreateWindow with DirectColor? Do I also need a transparent window? "A typical half brick half wood New York house in a typical New York suburb with ginkgo trees scattered conservatively about." DL (dan@eye.com)
brown@hpfcdq.HP.COM (John Brown) (04/08/91)
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 <stdio.h> #include <starbase.c.h> #include <X11/Xlib.h> #include <X11/Xutil.h> /* 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 */
harry@hpcvlx.cv.hp.com (Harry Phinney) (04/10/91)
Dan Loewus writes . . . > 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? I'm not intimately familiar with xwcreate. It should not need to create any extra windows if the server is in combined mode. John Brown writes: > 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. This is basically correct, although it should be stressed that the client(s) do not need to do anything special to make this work. Also, the window created by the window manager is not really made transparent. This window is simply logically obscured, and so is not drawn. When the server is running in "combined" mode there is no need (nor, I believe, any means) for any client to create a transparent window. While a reparenting window manager will indeed create additional windows, they will not obscure the image plane window they are associated with. The window manager's window(s) will be logically "behind" the image window, and the X server will insure that the image window is visible. The server does this by "painting" the overlay planes "transparent" over the visible portions of the image window. The server does this painting whenever the configuration (size, location, stacking order, etc) of the windows changes. The combined-mode servers simply "know" enough to clear the overlay planes in the visible regions of any image plane windows. You can view this as an image plane window "owning" all the planes, including overlays, within its visible regions. > It is not > necessary to create a special transparent window (the window manager > will do that for you :-) Again, in combined mode neither the window manager nor the server have to create a transparent window. The server only needs to remember to "clear" the overlays anywhere the image-plane window is visible. Harry Phinney harry@hp-pcd.cv.hp.com