HPlogo Using the X Window System > Chapter 11 Using Graphics With X Windows

Window-Smart and Window-Naive Programs

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

Window-smart applications are able to create and destroy the windows in which they operate.

Window-naive (sometimes called window-dumb) applications aren't able to create and destroy windows on their own. They need help from the X Window System.

Is My Application Window-Smart or Window-Naive?

If you are using an existing application, the documentation that comes with the application will tell you how to start it. You don't have to worry whether it is window-smart or window-naive, just follow the directions.

If you are writing a new application using Starbase, use the xwcreate and xwdestroy commands. Rather than typing the commands each time you want to test the new program, put the commands in a file, then execute the file to start the application. In this case, the application is window-naive but the file is window-smart.

Running Window-Smart Programs

From an hpterm window, type the name of the program you want to run.

For example, the following command will start a hypothetical Starbase application named planetarium that displays a moving view of the night sky. Assume that the program is in the /home/ellen/funstuff directory on your computer.

/home/ellen/funstuff/planetarium Return

Running Window-Naive Programs

Window-naive programs cannot open and close the window they need to run in, so you must do it for them with clients (a terminal emulator, for example). Some old programs that use the Starbase graphics library are window-naive.

Most window-naive programs are able to run in the X Window System environment using the sox11 device driver. The sox11 driver is described in the Starbase Device Drivers manual. But window-naive clients still need help to create and destroy the windows they display their output in.

To enable window-naive graphics programs to run within X, you need four special helper clients to create and destroy the windows used by the naive graphics programs. The clients are:

  • gwind

  • xwcreate

  • xwdestroy

  • gwindstop

gwind runs in the background and services requests from the other three helper clients. When requested by xwcreate, gwind creates a window in which an application can display its output; when requested by xwdestroy, gwind destroys the window. You don't need to start the gwind program, xwcreate and xwdestroy start and stop it for you.

The next sections cover:

  • Creating a window

  • Destroying a window

Creating a Window with `xwcreate'

xwcreate requests gwind to create a window for a window-naive graphics program to use for its output. The graphics program must exist on the same computer that is running xwcreate. If gwind is not already running when xwcreate is executed, xwcreate will start gwind. Once xwcreate has created a window, you can use the window to run your graphics program. When you finish that application, you can use the same window to run another graphics program if you wish.

Use xwcreate from the command line.

xwcreate [options]

where:

-display host:display.screen

Specifies the screen the window will appear on

-parent parent

Names a window to be the parent of the window being created.

-geometry width×height±col±row

Specifies desired size and location of window.

-r

Specifies backing store. Default is no backing store.

-bg color

Specifies the background color. The default is black.

-bw pixels

Specifies the border width in pixels. The default is 3 pixels wide.

-bd color

Specifies the border color. The default is white.

-depth depth

Specifies the depth of the window. The default is the same depth as its parent.

-visual visualclass

Specifies the visual class of the window when multiple visual classes are supported by the display at the specified depth.

-overlay

Specifies that an overlay plane visual should be used.

-wmdir directory

Specifies the name of the directory containing the pty file for the window.

-title name

Specifies the name the window will be called.

The depth option is where you tell the window manager what set of planes you want the window to be in. If you specify nothing, the window is created with the same depth as its parent, or with the same depth as the root if no parent is specified. If you specify a depth, the window will be placed in the image plane with the depth (number of color planes) you specify.

The following example creates a window named "foo":

xwcreate -title foo Return

Destroying a Window with `xwdestroy'

xwdestroy destroys the window created by xwcreate. If that window is the only graphics window present at that time, gwind will also terminate.

Use xwdestroy from the command line.

xwdestroy [-wmdir path/directory] window1 window2 ...

where:

-wmdir

Specifies the directory containing the pty file for the window.

window

Specifies the window or windows to be destroyed.

The following example will destroy a window named "foo":

xwdestroy foo

Destroying a Window with `gwindstop'

gwindstop destroys all windows created by gwind in the specified directory. If, however, you use xwdestroy to remove the last window opened for graphics use, xwdestroy will terminate gwind. You do not need to use gwindstop.

CAUTION: You must use xwdestroy or gwindstop to get rid of a window after you have finished running your graphics application. Do not use kill to remove the gwind process associated with the window. If you should accidentally do so, you must type the command rm $WMDIR/wm. Failure to do this will result in xwcreate not running the next time you call it.

Use gwindstop from the command line.

gwindstop [directory] [directory] ...  
directory

The directory containing the pty files for the windows to be destroyed.

© 1995 Hewlett-Packard Development Company, L.P.