JWM Source Documentation
Data Structures | Macros | Typedefs | Functions | Variables
key.c File Reference

Key binding functions. More...

#include "jwm.h"
#include "key.h"
#include "client.h"
#include "clientlist.h"
#include "command.h"
#include "error.h"
#include "misc.h"
#include "root.h"
#include "tray.h"

Go to the source code of this file.

Data Structures

struct  ModifierNode
 
struct  KeyNode
 
struct  LockNode
 

Macros

#define MASK_NONE   0
 
#define MASK_SHIFT   (1 << ShiftMapIndex)
 
#define MASK_LOCK   (1 << LockMapIndex)
 
#define MASK_CTRL   (1 << ControlMapIndex)
 
#define MASK_MOD1   (1 << Mod1MapIndex)
 
#define MASK_MOD2   (1 << Mod2MapIndex)
 
#define MASK_MOD3   (1 << Mod3MapIndex)
 
#define MASK_MOD4   (1 << Mod4MapIndex)
 
#define MASK_MOD5   (1 << Mod5MapIndex)
 

Typedefs

typedef struct ModifierNode ModifierNode
 
typedef struct KeyNode KeyNode
 
typedef struct LockNode LockNode
 

Functions

static unsigned int GetModifierMask (XModifierKeymap *modmap, KeySym key)
 Get the modifier mask for a key.
 
static KeySym ParseKeyString (const char *str)
 Parse a key string.
 
static char ShouldGrab (KeyType key)
 Determine if a key should be grabbed on client windows.
 
static void GrabKey (KeyNode *np, Window win)
 Grab a key.
 
void InitializeKeys (void)
 Initialize key data.
 
void StartupKeys (void)
 Startup key bindings.
 
void ShutdownKeys (void)
 Shutdown key bindings.
 
void DestroyKeys (void)
 Destroy key data.
 
KeyType GetKey (const XKeyEvent *event)
 Get the key action from an event.
 
void RunKeyCommand (const XKeyEvent *event)
 Run a command invoked from a key binding.
 
void ShowKeyMenu (const XKeyEvent *event)
 Show a root menu caused by a key binding.
 
unsigned int ParseModifierString (const char *str)
 Parse a modifier mask string.
 
void InsertBinding (KeyType key, const char *modifiers, const char *stroke, const char *code, const char *command)
 Insert a key binding.
 
void ValidateKeys (void)
 Validate key bindings.
 

Variables

static ModifierNode modifiers []
 
static LockNode lockMods []
 
static KeyNodebindings
 
unsigned int lockMask
 Mask of 'lock' keys.
 

Detailed Description

Key binding functions.

Author
Joe Wingbermuehle
Date
2004-2006

Definition in file key.c.

Macro Definition Documentation

#define MASK_CTRL   (1 << ControlMapIndex)

Definition at line 24 of file key.c.

#define MASK_LOCK   (1 << LockMapIndex)

Definition at line 23 of file key.c.

#define MASK_MOD1   (1 << Mod1MapIndex)

Definition at line 25 of file key.c.

#define MASK_MOD2   (1 << Mod2MapIndex)

Definition at line 26 of file key.c.

#define MASK_MOD3   (1 << Mod3MapIndex)

Definition at line 27 of file key.c.

#define MASK_MOD4   (1 << Mod4MapIndex)

Definition at line 28 of file key.c.

#define MASK_MOD5   (1 << Mod5MapIndex)

Definition at line 29 of file key.c.

#define MASK_NONE   0

Definition at line 21 of file key.c.

Referenced by ParseModifierString().

#define MASK_SHIFT   (1 << ShiftMapIndex)

Definition at line 22 of file key.c.

Typedef Documentation

typedef struct KeyNode KeyNode
typedef struct LockNode LockNode
typedef struct ModifierNode ModifierNode

Function Documentation

void DestroyKeys ( void  )

Destroy key data.

Definition at line 157 of file key.c.

References KeyNode::command, KeyNode::next, and Release.

Referenced by Destroy().

KeyType GetKey ( const XKeyEvent *  event)

Get the key action from an event.

Get the action to take from a key event.

Definition at line 204 of file key.c.

