changed caps lock detection to use LockMask, so the actual key can be used for Mod4, etc.

This commit is contained in:
markt 2007-04-05 16:07:01 +00:00
parent e89d4aa219
commit b09aae8579
3 changed files with 11 additions and 10 deletions

View file

@ -1,5 +1,8 @@
(Format: Year/Month/Day) (Format: Year/Month/Day)
Changes for 1.0.0: Changes for 1.0.0:
*07/04/05:
* Adjusted detection of Caps Lock key (Mark)
FbTk/KeyUtil.cc/hh
*07/04/01: *07/04/01:
* Fixed a problem with windows being created in iconic state (Mark) * Fixed a problem with windows being created in iconic state (Mark)
Window.cc Screen.cc fluxbox.cc Window.cc Screen.cc fluxbox.cc

View file

@ -62,7 +62,7 @@ KeyUtil &KeyUtil::instance() {
KeyUtil::KeyUtil() KeyUtil::KeyUtil()
: m_modmap(0), m_capslock(0), m_numlock(0), m_scrolllock(0) : m_modmap(0), m_numlock(0), m_scrolllock(0)
{ {
init(); init();
} }
@ -93,9 +93,9 @@ void KeyUtil::loadModmap() {
m_modmap->modifiermap[realkey], 0); m_modmap->modifiermap[realkey], 0);
switch (ks) { switch (ks) {
case XK_Caps_Lock: // we just want to clean the Lock modifier, not specifically the
m_capslock = modlist[i].mask; // XK_Caps_Lock key
break; // the others tend to vary from distro to distro, though
case XK_Scroll_Lock: case XK_Scroll_Lock:
m_scrolllock = modlist[i].mask; m_scrolllock = modlist[i].mask;
break; break;
@ -114,13 +114,12 @@ void KeyUtil::loadModmap() {
*/ */
void KeyUtil::grabKey(unsigned int key, unsigned int mod, Window win) { void KeyUtil::grabKey(unsigned int key, unsigned int mod, Window win) {
Display *display = App::instance()->display(); Display *display = App::instance()->display();
const unsigned int capsmod = instance().capslock();
const unsigned int nummod = instance().numlock(); const unsigned int nummod = instance().numlock();
const unsigned int scrollmod = instance().scrolllock(); const unsigned int scrollmod = instance().scrolllock();
// Grab with numlock, capslock and scrlock // Grab with numlock, capslock and scrlock
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
XGrabKey(display, key, mod | (i & 1 ? capsmod : 0) | XGrabKey(display, key, mod | (i & 1 ? LockMask : 0) |
(i & 2 ? nummod : 0) | (i & 4 ? scrollmod : 0), (i & 2 ? nummod : 0) | (i & 4 ? scrollmod : 0),
win, True, GrabModeAsync, GrabModeAsync); win, True, GrabModeAsync, GrabModeAsync);
} }
@ -130,13 +129,12 @@ void KeyUtil::grabKey(unsigned int key, unsigned int mod, Window win) {
void KeyUtil::grabButton(unsigned int button, unsigned int mod, Window win, void KeyUtil::grabButton(unsigned int button, unsigned int mod, Window win,
unsigned int event_mask, Cursor cursor) { unsigned int event_mask, Cursor cursor) {
Display *display = App::instance()->display(); Display *display = App::instance()->display();
const unsigned int capsmod = instance().capslock();
const unsigned int nummod = instance().numlock(); const unsigned int nummod = instance().numlock();
const unsigned int scrollmod = instance().scrolllock(); const unsigned int scrollmod = instance().scrolllock();
// Grab with numlock, capslock and scrlock // Grab with numlock, capslock and scrlock
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
XGrabButton(display, button, mod | (i & 1 ? capsmod : 0) | XGrabButton(display, button, mod | (i & 1 ? LockMask : 0) |
(i & 2 ? nummod : 0) | (i & 4 ? scrollmod : 0), (i & 2 ? nummod : 0) | (i & 4 ? scrollmod : 0),
win, False, event_mask, GrabModeAsync, GrabModeAsync, win, False, event_mask, GrabModeAsync, GrabModeAsync,
None, cursor); None, cursor);

View file

@ -87,14 +87,14 @@ public:
*/ */
static unsigned int keycodeToModmask(unsigned int keycode); static unsigned int keycodeToModmask(unsigned int keycode);
int numlock() const { return m_numlock; } int numlock() const { return m_numlock; }
int capslock() const { return m_capslock; } int capslock() const { return LockMask; }
int scrolllock() const { return m_scrolllock; } int scrolllock() const { return m_scrolllock; }
private: private:
void loadModmap(); void loadModmap();
XModifierKeymap *m_modmap; XModifierKeymap *m_modmap;
int m_capslock, m_numlock, m_scrolllock; int m_numlock, m_scrolllock;
static std::auto_ptr<KeyUtil> s_keyutil; static std::auto_ptr<KeyUtil> s_keyutil;
}; };