5.1  Units

5.1.1  Why Pixels are Bad

In the old days, every computer screen was 640 x 480 pixels in size. An application with a pixel-based layout thus looked the same on all screens. Nowadays, however, common screen resolutions range from 800 x 600 pixels up to 1600 x 1200 pixels or even more. Of course, a pixel-based layout would look the same on all screens, but a layout designed for a 800 x 600 screen would be unreadably small on a 1600 x 1200 screen.

Some resolutions don't even have a near-to-square pixel aspect ratio, and pixel-based layouts could look distorted.

For truly resolution-independent layouts, you cannot work with pixel values. Instead, classical units such as centimeters, inches, or DTP points become useful. And, of course, gDesklets supports all of these.

5.1.2  Layouting with Units

Every geometry property, such as the x, y, width, and height properties accept unit-based values. If the unit is omitted, pixels are used instead.

The units supported by the gDesklets platform are:

  • cm - centimeters
  • in - inches
  • pt - DTP points (1 pt = 1/72 inch)
  • % - percentage of the size of the parent container element

The correct scaling factor for transforming into pixels is computed from the DPI setting of the X server. For good results, the DPI value has to be set correctly. Some display managers, e.g. kdm, are known to set a hardcoded value of 100 dpi by default, which results in wrong scaling on most screens.