References KeyNode::code, KeyNode::key, KEY_NONE, lockMask, KeyNode::next, and KeyNode::state.

Referenced by HandleDialogKeyPress(), HandleKeyPress(), HandleKeyRelease(), MoveClientKeyboard(), ResizeClientKeyboard(), and UpdateMotion().

unsigned int GetModifierMask ( XModifierKeymap *  modmap,
KeySym  key 
)
static

Get the modifier mask for a key.

Definition at line 311 of file key.c.

References _, display, JUNLIKELY, JXKeysymToKeycode, and Warning().

Referenced by StartupKeys().

void GrabKey ( KeyNode np,
Window  win 
)
static

Grab a key.

Definition at line 171 of file key.c.

References KeyNode::code, display, JXGrabKey, lockMods, LockNode::mask, and KeyNode::state.

Referenced by StartupKeys().

void InitializeKeys ( void  )

Initialize key data.

Definition at line 83 of file key.c.

References lockMask.

Referenced by Initialize().

void InsertBinding ( KeyType  key,
const char *  modifiers,
const char *  stroke,
const char *  code,
const char *  command 
)
KeySym ParseKeyString ( const char *  str)
static

Parse a key string.

Definition at line 366 of file key.c.

References _, JUNLIKELY, JXStringToKeysym, and Warning().

Referenced by InsertBinding().

unsigned int ParseModifierString ( const char *  str)

Parse a modifier mask string.

Parse a modifier string.

Definition at line 333 of file key.c.

References _, JUNLIKELY, ModifierNode::mask, MASK_NONE, ModifierNode::name, and Warning().

Referenced by InsertBinding(), and ParseMoveMode().

void RunKeyCommand ( const XKeyEvent *  event)

Run a command invoked from a key binding.

Run a command caused by a key binding.

Definition at line 225 of file key.c.

References KeyNode::code, KeyNode::command, lockMask, KeyNode::next, RunCommand(), and KeyNode::state.

Referenced by HandleKeyPress().

char ShouldGrab ( KeyType  key)
static
void ShowKeyMenu ( const XKeyEvent *  event)

Show a root menu caused by a key binding.

Definition at line 244 of file key.c.

References KeyNode::code, KeyNode::command, GetRootMenuIndexFromString(), JLIKELY, lockMask, KeyNode::next, ShowRootMenu(), and KeyNode::state.

Referenced by HandleKeyPress().

void ShutdownKeys ( void  )

Shutdown key bindings.

Definition at line 132 of file key.c.

References display, GetTrays(), JXUngrabKey, LAYER_COUNT, TrayType::next, ClientNode::next, nodes, rootWindow, ClientNode::window, and TrayType::window.

Referenced by Shutdown().

void StartupKeys ( void  )
void ValidateKeys ( void  )

Validate key bindings.

Definition at line 460 of file key.c.

References _, KeyNode::command, GetRootMenuIndexFromString(), IsRootMenuDefined(), JUNLIKELY, KeyNode::key, KEY_ROOT, KeyNode::next, and Warning().

Referenced by ParseConfig().

Variable Documentation

KeyNode* bindings
static

Definition at line 74 of file key.c.

Referenced by InsertBinding().

unsigned int lockMask

Mask of 'lock' keys.

Definition at line 75 of file key.c.

Referenced by GetKey(), HandleButtonEvent(), InitializeKeys(), RunKeyCommand(), ShowKeyMenu(), and StartupKeys().

LockNode lockMods[]
static
Initial value:
= {
{ XK_Caps_Lock, 0 },
{ XK_Num_Lock, 0 }
}

Definition at line 69 of file key.c.

Referenced by GrabKey(), and StartupKeys().

ModifierNode modifiers[]
static
Initial value:
= {
{ 'C', MASK_CTRL },
{ 'S', MASK_SHIFT },
{ 'A', MASK_MOD1 },
{ '1', MASK_MOD1 },
{ '2', MASK_MOD2 },
{ '3', MASK_MOD3 },
{ '4', MASK_MOD4 },
{ '5', MASK_MOD5 },
{ 0, MASK_NONE }
}

Definition at line 36 of file key.c.

joewing.net / Projects / JWM