- TAILQ_FOREACH(kp, &keys, entry)
- if (keysym == kp->keysym
- && CLEANMASK(kp->mod) == CLEANMASK(ev->state)
- && keyfuncs[kp->funcid].func) {
- if (kp->funcid == kf_spawn_custom)
- spawn_custom(
- root_to_region(ev->root),
- &(keyfuncs[kp->funcid].args),
- kp->spawn_name
- );
- else
- keyfuncs[kp->funcid].func(
- root_to_region(ev->root),
- &(keyfuncs[kp->funcid].args)
- );
- }
+ if ((kp = key_lookup(CLEANMASK(ev->state), keysym)) == NULL)
+ return;
+ if (keyfuncs[kp->funcid].func == NULL)
+ return;
+
+ r = root_to_region(ev->root);
+ if (kp->funcid == kf_spawn_custom)
+ spawn_custom(r, &(keyfuncs[kp->funcid].args), kp->spawn_name);
+ else
+ keyfuncs[kp->funcid].func(r, &(keyfuncs[kp->funcid].args));