fixed crash on zoom if only 1 client exists
6797ff84
1 file(s) · +9 −3
| 28 | 28 | void |
|
| 29 | 29 | zoom(Arg *arg) |
|
| 30 | 30 | { |
|
| 31 | - | Client **l; |
|
| 31 | + | Client **l, *c; |
|
| 32 | 32 | ||
| 33 | 33 | if(!sel) |
|
| 34 | 34 | return; |
|
| 35 | 35 | ||
| 36 | - | if(sel == next(clients)) |
|
| 37 | - | sel = next(sel->next); |
|
| 36 | + | if(sel == next(clients) && sel->next) { |
|
| 37 | + | if((c = next(sel->next))) |
|
| 38 | + | sel = c; |
|
| 39 | + | } |
|
| 38 | 40 | ||
| 39 | 41 | for(l = &clients; *l && *l != sel; l = &(*l)->next); |
|
| 40 | 42 | *l = sel->next; |
|
| 497 | 499 | if(c->inch) |
|
| 498 | 500 | c->h -= (c->h - c->baseh) % c->inch; |
|
| 499 | 501 | } |
|
| 502 | + | if(c->x > sw) /* might happen on restart */ |
|
| 503 | + | c->x = sw - c->w; |
|
| 504 | + | if(c->y > sh) |
|
| 505 | + | c->ty = c->y = sh - c->h; |
|
| 500 | 506 | if(c->minw && c->w < c->minw) |
|
| 501 | 507 | c->w = c->minw; |
|
| 502 | 508 | if(c->minh && c->h < c->minh) |
|