- p = curpos ? curpos->first_child : firstnode;
- while (p) {
- grab_key(p->key, p->state, GrabModeAsync);
- p = p->next_sibling;
+ if (grab) {
+ p = curpos ? curpos->first_child : firstnode;
+ while (p) {
+ grab_key(p->key, p->state, win, GrabModeAsync);
+ p = p->next_sibling;
+ }
+ if (curpos)
+ grab_key(reset_key, reset_state, win, GrabModeAsync);