1 /* IMWheel Utility Definitions 2 * Copylefted under the Linux GNU Public License 3 * Author : Jonathan Atkins <jcatki@jonatkins.org> 4 * PLEASE: contact me if you have any improvements, I will gladly code good ones 5 */ 6 #ifndef UTIL_H 7 #define UTIL_H 8 #include <config.h> 9 #include <getopt.h> 10 11 #define PIDFILE PIDDIR"/imwheel.pid" 12 13 #define NUM_BUTTONS 6 14 #define STATE_MASK (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask) 15 #define NUM_STATES 3 16 #define MAX_MASKTRANS 8 17 #define ABS(a) ((a)<0?(-a):(a)) 18 19 /* commands */ 20 enum { 21 UNGRAB =100, 22 REPEAT =200, 23 GRAB =400, 24 PRIORITY=800 25 }; 26 #define MIN_COMMAND UNGRAB 27 28 struct Trans 29 { 30 char *name; 31 int val; 32 }; 33 struct WinAction 34 { 35 int pri; //used to determine priority of some conflicting matches 36 char *id; //window identifier (for regex match) 37 int button; //mouse button number or command 38 char **in; //keysyms in mask 39 char **out; //keysyms out 40 int reps; //number of repetitions 41 int delay; //microsecond delay until next keypress 42 int delayup;//microsecond delay while key down 43 }; 44 45 extern int buttons[NUM_BUTTONS+1]; 46 extern int statebits[STATE_MASK+1]; 47 extern int debug; 48 extern struct WinAction *wa; 49 extern int num_wa; 50 extern struct Trans masktrans[MAX_MASKTRANS]; 51 extern const int reps[1<<NUM_STATES]; 52 extern const char *keys[NUM_BUTTONS][1<<NUM_STATES]; 53 extern char *wname; 54 extern XClassHint xch; 55 extern const char *button_names[]; 56 extern Atom ATOM_NET_WM_NAME, ATOM_UTF8_STRING, ATOM_WM_NAME, ATOM_STRING; 57 58 void getOptions(int,char**,char*,const struct option*); 59 char *windowName(Display*, Window); 60 void Printf(char *,...); 61 void printUsage(char*, const struct option[], const char*[][2]); 62 void printXEvent(XEvent*); 63 void delay(unsigned long); 64 void printXModifierKeymap(Display*, XModifierKeymap*); 65 void printKeymap(Display *d, char[32]); 66 int getbit(char*, int); 67 void setbit(char*, int, Bool); 68 void setupstatebits(void); 69 int isMod(XModifierKeymap*, int); 70 unsigned int makeModMask(XModifierKeymap*, char[32]); 71 unsigned int makeKeysymModMask(Display*,XModifierKeymap*, char**); 72 void printfState(int); 73 void exitString(char*, char*); 74 struct WinAction *getRC(void); 75 int wacmp(const void*, const void*); 76 char **getPipeArray(char*); 77 void printWA(struct WinAction*); 78 void writeRC(struct WinAction*); 79 struct WinAction *findWA(Display*,int,char*,char*,char*,XModifierKeymap*,char[32]); 80 void doWA(Display*,XButtonEvent*,XModifierKeymap*,char[32],struct WinAction*); 81 void modMods(Display*, char*, XModifierKeymap*, Bool, int); 82 void flushFifo(void); 83 void closeFifo(void); 84 void openFifo(void); 85 void KillIMWheel(void); 86 void WritePID(void); 87 int isUsedButton(int b); 88 int buttonIndex(int b); 89 90 #endif 91