This appendix provides a brief overview of library routines that developers may need in order to make applications work on a Dual Head system. For more information about the routines mentioned, see the appropriate man pages.
Note that once you open a window on a given head, the user cannot move it to the other head via the window manager; if you want users to be able to move windows from one head to another, your program must explicitly close the old window and open a new one on the other head.
OpenGL, X, and mixed-model IRIS GL, and all use X calls to choose on which screen to display; just pass the name of the desired display as the argument to XOpenDisplay(3X11). (Pass NULL as the display name if you want to default to the value of the DISPLAY environment variable.) You can then call RootWindow(3X11) with the newly opened display, specifying whichever screen you want; then call XCreateWindow(3X11) to create a window on the specified screen. After that, use the usual OpenGL or X calls, as appropriate, to draw or display in the window.
This is the syntax for XOpenDisplay():
Display *XOpenDisplay(display_name)
char *display_name;
|
For example, use the following code example to open a window on each head of a Dual Head system:
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
void main(argc, argv)
int argc;
char **argv;
{
Display *display;
Window root0, root1, win0, win1;
/* Open the display specified in the DISPLAY variable. */
if ( (display = XOpenDisplay("")) == NULL )
fprintf(stderr, "%s: cannot connect to X server.\n",
argv[0]);
/* Set up a root window for each screen. */
root0 = RootWindow(display, 0);
root1 = RootWindow(display, 1);
/* Now create a window on each screen. */
win0 = XCreateSimpleWindow(display, root0, 0, 0, 100,
100, 0, 0, 0);
win1 = XCreateSimpleWindow(display, root1, 0, 0, 100,
100, 0, 0, 0);
/* Display the windows and flush the output buffer. */
XMapWindow(display, win0);
XMapWindow(display, win1);
XFlush(display);
/* Leave them up for ten seconds before exiting. */
sleep(10);
}
|
Under IRIS GL, you select a head on which to run a window by using the scrnselect(3G) function. If you do not call scrnselect() before opening a window using winopen(3G), the window opens on whichever screen the user has specified in the DISPLAY environment variable.
This is the syntax for scrnselect():
long scrnselect(gsnr)
long gsnr;
|
where gsnr is the screen number relative to the current server—that is, 0 for screen :0.0 or 1 for :0.1.
If you include system configuration files such as /usr/lib/X11/xdm/Xservers with your application, you may want to configure the layout of the heads, specifying which is on the left and which on the right. For information on how to specify adjacency, see the Xsgi reference page, under the –hw option, or Chapter 3, “Installing the Software and Using the Dual Head System”, in this guide.