diff options
Diffstat (limited to 'src/FbTk/KeyUtil.hh')
-rw-r--r-- | src/FbTk/KeyUtil.hh | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/src/FbTk/KeyUtil.hh b/src/FbTk/KeyUtil.hh index 9e872d6..a6051f6 100644 --- a/src/FbTk/KeyUtil.hh +++ b/src/FbTk/KeyUtil.hh | |||
@@ -19,34 +19,66 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: KeyUtil.hh,v 1.1 2003/09/06 15:46:00 fluxgen Exp $ | 22 | // $Id: KeyUtil.hh,v 1.2 2003/10/05 07:20:35 rathnor Exp $ |
23 | 23 | ||
24 | #ifndef FBTK_KEYUTIL_HH | 24 | #ifndef FBTK_KEYUTIL_HH |
25 | #define FBTK_KEYUTIL_HH | 25 | #define FBTK_KEYUTIL_HH |
26 | 26 | ||
27 | #include <X11/Xlib.h> | ||
28 | #include <X11/keysym.h> | ||
29 | |||
27 | namespace FbTk { | 30 | namespace FbTk { |
28 | 31 | ||
29 | class KeyUtil { | 32 | class KeyUtil { |
30 | public: | 33 | public: |
34 | |||
35 | KeyUtil(); | ||
36 | ~KeyUtil(); | ||
37 | |||
38 | void init(); | ||
39 | static KeyUtil *instance(); | ||
40 | |||
41 | /** | ||
42 | Grab the specified key | ||
43 | */ | ||
44 | static void grabKey(unsigned int key, unsigned int mod); | ||
45 | |||
46 | /** | ||
47 | convert the string to the keysym | ||
48 | @return the keysym corresponding to the string, or zero | ||
49 | */ | ||
50 | static unsigned int getKey(const char *keystr); | ||
51 | |||
52 | /** | ||
53 | @return the modifier for the modstr else zero on failure. | ||
54 | */ | ||
55 | static unsigned int KeyUtil::getModifier(const char *modstr); | ||
56 | |||
57 | /** | ||
58 | ungrabs all keys | ||
59 | */ | ||
60 | static void ungrabKeys(); | ||
61 | |||
31 | /** | 62 | /** |
32 | Strip out modifiers we want to ignore | 63 | Strip out modifiers we want to ignore |
33 | @return the cleaned state number | 64 | @return the cleaned state number |
34 | */ | 65 | */ |
35 | static unsigned int cleanMods(unsigned int mods) { | 66 | static unsigned int cleanMods(unsigned int mods) { |
36 | if (!s_init) | 67 | //remove numlock(Mod2), capslock and scrolllock(Mod5) |
37 | init(); | 68 | return mods & ~(LockMask | Mod2Mask | Mod5Mask); |
38 | //remove numlock, capslock and scrolllock | ||
39 | return mods & (~s_capslock_mod & ~s_numlock_mod & ~s_scrolllock_mod); | ||
40 | } | 69 | } |
41 | 70 | ||
42 | static int capslockMod() { if (!s_init) init(); return s_capslock_mod; } | 71 | /** |
43 | static int numlockMod() { if (!s_init) init(); return s_numlock_mod; } | 72 | Convert the specified key into appropriate modifier mask |
44 | static int scrolllockMod() { if (!s_init) init(); return s_scrolllock_mod; } | 73 | @return corresponding modifier mask |
45 | /// so one can force a reinit of modifiers | 74 | */ |
46 | static void init(); | 75 | static unsigned int keycodeToModmask(unsigned int keycode); |
76 | |||
47 | private: | 77 | private: |
48 | static int s_capslock_mod, s_numlock_mod, s_scrolllock_mod; ///< modifiers | 78 | void loadModmap(); |
49 | static bool s_init; | 79 | |
80 | XModifierKeymap *m_modmap; | ||
81 | static KeyUtil *s_keyutil; | ||
50 | }; | 82 | }; |
51 | 83 | ||
52 | } // end namespace FbTk | 84 | } // end namespace FbTk |