diff options
author | MicroJoe <microjoe@mailoo.org> | 2012-07-07 19:10:37 +0200 |
---|---|---|
committer | MicroJoe <microjoe@mailoo.org> | 2012-07-07 19:10:37 +0200 |
commit | 29e9cee5fbef42389facc6520c0373aa07f2e455 (patch) | |
tree | 3131ec0e58b52bfb76d81357923cd1808569c72f | |
parent | 6d5ffbe33f7514d2e0d7cc447bdd257a8aaeeb2b (diff) | |
download | wmfs-29e9cee5fbef42389facc6520c0373aa07f2e455.zip wmfs-29e9cee5fbef42389facc6520c0373aa07f2e455.tar.gz wmfs-29e9cee5fbef42389facc6520c0373aa07f2e455.tar.bz2 |
Prevent graph from drawing overflow
-rw-r--r-- | src/status.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/status.c b/src/status.c index b7245a5..7b98667 100644 --- a/src/status.c +++ b/src/status.c @@ -72,6 +72,7 @@ static void status_graph_draw(struct status_ctx *ctx, struct status_seq *sq, struct status_gcache *gc) { int i, j, y; + float c; int ys = sq->geo.y + sq->geo.h - 1; XSetForeground(W->dpy, W->gc, sq->color2); @@ -83,7 +84,8 @@ status_graph_draw(struct status_ctx *ctx, struct status_seq *sq, struct status_g /* You divided by zero didn't you? */ if(gc->datas[j]) { - y = ys - (sq->geo.h / ((float)sq->data[2] / (float)gc->datas[j])) + 1; + c = (float)sq->data[2] / (float)gc->datas[j]; + y = ys - (sq->geo.h / (c > 1 ? c : 1)) + 1; draw_line(ctx->barwin->dr, i, y, i, ys); } } |