Next | Prev | Up | Top | Contents | Index

Rubber Banding

Rubber banding can be used for cases where it's necessary to draw a few lines over a scene in response to a mouse movement. An example is the movable window outline that you get when resizing or moving a window. Rubber-banding is also used frequently by drawing programs.

The 4Dwm window manager provides rubber banding for moving and resizing windows. However, if you need rubber banding features inside your application, you have to manage it yourself.

Here's the best way to do rubber banding with overlays (this is the method used by 4Dwm, the default Silicon Graphics window manager):

  1. Map an overlay window, with its background pixmap set to None (background is passed in as a parameter to XCreateWindow()). This window should be as large as the area over which rubber banding could take place.

  2. Draw rubber bands in the new overlay window. Ignore resulting damage to other windows in the overlay plane.

  3. Unmap the rubber-band window, which sends Expose events to other windows in the overlay plane.

Next | Prev | Up | Top | Contents | Index