XKeys.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00017 #ifndef _OT_XKEYS_H
00018 #define _OT_XKEYS_H
00019
00020
00021 #ifndef WIN32
00022
00023 #include <X11/Xlib.h>
00024 #include <iostream>
00025 #include <string>
00026
00033 namespace ot {
00034
00035 class XKeys {
00036
00037 public:
00038 typedef enum {
00039 SYM,
00040 CODE,
00041 BUTTON
00042 } KeyType_t;
00043
00044 typedef enum {
00045 PRESS,
00046 RELEASE
00047 } EventType_t;
00048
00049 typedef struct {
00050 KeyType_t type;
00051 EventType_t event_type;
00052
00053 union {
00054 KeySym sym;
00055 KeyCode code;
00056 unsigned int button;
00057 } key;
00058
00059 unsigned int modifier;
00060 char *command;
00061 } Keys_t;
00062
00063
00064 public:
00065
00066
00067 XKeys()
00068 { init(); }
00069
00070
00071 XKeys(const char* rcfile);
00072
00073
00074 ~XKeys()
00075 { freeKeys(); }
00076
00077
00078 bool loadRC(const char* rcfile);
00079
00080 void showKeys(Display * d);
00081 void print_key(Display * d, Keys_t * key);
00082 void grab_keys (Display * dpy);
00083
00084 protected:
00085
00086 void init();
00087 void initKeys();
00088 void freeKeys();
00089
00090 bool add_key(KeyType_t type, EventType_t event_type, KeySym keysym, KeyCode keycode,
00091 unsigned int button, unsigned int modifier, char *command, const char* rc_file);
00092
00093
00094 void set_keysym (Keys_t * key, EventType_t event_type, KeySym keysym,
00095 unsigned int modifier, char *command);
00096 void set_keycode (Keys_t * key, EventType_t event_type, KeySym keycode,
00097 unsigned int modifier, char *command);
00098 void set_button (Keys_t * key, EventType_t event_type, unsigned int button,
00099 unsigned int modifier, char *command);
00100 void free_key (Keys_t * key);
00101
00102 void modifier_to_string (unsigned int modifier, char *str);
00103
00104 void my_grab_button (Display * dpy, unsigned int button, unsigned int modifier,
00105 Window win);
00106 void my_grab_key (Display * dpy, KeyCode keycode, unsigned int modifier,
00107 Window win);
00108
00109 public:
00110
00111 int nb_keys;
00112 Keys_t *keys;
00113
00114 unsigned int numlock_mask;
00115 unsigned int scrolllock_mask;
00116 unsigned int capslock_mask;
00117
00118
00119 protected:
00120
00121 bool verbose;
00122
00123 };
00124 }
00125
00126
00127 #endif
00128
00129 #endif
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145