[PATCH 2/5] drw: fixup drw_rect function

From: Markus Teich <markus.teich_AT_stusta.mhn.de>
Date: Sun, 12 Apr 2015 22:56:56 +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 82361a0..55dbbb8 100644
--- a/drw.c
+++ b/drw.c
_AT_@ -216,15 +216,15 @@ drw_setscheme(Drw *drw, Clr *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 f8012af..55a33e4 100644
--- a/drw.h
+++ b/drw.h
_AT_@ -53,7 +53,7 @@ void drw_setfont(Drw *drw, Fnt *font);
 void drw_setscheme(Drw *drw, Clr *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
--mYCpIKhGyMATD0i+
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment; filename="libsl6.patch"
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Tue May 24 2016 - 20:00:14 CEST