HPlogo Using the X Window System > Chapter 7 The Window Manager

Managing Window Manager Menus

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

The OSF/Motif Window Manager menus are defined by a text file in /usr/lib/X11 called system.mwmrc, unless you have a file in your home directory called .mwmrc. You can add or delete menus and menu selections by copying system.mwmrc to your home directory as .mwmrc and modifying it to suit your needs.

Default Menus

The OSF/Motif Window Manager comes with two default menus:

Default Window Menu

The default window menu is built into mwm. For reference, a copy of its contents are placed in .mwmrc.

   Menu DefaultWindowMenu

   {

       "Restore"   _R      Alt<Key>F5      f.normalize

       "Move"      _M      Alt<Key>F7      f.move 

       "Size"      _S      Alt<Key>F8      f.resize

       "Minimize"  _n      Alt<Key>F9      f.minimize

       "Maximize"  _x      Alt<Key>F10     f.maximize

       "Lower"     _L      Alt<Key>F3      f.lower

       no-label                            f.separator

       "Close"     _C      Alt<Key>F4      f.kill

   }

By default, the window menu displays when you do the following operations:

  • Press button 1 on a window frame's window menu button.

  • Press button 3 anywhere on a window frame.

  • Press Shift Esc with the keyboard focus set to a window.

The windowMenu resource must be set in order to replace the DefaultWindowMenu with a different menu.

Default Root Menu

The default root menu is specified in the same files by the following lines:

   Menu RootMenu

   {   

    "Root Menu"    f.title            

    "New Window"   f.exec "hpterm &"  

    "Start Clock"  f.exec "xclock -geometry 100x90-1+1 &"

    "Start Load"   f.exec "xload -geometry 150x90-130+1 &"

    "Shuffle Up"   f.circle_up    

    "Shuffle Down" f.circle_down 

    "Refresh"      f.refresh    

     no-label      f.separator 

    "Restart..."   f.restart  

   }

By default, the root menu displays when you press button 3 on the root window.

Modifying Menus

You can modify either menu to suit the specific needs of your application; however, for the sake of the consistency of window operation, it's usually better to modify the root menu and keep the window menu the same.

All window manager menus, regardless of the mechanism that calls them to the screen, have the same syntax.

Menu Syntax

   Menu MenuName

   {

      selection1  [mnemonic] [accelerator]  function

    [argument]

      selection2  [mnemonic]  [accelerator]  function  [argument]

      selection3  [mnemonic] [accelerator]  function [argument]

                                    .

                                    .

                                    .          

      selection*  [mnemonic]  [accelerator]  function  [argument]

   }

Each line identifies a selection name followed by the function to be done if that selection is chosen. The order of the selections is the order of their appearance when you display the menu. A selection name may be either a character string or a bitmap.

The f.title function creates a menu title, and automatically places a separator above and below the title.

Selections

Any character string containing a space must be enclosed in double quotes (""); single-word strings don't have to be enclosed, but it's probably a good idea for the sake of consistency. An alternate method of dealing with two-word selection names is to use an underbar (_) in place of the space.

Mnemonics and Accelerators

You have the option of using a mnemonic and accelerator with a menu selection. A mnemonic is specified using the syntax:

mnemonic = _character

An accelerator is specified using keyboard binding syntax described later in this chapter (see "Keyboard Binding Syntax").

Functions

Each function operates in one or more of these contexts:

root

Operates the function when the root window is selected.

icon

Operates the function when an icon is selected.

window

Operates the function when a client window is selected.

Each function is triggered by one or more of these devices:

Button

Button binding (mouse).

Key

Key binding.

Menu

Window manager menu.

Most contexts and devices are valid for most functions. Occasionally, a context or device doesn't make sense for a particular function. Any selection that uses an invalid context, an invalid function, or a function that doesn't apply to the current context is grayed out.

Function Names, Contexts, and Devices

The following table lists the valid functions, contexts, and devices.

Table 7-17 Valid Window Manager Functions

FunctionsContextsDevices
Name Description Root Icon Window Button Key Menu
f.beepCauses a beep to sound.XXXXXX
f.circle_downPuts window on bottom of stack.XXXXXX
f.circle_upPuts window on top of stack.XXXXXX
f.execUses /usr/bin/sh to execute a command.XXXXXX
f.focus_color Sets colormap focus when colormap focus policy is explicit. XXXXXX
f.focus_key Sets keyboard input focus when keyboard focus policy is explicit. XXXXXX
f.killTerminates a client's connection to server. XXXXX
f.lowerLowers a window to bottom of stack. XXXXX
f.maximizeEnlarges a window to its maximum size. XXXXX
f.menuAssociates a menu with a selection or binding.XXXXXX
f.minimizeChanges a window into an icon.  XXXX
f.moveEnables the interactive moving of a window. XXXXX
Name Description Root Icon Window Button Key Menu
f.next_cmapInstalls the next colormap in the window with the colormap focus.XXXXXX
f.next_keySets keyboard focus policy to the next window/icon in the stack.XXXXXX
f.nopDoes no function.XXXXXX
f.normalizeDisplays a window in normal size. XXXXX
f.pack_icons Packs icons rows in the root window or icon box.XXXXXX
f.pass_keys Toggles between enabling and disabling processing of key bindings. XXXXXX
f.post_wmenu Posts the window menu XXXXX 
f.prev_cmap Installs the previous color map in the window with the colormap focus. XXXXXX
f.prev_key Sets the keyboard input focus to the next window/icon in the stack. XXXXXX
Name Description Root Icon Window Button Key Menu
f.quit_mwmTerminates OSF/Motif Window Manager, but not X.X  XXX
f.raiseLifts a window to the top of the window stack. XXXXX
f.raise_lower Raises a partially concealed window; lowers an unconcealed window.  XXXXX
f.refreshRedraws all windows. XXXXXX
f.refresh_winRedraws a client window.   XXXX
f.resizeEnables you to interactively resize a window.   XXXX
f.restartRestarts the OSF/Motif Window Manager. X  XXX
f.send_msg Sends a client message.  XXXXX
f.separatorDraws a line between menu selections. XXX  X
f.set_behaviorRestarts mwm with CXI or custom behavior. XXXXXX
f.titleInserts a title into a menu at the specified position. XXX  X

 

Changing the Menu Associated with the Window Menu Button

The windowMenu resource lets you change the menu displayed when you press button 1 on the window menu button.

For example, you would place the following line in your personal resource specifications to associate a menu named EditMenu with an hpterm window started as hpterm -name hp850.

   Mwm*hp850*windowMenu:   EditMenu
© 1995 Hewlett-Packard Development Company, L.P.