Chapter 6. Customizing Your Application's Minimized Windows

Users can minimize (stow) your application's window on the Desktop, by clicking the minimize button in the top right corner of the window frame or by selecting “Minimize” from the Window Menu. When a window is minimized, it is replaced by a 100 x 100 pixel representation with an identifying label of 13 characters or less. This is referred to as the minimized window. (It is also commonly called an icon, but this document uses the term minimized window to prevent confusing it with the Desktop icon.)

This chapter explains how to put the image of your choice on a minimized window. It contains these sections:

Some Different Sources for Minimized Window Images

You can make a minimized window image out of any image that you can display on your workstation monitor. This means that you can create a picture using showcase or the drawing/painting tool of your choice, or you can scan in a picture, or you can take a snapshot of some portion of your application. You can even have an artist design your stow icons for you. “Choosing an Image for Your Minimized Window” in Chapter 3 of the Indigo Magic User Interface Guidelines provides some guidelines for designing minimized window images.

Figure 6-1 shows some different minimized window images that were created in different ways. From left to right: the top row shows a scanned-in photograph, a snapshot of the application itself, a scanned-in photograph that was altered with imp, and scanned-in line art; the bottom row shows a drawing representing the application, scanned-in line art, and two artist-designed images.

Figure 6-1. Minimized Window Image Examples


Creating a Minimized Window Image: The Basic Steps

It's important for users to be able to easily identify your application's windows when they are minimized, so you should define a specific image and label for each primary and support window in your application. For guidelines on selecting minimize images, see “Choosing an Image for Your Minimized Window” in Chapter 3 of the Indigo Magic User Interface Guidelines.

To make a minimized window image for your application:

  1. Create an RGB image. If your image is already in RGB format, then all you have to do is resize the image to an appropriate size (look at the setting of the iconImageMaximum resource in 4Dwm to see the maximum size of the stow icon, currently 85x67). See “Resizing the RGB Image Using imgworks” for instructions on resizing the image.

    If your image is not in RGB format, you need to convert it to RGB. One way to do this is to take a snapshot of your image. See “Using snapshot to Get an RGB Format Image” for instructions.

  2. Scale the image to the correct size. See “Resizing the RGB Image Using imgworks” for instructions.

  3. Name the image file. The filename should consist of two parts: first, the application name (technically,. the res_name field of the WM_CLASS property); and second, the .icon suffix. This gives you a name of the form res_name.icon. For example, if your application's name is “chocolate,” the name of your image file should be:

    chocolate.icon
    

  4. Put the file in the /usr/lib/images directory.

Using snapshot to Get an RGB Format Image

You can use the snapshot tool to capture an image on your screen for use in your image. To bring up snapshot, enter:

% snapshot 

The snapshot tool, shown in Figure 6-2, appears.

Figure 6-2. The snapshot Tool


To use snapshot, follow these steps:

  1. Bring up the desired image on your monitor.

  2. Position the cursor over the snapshot tool. The cursor turns into a small red camera.

  3. While the cursor is still positioned over the snapshot tool, hold down the <Shift> key. Don't release it.

  4. Continuing to hold down the <Shift> key, move the cursor over to a corner of the image you want to snap and, holding down the left mouse button, drag the mouse to the opposite corner of the image. A red box is formed around the image as you drag the cursor. Release the mouse button when the box reaches the desired size.

  5. After releasing the mouse button, you can adjust the red box from the corners or the sides by holding the left mouse button down again and resizing just as you would a window.

    Everything in this red box is saved in the snapshot, so make sure you don't include any unwanted window borders or screen background. If you have trouble telling what's included in the box and what isn't, bring up the xmag tool by entering:

    % xmag 
    

    The xmag window shows you a magnified view of the area around the cursor.

  6. When the red box is positioned exactly around the correct area of the image, release the left mouse button and move the cursor back over the snapshot tool.

  7. Keeping the cursor positioned over the snapshot tool, release the <Shift> key.

  8. Press down the right mouse button to see the snapshot menu and select “Save as snap.rgb” from the menu. The cursor turns into an hourglass while snapshot saves your image.

  9. To see the image you've snapped, enter:

    % ipaste snap.rgb 
    

    If the image looks good, then you're ready to resize it. See “Resizing the RGB Image Using imgworks” for instructions.

See the snapshot(1) reference page for more information about using snapshot.

Resizing the RGB Image Using imgworks

You can use imgworks to resize your RGB image to the appropriate size for a minimized window image. The maximum size is determined by the value of the iconImageMaximum resource in 4Dwm, which is currently 85x67.

To find the imgworks icon, select “An Icon” from the Find toolchest. When the Find an Icon window appears, type

imgworks 

into the text field. The imgworks icon appears in the drop pocket. Drag the icon to the Desktop and drop it. Then run imgworks by double-clicking the icon.

To resize your image using imgworks, follow these steps:

  1. Open your image file by selecting “Open” from the File menu and selecting your file from the Image Works: Open Image… window. Your image appears in the main window.

  2. To scale the image, select “Scale…” from the Transformations menu. The Image Works: Scale window appears.

  3. Scale the image by typing in an appropriate scale factor. The dimensions of the new image (in pixels) are listed in the Scale window.

  4. When you're happy with the dimensions listed in the Scale window, click the Apply button. The resized image appears in the main window. Save it by selecting “Save” from the File menu.

Refer to the imgworks(1) reference page for more information on imgworks.

Setting the Minimized Window Label

By default, the 4Dwm window manager reuses the title bar label for the minimized window label. To explicitly set the label of the minimized window, you simply need to change the value of the window's XmNiconName resource. See “Labeling a Minimized Window” in Chapter 3 for guidelines for choosing a label.

Changing the Minimized Window Image

Your application can also change its minimized window's image while it is running (for example, to indicate application status) by setting the window's XmNiconWindow resource. However, it can be very difficult to handle color images without causing visual and colormap conflicts. If you decide to change the image, the image you install should: 1) use the default visual; and 2) use the existing colormap without creating any new colors (preferably, your image should use only the first 16 colors in the colormap). This potentially implies dithering or color quantization of your image.


Note: The 4Dwm window manager automatically handles your application's initial minimized window image (that is, the image automatically loaded from the /usr/lib/images directory at application start-up). If you don't want to change this image while your application is running, your application doesn't need to do anything to support displaying the image properly.