X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Factions.cc;h=e2999b768360776d8d7ac7f599eadf6ab8f7ca94;hb=b760c466567dc06fa41dfb5a301192c251a5fc85;hp=65546167da65e7082e04d75c0d9ea47aac510b6f;hpb=4c5671eecae90077dd930bf36af3be9e13305985;p=chaz%2Fopenbox diff --git a/src/actions.cc b/src/actions.cc index 65546167..e2999b76 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -206,6 +206,7 @@ void Actions::leaveHandler(const XCrossingEvent &e) void Actions::keyPressHandler(const XKeyEvent &e) { + printf("press\n"); otk::EventHandler::keyPressHandler(e); // kill off the Button1Mask etc, only want the modifiers @@ -213,7 +214,41 @@ void Actions::keyPressHandler(const XKeyEvent &e) Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); openbox->bindings()-> fireKey(otk::display->findScreen(e.root)->screen(), - state, e.keycode, e.time); + state, e.keycode, e.time, EventKeyPress); +} + + +void Actions::keyReleaseHandler(const XKeyEvent &e) +{ + printf("release\n"); + otk::EventHandler::keyReleaseHandler(e); + + // kill off the Button1Mask etc, only want the modifiers + unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask | + Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); + + // remove from the state the mask of the modifier being released, if it is + // a modifier key being released (XXX this is a little ugly..) + const XModifierKeymap *map = otk::display->modifierMap(); + const int mask_table[] = { + ShiftMask, LockMask, ControlMask, Mod1Mask, + Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask + }; + KeyCode *kp = map->modifiermap; + for (int i = 0, n = sizeof(mask_table)/sizeof(mask_table[0]); i < n; ++i) { + for (int k = 0; k < map->max_keypermod; ++k) { + if (*kp == e.keycode) { // found the keycode + state &= ~mask_table[i]; // remove the mask for it + i = n; // cause the first loop to break; + break; // get outta here! + } + ++kp; + } + } + + openbox->bindings()-> + fireKey(otk::display->findScreen(e.root)->screen(), + state, e.keycode, e.time, EventKeyRelease); }