2
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at fluxbox dot org)
4
// Permission is hereby granted, free of charge, to any person obtaining a
5
// copy of this software and associated documentation files (the "Software"),
6
// to deal in the Software without restriction, including without limitation
7
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
// and/or sell copies of the Software, and to permit persons to whom the
9
// Software is furnished to do so, subject to the following conditions:
11
// The above copyright notice and this permission notice shall be included in
12
// all copies or substantial portions of the Software.
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
// DEALINGS IN THE SOFTWARE.
22
// $Id: KeyUtil.hh 3991 2005-05-06 09:22:53Z mathias $
24
#ifndef FBTK_KEYUTIL_HH
25
#define FBTK_KEYUTIL_HH
28
#include <X11/keysym.h>
41
static KeyUtil &instance();
44
Grab the specified key
46
static void grabKey(unsigned int key, unsigned int mod);
49
convert the string to the keysym
50
@return the keysym corresponding to the string, or zero
52
static unsigned int getKey(const char *keystr);
55
@return the modifier for the modstr else zero on failure.
57
static unsigned int getModifier(const char *modstr);
62
static void ungrabKeys();
65
Strip out modifiers we want to ignore
66
@return the cleaned state number
68
unsigned int cleanMods(unsigned int mods) {
69
//remove numlock, capslock and scrolllock
70
return mods & ~(capslock() | numlock() );
74
strip away everything which is actually not a modifier
75
eg, xkb-keyboardgroups are encoded as bit 13 and 14
77
unsigned int isolateModifierMask(unsigned int mods) {
78
return mods & (ShiftMask|LockMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask);
82
Convert the specified key into appropriate modifier mask
83
@return corresponding modifier mask
85
static unsigned int keycodeToModmask(unsigned int keycode);
86
int numlock() const { return Mod2Mask; } //m_numlock; }
87
int capslock() const { return LockMask; } //m_capslock; }
88
int scrolllock() const { return Mod5Mask; } //m_scrolllock; }
93
XModifierKeymap *m_modmap;
94
int m_capslock, m_numlock, m_scrolllock;
95
static std::auto_ptr<KeyUtil> s_keyutil;
98
} // end namespace FbTk
101
#endif // FBTK_KEYUTIL_HH