diff options
Diffstat (limited to 'client.c')
| -rw-r--r-- | client.c | 34 |
1 files changed, 14 insertions, 20 deletions
| @@ -7,8 +7,8 @@ | |||
| 7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | #include <X11/Xatom.h> | 9 | #include <X11/Xatom.h> |
| 10 | #include <X11/Xutil.h> | ||
| 10 | 11 | ||
| 11 | #include "util.h" | ||
| 12 | #include "wm.h" | 12 | #include "wm.h" |
| 13 | 13 | ||
| 14 | void (*arrange)(void *aux); | 14 | void (*arrange)(void *aux); |
| @@ -19,9 +19,9 @@ max(void *aux) | |||
| 19 | if(!stack) | 19 | if(!stack) |
| 20 | return; | 20 | return; |
| 21 | stack->x = sx; | 21 | stack->x = sx; |
| 22 | stack->y = bh; | 22 | stack->y = sy; |
| 23 | stack->w = sw - 2 * stack->border; | 23 | stack->w = sw - 2 * stack->border; |
| 24 | stack->h = sh - bh - 2 * stack->border; | 24 | stack->h = sh - 2 * stack->border; |
| 25 | resize(stack); | 25 | resize(stack); |
| 26 | discard_events(EnterWindowMask); | 26 | discard_events(EnterWindowMask); |
| 27 | } | 27 | } |
| @@ -59,11 +59,11 @@ grid(void *aux) | |||
| 59 | cols = rows; | 59 | cols = rows; |
| 60 | 60 | ||
| 61 | gw = (sw - 2) / cols; | 61 | gw = (sw - 2) / cols; |
| 62 | gh = (sh - bh - 2) / rows; | 62 | gh = (sh - 2) / rows; |
| 63 | 63 | ||
| 64 | for(i = j = 0, c = clients; c; c = c->next) { | 64 | for(i = j = 0, c = clients; c; c = c->next) { |
| 65 | c->x = i * gw; | 65 | c->x = i * gw; |
| 66 | c->y = j * gh + bh; | 66 | c->y = j * gh; |
| 67 | c->w = gw; | 67 | c->w = gw; |
| 68 | c->h = gh; | 68 | c->h = gh; |
| 69 | resize(c); | 69 | resize(c); |
| @@ -89,12 +89,12 @@ sel(void *aux) | |||
| 89 | for(c = stack; c && c->snext; c = c->snext); | 89 | for(c = stack; c && c->snext; c = c->snext); |
| 90 | if(!c) | 90 | if(!c) |
| 91 | c = stack; | 91 | c = stack; |
| 92 | raise(c); | 92 | craise(c); |
| 93 | focus(c); | 93 | focus(c); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | void | 96 | void |
| 97 | kill(void *aux) | 97 | ckill(void *aux) |
| 98 | { | 98 | { |
| 99 | Client *c = stack; | 99 | Client *c = stack; |
| 100 | 100 | ||
| @@ -114,8 +114,8 @@ resize_title(Client *c) | |||
| 114 | c->tw = 0; | 114 | c->tw = 0; |
| 115 | for(i = 0; i < TLast; i++) | 115 | for(i = 0; i < TLast; i++) |
| 116 | if(c->tags[i]) | 116 | if(c->tags[i]) |
| 117 | c->tw += textw(&brush.font, c->tags[i]) + bh; | 117 | c->tw += textw(&brush.font, c->tags[i]) + brush.font.height; |
| 118 | c->tw += textw(&brush.font, c->name) + bh; | 118 | c->tw += textw(&brush.font, c->name) + brush.font.height; |
| 119 | if(c->tw > c->w) | 119 | if(c->tw > c->w) |
| 120 | c->tw = c->w + 2; | 120 | c->tw = c->w + 2; |
| 121 | c->tx = c->x + c->w - c->tw + 2; | 121 | c->tx = c->x + c->w - c->tw + 2; |
| @@ -190,7 +190,7 @@ update_size(Client *c) | |||
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | void | 192 | void |
| 193 | raise(Client *c) | 193 | craise(Client *c) |
| 194 | { | 194 | { |
| 195 | XRaiseWindow(dpy, c->win); | 195 | XRaiseWindow(dpy, c->win); |
| 196 | XRaiseWindow(dpy, c->title); | 196 | XRaiseWindow(dpy, c->title); |
| @@ -234,11 +234,9 @@ manage(Window w, XWindowAttributes *wa) | |||
| 234 | c->win = w; | 234 | c->win = w; |
| 235 | c->tx = c->x = wa->x; | 235 | c->tx = c->x = wa->x; |
| 236 | c->ty = c->y = wa->y; | 236 | c->ty = c->y = wa->y; |
| 237 | if(c->y < bh) | ||
| 238 | c->ty = c->y += bh; | ||
| 239 | c->tw = c->w = wa->width; | 237 | c->tw = c->w = wa->width; |
| 240 | c->h = wa->height; | 238 | c->h = wa->height; |
| 241 | c->th = bh; | 239 | c->th = th; |
| 242 | c->border = 1; | 240 | c->border = 1; |
| 243 | update_size(c); | 241 | update_size(c); |
| 244 | XSetWindowBorderWidth(dpy, c->win, 1); | 242 | XSetWindowBorderWidth(dpy, c->win, 1); |
| @@ -379,10 +377,8 @@ unmanage(Client *c) | |||
| 379 | XDestroyWindow(dpy, c->title); | 377 | XDestroyWindow(dpy, c->title); |
| 380 | 378 | ||
| 381 | for(l=&clients; *l && *l != c; l=&(*l)->next); | 379 | for(l=&clients; *l && *l != c; l=&(*l)->next); |
| 382 | eassert(*l == c); | ||
| 383 | *l = c->next; | 380 | *l = c->next; |
| 384 | for(l=&stack; *l && *l != c; l=&(*l)->snext); | 381 | for(l=&stack; *l && *l != c; l=&(*l)->snext); |
| 385 | eassert(*l == c); | ||
| 386 | *l = c->snext; | 382 | *l = c->snext; |
| 387 | free(c); | 383 | free(c); |
| 388 | 384 | ||
| @@ -418,10 +414,8 @@ void | |||
| 418 | draw_client(Client *c) | 414 | draw_client(Client *c) |
| 419 | { | 415 | { |
| 420 | int i; | 416 | int i; |
| 421 | if(c == stack) { | 417 | if(c == stack) |
| 422 | draw_bar(); | ||
| 423 | return; | 418 | return; |
| 424 | } | ||
| 425 | 419 | ||
| 426 | brush.x = brush.y = 0; | 420 | brush.x = brush.y = 0; |
| 427 | brush.h = c->th; | 421 | brush.h = c->th; |
| @@ -430,12 +424,12 @@ draw_client(Client *c) | |||
| 430 | for(i = 0; i < TLast; i++) { | 424 | for(i = 0; i < TLast; i++) { |
| 431 | if(c->tags[i]) { | 425 | if(c->tags[i]) { |
| 432 | brush.x += brush.w; | 426 | brush.x += brush.w; |
| 433 | brush.w = textw(&brush.font, c->tags[i]) + bh; | 427 | brush.w = textw(&brush.font, c->tags[i]) + brush.font.height; |
| 434 | draw(dpy, &brush, True, c->tags[i]); | 428 | draw(dpy, &brush, True, c->tags[i]); |
| 435 | } | 429 | } |
| 436 | } | 430 | } |
| 437 | brush.x += brush.w; | 431 | brush.x += brush.w; |
| 438 | brush.w = textw(&brush.font, c->name) + bh; | 432 | brush.w = textw(&brush.font, c->name) + brush.font.height; |
| 439 | draw(dpy, &brush, True, c->name); | 433 | draw(dpy, &brush, True, c->name); |
| 440 | XCopyArea(dpy, brush.drawable, c->title, brush.gc, | 434 | XCopyArea(dpy, brush.drawable, c->title, brush.gc, |
| 441 | 0, 0, c->tw, c->th, 0, 0); | 435 | 0, 0, c->tw, c->th, 0, 0); |
