drw: fixup drw_rect function

This commit is contained in:
Markus Teich 2015-04-12 22:56:56 +02:00
parent edb657eb96
commit 87ef23296b
2 changed files with 8 additions and 10 deletions

14
drw.c
View File

@ -204,17 +204,15 @@ drw_setscheme(Drw *drw, Scm *scm) {
} }
void 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)
int dx; {
if (!drw || !drw->scheme)
if(!drw || !drw->fontcount || !drw->scheme)
return; return;
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->bg.pix : drw->scheme->fg.pix); XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->bg.pix : drw->scheme->fg.pix);
dx = (drw->fonts[0]->ascent + drw->fonts[0]->descent + 2) / 4;
if (filled) if (filled)
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x+1, y+1, dx+1, dx+1); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
else if(empty) else
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x+1, y+1, dx, dx); XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
} }
int int

2
drw.h
View File

@ -57,7 +57,7 @@ void drw_setfont(Drw *drw, Fnt *font);
void drw_setscheme(Drw *drw, Scm *scm); void drw_setscheme(Drw *drw, Scm *scm);
/* Drawing functions */ /* 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); int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert);
/* Map functions */ /* Map functions */