[Contents] [Index] [Next] [Previous]

Modifying Mouse Button Bindings


As described in Chapter 2, the Motif Window Manager recognizes the following button actions:

You can associate a mouse button action with a window management function by using a button binding. A button binding is a command line you put in your .mwmrc file that associates a button action with a window manager function.

User-defined button bindings are added to built-in button bindings and are always defined first.

Default Button Bindings

The Motif Window Manager provides default button bindings. These button bindings define the functions of the window frame components. The user-specified button bindings that are defined with the buttonBindings resource are added to the built-in button bindings. The default value for this resource is DefaultButtonBindings.

Button Action Context Function
<Btn1Click2> menu f.kill
<Btn1Click> minimize f.minimize
<Btn1Click> maximize f.maximize
<Btn1Down> title f.move
<Btn1Down> window|icon f.focus_key
<Btn1Down> border f.resize
<Btn1Click> icon f.post_wmenu
<Btn1Click2> icon f.restore

Button Binding Syntax

The syntax for button bindings is as follows:

Buttons ButtonBindingSetName
{
button context [| context] function [argument]
button context [| context] function [argument]
.
.
.
button context [| context] function [argument]
}

Each line identifies a certain mouse button action, followed by the context in which the button action is valid, followed by the function to be done. Some functions require an argument.

Modifying Button Bindings

To modify the default button bindings, you need to edit either system.mwmrc to make system-wide changes or .mwmrc to make changes to the local environment. The easiest way to modify button bindings is to change the default bindings or to insert extra lines in the DefaultButtonBindings.

When modifying or creating a button binding, you need to first decide which mouse button to use and which action is performed on the button. Make sure you do not use button-action combinations already used by OSF/Motif. You might want to require a simultaneous key press with the mouse button action. This is called modifying the button action. Modifiers increase the number of possible button bindings you can make. The following table lists button binding modifier keys.

Control Key

Shift Key

Alt (Meta) Key

Lock
Lock Key

Mod1
Modifier 1

Mod2
Modifier 2

Mod3
Modifier 3

Mod4
Modifier 4

Mod5
Modifier 5

On some systems, you can bind up to five buttons if you have a 3-button mouse. For example, Button 4 is the simultaneous press of Buttons 1 and 2. Button 5 is the simultaneous press of Buttons 2 and 3. Each button can be bound with one of four actions.

Button Description
Btn1Down Button 1 press
Btn1Up Button 1 release
Btn1Click Button 1 press and release
Btn1Click2 Button 1 double-click
Btn2Down Button 2 press
Btn2Up Button 2 release
Btn2Click Button 2 press and release
Btn2Click2 Button 2 double-click
Btn3Down Button 3 press
Btn3Up Button 3 release
Btn3Click Button 3 press and release
Btn3Click2 Button 3 double-click

After choosing the optional modifier and the mouse button action, you must decide under which context(s) the binding works.

This context For mouse action at this pointer position
root Workspace (root window)
window Client window
frame Window frame (title and border)
icon Icon
title Title bar
border Frame minus title bar
app Application window (inside the frame)

The context indicates where the pointer must be for the button binding to be effective. For example, a context of window indicates that the pointer must be over a client window or window frame for the button binding to be effective. The frame context is for the window frame around a client window (including the border and title bar), the border context is for the border part of the window frame (not including the title bar), the title context is for the title bar of the window frame, and the app context is for the application window or client area (not including the window frame).

The following is an example of a button binding. Imagine you have created your own Graphics Projects menu and you want to display the menu with a button action. You choose as a modifier and Btn3Down as the button action. You decide the pointer must be on the workspace. The function name for posting a special menu is f.menu and the argument is the menu name Graphics Projects.

The following line in the DefaultButtonBindings in your .mwmrc file creates the button binding:

Alt<Btn3Down> root f.menu "Graphics Projects"

Making a New Button Binding Set

If inserting a new button binding into the DefaultButtonBindings set is not enough, you may need to make a complete new set of button bindings. To create a new button binding set, use the DefaultButtonBindings in your .mwmrc file as a model. After you have created a new button binding set, use the buttonBindings resource to tell the window manager about it.

The buttonBindings resource specifies a button binding set. The default value of the resource is DefaultButtonBindings. Use the following syntax for specifying the resource in your .Xdefaults file:

Mwm*buttonBindings: NewButtonBindingSetName

This line directs the window manager to use NewButtonBindingSetName as the source of its button binding information. The button bindings are assumed to exist in the file named by the configFile resource; the default is .mwmrc.

For example, suppose that you want to specify a completely new button binding set instead of inserting a line in the existing DefaultButtonBindings set. The following entry in your .mwmrc file creates a new button binding set:

Buttons GraphicsButtonBindings
{
<Btn3Down> root f.menu "Graphics Projects"
}

The following line in your .Xdefaults file references the new button binding set:

Mwm*buttonBindings: GraphicsButtonBindings

To display the graphics menu, press Button 3 on the mouse when the pointer is on the workspace.