15.11 Porting Programs to X

Any program that runs on an ASCII terminal can be run directly under the terminal emulator xterm. The only problem is how to deal with changing the size of the window while the application is running. The application may read the termcap definition to determine the original window size. Look at the X application resize, which makes changes to TERMCAP. The resize reference page (see Volume Three,X Window System User’s Guide) suggests a couple of C shell aliases for commands to resize xterm windows.

If you have a Berkeley 4.3-compatible tty driver, xterm sets the tty driver’s row and column attributes when its top-level window is resized. vi and more and several other programs also look at those attributes when figuring out the terminal size. Also, xterm will send a SIGWINCH signal to the controlling process, which, if it is vi or more, will understand this signal and change its own notion of screen size, repainting the window in the process. This is the best way to deal with window resizing under xterm.

Graphics programs face a more difficult porting path. They must be rewritten to use the X library. It is a good idea to use a toolkit rather than trying to write completely in Xlib.

Programs written for single-user systems such as PCs will be a little more difficult, since they must be converted to respond to events instead of asking for one type of input at a time. They must also be modified to work in a multitasking environment.

Byte order is another traditionally ...

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.