1 /* -*-c-*- */ 2 3 #ifndef FVWMLIB_BINDINGS_H_H 4 #define FVWMLIB_BINDINGS_H_H 5 6 #include "fvwm_x11.h" 7 8 /* ---------------------------- global definitions ------------------------- */ 9 10 #define binding_t_t unsigned char 11 12 /* ---------------------------- global macros ------------------------------ */ 13 14 #define BIND_IS_KEY_PRESS(t) ((t) == BIND_KEYPRESS || (t) == BIND_PKEYPRESS) 15 #define BIND_IS_KEY_BINDING(t) ((t) == BIND_KEYPRESS || (t) == BIND_PKEYPRESS) 16 #define BIND_IS_PKEY_BINDING(t) ((t) == BIND_PKEYPRESS) 17 #define BIND_IS_MOUSE_BINDING(t) \ 18 ((t) == BIND_BUTTONPRESS || (t) == BIND_BUTTONRELEASE) 19 20 /* ---------------------------- type definitions --------------------------- */ 21 22 typedef enum 23 { 24 /* press = even number, release = press + 1 */ 25 BIND_BUTTONPRESS = 0, 26 BIND_BUTTONRELEASE = 1, 27 BIND_KEYPRESS = 2, 28 BIND_PKEYPRESS = 4, 29 } binding_t; 30 31 typedef struct Binding 32 { 33 binding_t_t type; /* Is it a mouse or key binding */ 34 int Button_Key; /* Mouse Button number or Keycode */ 35 char *key_name; /* In case of keycode, give the key_name too */ 36 int Context; /* Fvwm context, ie titlebar, frame, etc */ 37 int Modifier; /* Modifiers for keyboard state */ 38 void *Action; /* What to do? */ 39 void *Action2; /* This one can be used too */ 40 char *windowName; /* Name of window (regex pattern) this binding 41 applies to. NULL means all windows. */ 42 struct Binding *NextBinding; 43 } Binding; 44 45 /* ---------------------------- interface functions ------------------------ */ 46 47 void CollectBindingList( 48 Display *dpy, Binding **pblist_src, Binding **pblist_dest, 49 Bool *ret_are_similar_bindings_left, binding_t type, 50 int button, KeySym keysym, 51 int modifiers, int contexts, char *windowName); 52 int AddBinding( 53 Display *dpy, Binding **pblist, binding_t type, 54 int button, KeySym keysym, char *key_name, 55 int modifiers, int contexts, void *action, void *action2, 56 char *windowName); 57 void FreeBindingStruct(Binding *b); 58 void FreeBindingList(Binding *b); 59 void RemoveBinding(Binding **pblist, Binding *b, Binding *prev); 60 Bool RemoveMatchingBinding( 61 Display *dpy, Binding **pblist, binding_t type, 62 int button, KeySym keysym, int modifiers, 63 int contexts); 64 void *CheckBinding( 65 Binding *blist, int button_keycode, 66 unsigned int modifier, unsigned int dead_modifiers, int Context, 67 binding_t type, const XClassHint *win_class, const char *win_name); 68 void *CheckTwoBindings( 69 Bool *ret_is_second_binding, Binding *blist, 70 int button_keycode, unsigned int modifier,unsigned int dead_modifiers, 71 int Context, binding_t type, const XClassHint *win_class, 72 const char *win_name, int Context2, binding_t type2, 73 const XClassHint *win_class2, const char *win_name2); 74 void GrabWindowKey( 75 Display *dpy, Window w, Binding *binding, unsigned int contexts, 76 unsigned int dead_modifiers, Bool fGrab); 77 void GrabAllWindowKeys( 78 Display *dpy, Window w, Binding *blist, unsigned int contexts, 79 unsigned int dead_modifiers, Bool fGrab); 80 void GrabWindowButton( 81 Display *dpy, Window w, Binding *binding, unsigned int contexts, 82 unsigned int dead_modifiers, Cursor cursor, Bool fGrab); 83 void GrabAllWindowButtons( 84 Display *dpy, Window w, Binding *blist, unsigned int contexts, 85 unsigned int dead_modifiers, Cursor cursor, Bool fGrab); 86 void GrabAllWindowKeysAndButtons( 87 Display *dpy, Window w, Binding *blist, unsigned int contexts, 88 unsigned int dead_modifiers, Cursor cursor, Bool fGrab); 89 void GrabWindowKeyOrButton( 90 Display *dpy, Window w, Binding *binding, unsigned int contexts, 91 unsigned int dead_modifiers, Cursor cursor, Bool fGrab); 92 KeySym FvwmStringToKeysym(Display *dpy, char *key); 93 Bool bindingAppliesToWindow(Binding *binding, const XClassHint *win_class, 94 const char *win_name); 95 Bool is_pass_through_action(const char *action); 96 97 98 #endif /* FVWMLIB_BINDINGS_H_H */ 99