- for (it = node->children.begin(); it != end; ++it)
- if ( (*it)->action )
- scr->ungrabKey( (*it)->action->keycode(), (*it)->action->modifierMask());
+ bool ungrab = true;
+
+ // when ungrabbing children, make sure that we don't ungrab any topmost keys
+ // (children of the head node) This would render those topmost keys useless.
+ // Topmost keys are _never_ ungrabbed, since they are only grabbed at startup
+
+ for (it = node->children.begin(); it != end; ++it) {
+ if ( (*it)->action ) {
+ for (head_it = _head->children.begin(); head_it != head_end; ++head_it) {
+ if ( (*it)->action->modifierMask() == (*head_it)->action->modifierMask() &&
+ (*it)->action->keycode() == (*head_it)->action->keycode())
+ {
+ ungrab = false;
+ break;
+ }
+ }
+
+ if (ungrab)
+ scr->ungrabKey( (*it)->action->keycode(), (*it)->action->modifierMask());
+
+ ungrab = true;
+ }
+ }