[hackers] [PATCH 5/8] drw: fixup drw_rect function

From: Markus Teich <markus.teich_AT_stusta.mhn.de>
Date: Sun, 22 May 2016 22:29:22 +0200

- drw_rect was just setting the color when filled == empty == 0. If you don't
  want to draw a rectangle, you should not call drw_rect.
- parameters w and h now also specify the result exactly.
---
 drw.c | 10 +++++-----
 drw.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drw.c b/drw.c
index e56cb47..88d4eac 100644
--- a/drw.c
+++ b/drw.c
_AT_@ -216,15 +216,15 @@ drw_setscheme(Drw *drw, Scm scm)
 }
 
 void
-drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert)
+drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
 {
-	if (!drw->scheme)
+	if (!drw || !drw->scheme)
 		return;
 	XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
 	if (filled)
-		XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w + 1, h + 1);
-	else if (empty)
-		XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
+		XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
+	else
+		XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
 }
 
 int
diff --git a/drw.h b/drw.h
index 61633d9..8ce6bc5 100644
--- a/drw.h
+++ b/drw.h
_AT_@ -53,7 +53,7 @@ void drw_setfont(Drw *drw, Fnt *font);
 void drw_setscheme(Drw *drw, Scm scm);
 
 /* Drawing functions */
-void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert);
+void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
 int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert);
 
 /* Map functions */
-- 
2.7.3
Received on Sun May 22 2016 - 22:29:22 CEST

This archive was generated by hypermail 2.3.0 : Sun May 22 2016 - 22:36:27 CEST