Next: , Previous: , Up: Window Frames   [Contents][Index]


10.2 Frame Part Classes

Although one of the aims of Sawfish is to provide as much flexibility as possible, this can sometimes be detrimental to the overall experience. For example, it would be easier for the user if all themes use consistent keymaps and cursor images in conceptually similar parts of window frames. That is, it would be better if all close buttons had the same mouse button bindings and the same mouse cursor displayed when the pointer is over them.

To achieve this, Sawfish defines a number of classes of frame parts, each with several default attributes. When defining a window frame, the definitions of each part then specifies which class it is a member of, and inherits the associated default attributes (provided that it hasn’t explicitly specified values for these attributes).

Variable: frame-part-classes

This variable is an association list, associating symbols naming frame part classes with an association list of default attributes for that class.

The names of the pre-defined classes are as follows, their meanings should be self-explanatory:

title, menu-button, close-button, iconify-button, maximize-button, sticky-button, lock-button, rename-button, move-resize-button, raise-lower-button, top-border, left-border, right-border, bottom-border, top-left-corner, top-right-corner, bottom-left-corner, bottom-right-corner.

Extra classes can be created by adding to frame-part-classes. However, it’s likely that more than one theme may need to use the same class, and that the user may then wish to customize any extra keymaps used. The def-frame-class macro should be used to add new classes, since it handles these situations.

Macro: def-frame-class class alist-form &rest binding-forms …

Creates a new frame part class named by the symbol CLASS.

The ALIST-FORM is evaluated to give an association list defining attributes for the class. Each key-value pairs is only set if no existing value exists for that key.

If binding-forms are given, they will be evaluated when no keymap already exists for the class. A keymap will be created, and stored in the variable named ‘class-name’. This variable may then be used within the binding-forms.

So to define a hypothetical shade-button class, the following might be used:

(def-frame-class shade-button '((cursor . left_ptr))
  (bind-keys shade-button-keymap
    "Button1-Off" 'toggle-window-shaded))

In some cases it might be valuable to be able to override pre-defined frame part properties. For example, it might be your preference that text in window title bars is always blue.

Function: define-frame-class class alist-form #!optional with-keymap

Creates a new frame part class named by the symbol class.

Unlike def-frame-class, the trailing argument is just a boolean flag. This flag only indicates whether to create a keymap for the class. Any bindings have to be established through a separate call to bind-keys.

The function returns t if it was able to create and bind the empty keymap, nil otherwise. This allows us to check for errors.

Variable: override-frame-part-classes

Similar to frame-part-classes except that the properties take precedence over values defined both in that variable and in the frame style itself.

The following function may be used to simplify the customization of these two variables:

Function: set-frame-part-value class key value #!optional override

Associate value with property key for all frame parts of class class.

If override is non-nil, then the setting is installed in the override-frame-part-classes variable, otherwise it’s stored in the frame-part-classes variable.

The following example would override the colors of all title bars:

(set-frame-part-value 'title 'background
                      '("black" "white" "green" "blue") t)

(See the next section for details about what is actually being set here.)


Next: , Previous: , Up: Window Frames   [Contents][Index]