aboutsummaryrefslogtreecommitdiff
path: root/src/Keys.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-04-15 00:50:25 (GMT)
committerrathnor <rathnor>2003-04-15 00:50:25 (GMT)
commit58e19dc91eba51739d4b8ed2dfdbb49e28d96379 (patch)
tree1fbb529d593c1b1b1fabb76832a97783649cab23 /src/Keys.cc
parent1aa5ede1b70dfba6519eeaa38101948bbdfea8a2 (diff)
downloadfluxbox-58e19dc91eba51739d4b8ed2dfdbb49e28d96379.zip
fluxbox-58e19dc91eba51739d4b8ed2dfdbb49e28d96379.tar.bz2
add most recently used window cycling (Simon)
It is now the default cycling action
Diffstat (limited to 'src/Keys.cc')
-rw-r--r--src/Keys.cc48
1 files changed, 36 insertions, 12 deletions
diff --git a/src/Keys.cc b/src/Keys.cc
index 8d705c1..02cfabd 100644
--- a/src/Keys.cc
+++ b/src/Keys.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: Keys.cc,v 1.24 2003/04/14 12:10:16 fluxgen Exp $ 22//$Id: Keys.cc,v 1.25 2003/04/15 00:50:24 rathnor Exp $
23 23
24 24
25#include "Keys.hh" 25#include "Keys.hh"
@@ -140,14 +140,18 @@ Keys::Keys(const char *filename):
140 m_numlock_mod(0), 140 m_numlock_mod(0),
141 m_scrolllock_mod(0), 141 m_scrolllock_mod(0),
142 m_abortkey(0), 142 m_abortkey(0),
143 m_display(FbTk::App::instance()->display()) 143 m_display(FbTk::App::instance()->display()),
144 m_modmap(0)
144{ 145{
145 determineModmap(); 146 loadModmap();
146 if (filename != 0) 147 if (filename != 0)
147 load(filename); 148 load(filename);
148} 149}
149 150
150Keys::~Keys() { 151Keys::~Keys() {
152 if (m_modmap) {
153 XFreeModifiermap(m_modmap);
154 }
151 ungrabKeys(); 155 ungrabKeys();
152 deleteTree(); 156 deleteTree();
153} 157}
@@ -458,7 +462,7 @@ unsigned int Keys::getKey(const char *keystr) {
458Keys::KeyAction Keys::getAction(XKeyEvent *ke) { 462Keys::KeyAction Keys::getAction(XKeyEvent *ke) {
459 static t_key *next_key = 0; 463 static t_key *next_key = 0;
460 //remove numlock, capslock and scrolllock 464 //remove numlock, capslock and scrolllock
461 ke->state &= ~Mod2Mask & ~Mod5Mask & ~LockMask; 465 ke->state = cleanMods(ke->state);
462 466
463 if (m_abortkey && *m_abortkey==ke) { //abort current keychain 467 if (m_abortkey && *m_abortkey==ke) { //abort current keychain
464 next_key = 0; 468 next_key = 0;
@@ -636,9 +640,14 @@ Keys::t_key::~t_key() {
636} 640}
637 641
638/** 642/**
639 determines modifier mapping for caps, num and scroll lock 643 * load state relating to the modifier map
640*/ 644 */
641void Keys::determineModmap() { 645void Keys::loadModmap() {
646 if (m_modmap) {
647 XFreeModifiermap(m_modmap);
648 }
649 m_modmap = XGetModifierMapping(m_display);
650
642 // mask to use for modifier 651 // mask to use for modifier
643 int mods[] = { 652 int mods[] = {
644 ShiftMask, 653 ShiftMask,
@@ -652,15 +661,14 @@ void Keys::determineModmap() {
652 0 661 0
653 }; 662 };
654 663
655 XModifierKeymap *map = XGetModifierMapping(m_display);
656 // find modifiers and set them 664 // find modifiers and set them
657 for (int i=0, realkey=0; i<8; ++i) { 665 for (int i=0, realkey=0; i<8; ++i) {
658 for (int key=0; key<map->max_keypermod; ++key, ++realkey) { 666 for (int key=0; key<m_modmap->max_keypermod; ++key, ++realkey) {
659 667
660 if (map->modifiermap[realkey] == 0) 668 if (m_modmap->modifiermap[realkey] == 0)
661 continue; 669 continue;
662 670
663 KeySym ks = XKeycodeToKeysym(m_display, map->modifiermap[realkey], 0); 671 KeySym ks = XKeycodeToKeysym(m_display, m_modmap->modifiermap[realkey], 0);
664 672
665 switch (ks) { 673 switch (ks) {
666 case XK_Caps_Lock: 674 case XK_Caps_Lock:
@@ -675,5 +683,21 @@ void Keys::determineModmap() {
675 } 683 }
676 } 684 }
677 } 685 }
678 XFreeModifiermap(map); 686}
687
688unsigned int Keys::keycodeToModmask(unsigned int keycode) {
689 if (!m_modmap) return 0;
690
691 // search through modmap for this keycode
692 for (int mod=0; mod < 8; mod++) {
693 for (int key=0; key < m_modmap->max_keypermod; ++key) {
694 // modifiermap is an array with 8 sets of keycodes
695 // each max_keypermod long, but in a linear array.
696 if (m_modmap->modifiermap[m_modmap->max_keypermod*mod + key] == keycode) {
697 return (1<<mod);
698 }
699 }
700 }
701 // no luck
702 return 0;
679} 703}