## 2.5. Working with Windows

A window manager program helps you control windows. Various window managers do the same kinds of things, with some variation. Let's start by looking at Figure 2-4, which shows a typical window under KDE and kwm.

The edges of the window can be used to resize the window. The top of every window has a titlebar that includes the window title as well as three buttons.

### 2.5.1. Using the Titlebar

The titlebar is the top of a window; it has the window's title, and, usually, some buttons or other features. See Figure 2-4.

#### Figure 2-4. A window under KDE and kwm

The three buttons at the top right corner have boxes inside them.

- Click the button with the small square to mimimize the window (make the window as small as possible); this is also called "hiding" the window. With some window manager configurations, a minimized window turns into an icon; on others, the window may have a title button in a list of window buttons at the bottom of a window (or elsewhere). No matter how your window manager treats a minimized window, though, the important point here is that minimizing puts unneeded windows out of the way without quitting the program inside them; it also keeps you from accidentally typing into a window.

  You can restore ("show") a minimized ("hidden") window by clicking on its icon, its button on the panel at the bottom of the screen, or in several other ways--again, depending on your window manager.

- Maximizing a window makes it as big as the program will allow, often as big as the screen. One way to do this--which is different in different window managers, of course--is to click the button on the window frame that has a large square.

  Maximizing windows that have graphical applications in them--such as a web browser--works just fine. But it can be a bad idea to maximize terminal windows (and give them more than 80 characters per line), especially if there's a program running in that window. See the note in Section 2.5.3, later in this chapter.

- Clicking the box with a big "X" kills a window. In some window managers, clicking with the third mouse button is a more emphatic kill. (Later in this chapter, Section 2.7 describes this in more detail.)

> NOTE: It's not always a good idea to click the "X" box on a window frame--especially on a terminal window with a program running inside. Although it may seem to work (because the window closes), the programs running inside the window may not have time to finish their work and exit gracefully.

> It's safer to use the program's own "exit" command. For instance, if you're running the Pico editor in a terminal window, use its CTRL-X command. If you have a shell prompt, type exit or press CTRL-D; if the program has a menu or button with which to quit, use it. If there's no other choice, though, you're probably safe to click the "X" box on the frame.

The left button opens the window menu; this is explained in Section 2.5.5 later in this chapter.

### 2.5.2. Moving Windows and Icons

To move a window, start by pointing to the titlebar. Hold down the first mouse button and drag to the new location--then let go of the button.

### 2.5.3. Resizing Windows

If you have the pointer inside a window and then move the pointer to an edge, the pointer will probably change to another shape--an arrow, for example. If you point to a corner, you may be able to resize both sides that meet at the corner. To resize when you have the arrow pointer, press and hold (typically) the first button, then drag the window border until the window size is what you want and release the button. If you don't get quite the size you want, just do it again.

> NOTE: If you're using a terminal window (such as xterm), and a program is already running in that window (not just a shell prompt), note that resizing the window may confuse the programs currently running in it! It's best to set the terminal window size before you run a program.

> Also, remember that standard terminals are 80 characters wide. If you're editing text in a window with a width that isn't 80 characters, it can cause trouble later when the file is viewed on a standard terminal.

### 2.5.4. Stacking Windows

You can have many windows open at once. To get some or all out of the way, minimize them. Sometimes, though, you'll want several overlapping windows on your screen:

- You could log onto the Internet, go to your favorite news website and open ten windows, each with an article you want to read. Then log off the Internet (to free your phone line) and read each window. In that case, it might be easiest to have the ten windows in a stack, and close each window after you're done--instead of minimizing all windows at the start and restoring them, one by one, as you read them.

- You might need several windows visible at the same time--for instance, reading email messages in one window while you edit a presentation in another window, with a web browser open to a company information page in a third window. You may not need to shrink windows to keep them from overlapping. Instead, windows can partly overlap, covering areas of other windows that you don't need to see.

  In X, a window doesn't always need to be on top of the stack to get the input focus (so you can type into it). If you've configured your window manager so the window with the mouse pointer over it gets the focus automatically (without clicking on the window), you can type in a window without raising it to the top of the stack. This is a handy feature of most X window managers.

To bring a window to the top, you can generally either click on its title bar with the first mouse button or use the window manager's "raise window" command. That "raise window" command is usually either on the window menu (see the following section), on a window manager menu (choose "raise window," then click on the window you want to raise), or it might be found by clicking on the window frame with the third mouse button. In the same way, your window manager probably has a "lower window" command that moves a window behind the windows it overlaps.

### 2.5.5. The Window Menu

Many window managers let you control each window by its own window menu. There are lots of ways to get a window menu. Here are two: click on the menu button at the top left corner of a frame (as in Figure 2-4, for KDE and the kwm window manager), or click on an icon (for the mwm window manager). Figure 2-5 shows a window menu from the Sawfish window manager. When the menu pops up, you can point to an item and click it.

Let's look at some of the Sawfish window menu operations:

- The Minimize and Maximize operations are explained in "Using the Titlebar," earlier in this chapter.

- Close terminates the window and the program in it. Use this as a last resort. If the program has a separate menu or quit command (for example, entering exit at a shell prompt in a terminal window), use it instead of Close. (See "Quitting," later in this chapter, for an explanation.)

- Send window to lets you move a window to another virtual desktop. When you point to this item, a submenu appears with a list of desktops where the window can be moved.

- Stacking opens a submenu that lets you control this window's position in a stack of windows.

- History opens a submenu that tells the window manager how to handle this particular type of window in the future. For example, the window menu in Figure 2-5 happens to be on a GNOME Terminal window. If you have the GNOME Terminal window at a particular spot near the lower-left corner of the desktop, and you choose the Remember position entry on this submenu, then the next GNOME Terminal window you open will open at the same place on the desktop. (Once a window has opened in this particular spot, you can always move it somewhere else.) The Forget saved state entry tells the window manager to forget all of the History settings you've made for this type of window.

#### Figure 2-5. A Sawfish window menu

On the mwm menu (not shown here), a keyboard shortcut follows each command. Other window managers may have keyboard shortcuts but not list them on the menu (they could be listed on a configuration menu somewhere else). With a shortcut, you don't have to use the mouse to choose commands; you can handle window operations without taking your hands off the keyboard. For example, next to the Minimize entry is the shortcut hint "Alt+F9", which means that you can minimize this window without a mouse by holding down the ALT (or META) key and pressing the F9 key. Holding the SHIFT key and pressing the ESC key brings up an mwm window menu (and takes it away). If your keyboard doesn't have all of those keys, the menu can probably be customized to use others. Other window managers may have different keyboard shortcuts--or none at all.

### 2.5.5.1. Exercise

If you don't have two terminal windows open from the previous exercise, please start by opening them.

Copy and paste part of a command line. | Type `who am i;date` and press RETURN in one terminal window. Highlight the `who am i`, set focus to the other terminal window, paste the command there, and run it.
Move a window. | Grab and drag the window by its titlebar.
Iconify a window from the titlebar. | Use the Mimimize button.
Restore (de-iconify) the window. | Find the window's Restore command.

Copyright © 2003 O'Reilly & Associates. All rights reserved.