diff options
-rw-r--r-- | src/FbTk/KeyUtil.cc | 43 | ||||
-rw-r--r-- | src/FbTk/KeyUtil.hh | 9 |
2 files changed, 44 insertions, 8 deletions
diff --git a/src/FbTk/KeyUtil.cc b/src/FbTk/KeyUtil.cc index 72e78eb..952463c 100644 --- a/src/FbTk/KeyUtil.cc +++ b/src/FbTk/KeyUtil.cc | |||
@@ -19,7 +19,7 @@ | |||
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.cc,v 1.4 2003/10/13 19:31:56 fluxgen Exp $ | 22 | // $Id: KeyUtil.cc,v 1.5 2003/12/30 18:11:44 fluxgen Exp $ |
23 | 23 | ||
24 | #include "KeyUtil.hh" | 24 | #include "KeyUtil.hh" |
25 | #include "App.hh" | 25 | #include "App.hh" |
@@ -57,6 +57,41 @@ void KeyUtil::loadModmap() { | |||
57 | XFreeModifiermap(m_modmap); | 57 | XFreeModifiermap(m_modmap); |
58 | 58 | ||
59 | m_modmap = XGetModifierMapping(App::instance()->display()); | 59 | m_modmap = XGetModifierMapping(App::instance()->display()); |
60 | // mask to use for modifier | ||
61 | int mods[] = { | ||
62 | ShiftMask, | ||
63 | LockMask, | ||
64 | ControlMask, | ||
65 | Mod1Mask, | ||
66 | Mod2Mask, | ||
67 | Mod3Mask, | ||
68 | Mod4Mask, | ||
69 | Mod5Mask, | ||
70 | 0 | ||
71 | }; | ||
72 | |||
73 | // find modifiers and set them | ||
74 | for (int i=0, realkey=0; i<8; ++i) { | ||
75 | for (int key=0; key<m_modmap->max_keypermod; ++key, ++realkey) { | ||
76 | |||
77 | if (m_modmap->modifiermap[realkey] == 0) | ||
78 | continue; | ||
79 | |||
80 | KeySym ks = XKeycodeToKeysym(App::instance()->display(), m_modmap->modifiermap[realkey], 0); | ||
81 | |||
82 | switch (ks) { | ||
83 | case XK_Caps_Lock: | ||
84 | m_capslock = mods[i]; | ||
85 | break; | ||
86 | case XK_Scroll_Lock: | ||
87 | m_scrolllock = mods[i]; | ||
88 | break; | ||
89 | case XK_Num_Lock: | ||
90 | m_numlock = mods[i]; | ||
91 | break; | ||
92 | } | ||
93 | } | ||
94 | } | ||
60 | } | 95 | } |
61 | 96 | ||
62 | 97 | ||
@@ -67,9 +102,9 @@ void KeyUtil::loadModmap() { | |||
67 | */ | 102 | */ |
68 | void KeyUtil::grabKey(unsigned int key, unsigned int mod) { | 103 | void KeyUtil::grabKey(unsigned int key, unsigned int mod) { |
69 | Display *display = App::instance()->display(); | 104 | Display *display = App::instance()->display(); |
70 | const unsigned int capsmod = LockMask; | 105 | const unsigned int capsmod = instance().m_capslock; |
71 | const unsigned int nummod = Mod2Mask; | 106 | const unsigned int nummod = instance().m_numlock; |
72 | const unsigned int scrollmod = Mod5Mask; | 107 | const unsigned int scrollmod = instance().m_scrolllock; |
73 | 108 | ||
74 | for (int screen=0; screen<ScreenCount(display); screen++) { | 109 | for (int screen=0; screen<ScreenCount(display); screen++) { |
75 | 110 | ||
diff --git a/src/FbTk/KeyUtil.hh b/src/FbTk/KeyUtil.hh index d1f1706..5b5cb3e 100644 --- a/src/FbTk/KeyUtil.hh +++ b/src/FbTk/KeyUtil.hh | |||
@@ -19,7 +19,7 @@ | |||
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.4 2003/12/16 17:06:51 fluxgen Exp $ | 22 | // $Id: KeyUtil.hh,v 1.5 2003/12/30 18:10:43 fluxgen Exp $ |
23 | 23 | ||
24 | #ifndef FBTK_KEYUTIL_HH | 24 | #ifndef FBTK_KEYUTIL_HH |
25 | #define FBTK_KEYUTIL_HH | 25 | #define FBTK_KEYUTIL_HH |
@@ -65,9 +65,9 @@ public: | |||
65 | Strip out modifiers we want to ignore | 65 | Strip out modifiers we want to ignore |
66 | @return the cleaned state number | 66 | @return the cleaned state number |
67 | */ | 67 | */ |
68 | static unsigned int cleanMods(unsigned int mods) { | 68 | unsigned int cleanMods(unsigned int mods) { |
69 | //remove numlock(Mod2), capslock and scrolllock(Mod5) | 69 | //remove numlock, capslock and scrolllock |
70 | return mods & ~(LockMask | Mod2Mask | Mod5Mask); | 70 | return mods & ~(m_capslock | m_numlock | m_scrolllock); |
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
@@ -80,6 +80,7 @@ private: | |||
80 | void loadModmap(); | 80 | void loadModmap(); |
81 | 81 | ||
82 | XModifierKeymap *m_modmap; | 82 | XModifierKeymap *m_modmap; |
83 | int m_capslock, m_numlock, m_scrolllock; | ||
83 | static std::auto_ptr<KeyUtil> s_keyutil; | 84 | static std::auto_ptr<KeyUtil> s_keyutil; |
84 | }; | 85 | }; |
85 | 86 | ||