+ static KeyBindingTree *grabbed_key = NULL;
+
+ if (grabbed_key) {
+ gboolean done = FALSE;
+
+ if ((e->type == Event_X_KeyRelease &&
+ !(grabbed_key->state & e->data.x.e->xkey.state)))
+ done = TRUE;
+ else if (e->type == Event_X_KeyPress) {
+ if (e->data.x.e->xkey.keycode == button_return)
+ done = TRUE;
+ else if (e->data.x.e->xkey.keycode == button_escape) {
+ grabbed_key->action->data.cycle.cancel = TRUE;
+ done = TRUE;
+ }
+ }
+ if (done) {
+ grabbed_key->action->data.cycle.final = TRUE;
+ grabbed_key->action->func(&grabbed_key->action->data);
+ grab_keyboard(FALSE);
+ grabbed_key = NULL;
+ reset_chains();
+ return;
+ }
+ }
+ if (e->type == Event_X_KeyRelease)
+ return;
+
+ g_assert(e->type == Event_X_KeyPress);
+