drw: a valid (non-NULL) Drw and Fnt context must be passed
don't do these checks on this level. However for resource drw_*_free we will allow it.
This commit is contained in:
parent
5a20b409c6
commit
1f2226df13
19
drw.c
19
drw.c
@ -82,8 +82,6 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
|
|||||||
void
|
void
|
||||||
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
if (!drw)
|
|
||||||
return;
|
|
||||||
drw->w = w;
|
drw->w = w;
|
||||||
drw->h = h;
|
drw->h = h;
|
||||||
if (drw->drawable)
|
if (drw->drawable)
|
||||||
@ -188,8 +186,6 @@ Clr *
|
|||||||
drw_clr_create(Drw *drw, const char *clrname)
|
drw_clr_create(Drw *drw, const char *clrname)
|
||||||
{
|
{
|
||||||
Clr *clr;
|
Clr *clr;
|
||||||
if (!drw)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
clr = ecalloc(1, sizeof(Clr));
|
clr = ecalloc(1, sizeof(Clr));
|
||||||
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||||
@ -210,15 +206,13 @@ drw_clr_free(Clr *clr)
|
|||||||
void
|
void
|
||||||
drw_setscheme(Drw *drw, ClrScheme *scheme)
|
drw_setscheme(Drw *drw, ClrScheme *scheme)
|
||||||
{
|
{
|
||||||
if (!drw)
|
|
||||||
return;
|
|
||||||
drw->scheme = scheme;
|
drw->scheme = scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 empty, int invert)
|
||||||
{
|
{
|
||||||
if (!drw || !drw->scheme)
|
if (!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);
|
||||||
if (filled)
|
if (filled)
|
||||||
@ -369,8 +363,6 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
|
|||||||
void
|
void
|
||||||
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
if (!drw)
|
|
||||||
return;
|
|
||||||
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||||
XSync(drw->dpy, False);
|
XSync(drw->dpy, False);
|
||||||
}
|
}
|
||||||
@ -380,8 +372,6 @@ drw_font_getexts(Fnt *font, const char *text, unsigned int len, Extnts *tex)
|
|||||||
{
|
{
|
||||||
XGlyphInfo ext;
|
XGlyphInfo ext;
|
||||||
|
|
||||||
if (!font || !text)
|
|
||||||
return;
|
|
||||||
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||||
tex->h = font->h;
|
tex->h = font->h;
|
||||||
tex->w = ext.xOff;
|
tex->w = ext.xOff;
|
||||||
@ -392,9 +382,8 @@ drw_font_getexts_width(Fnt *font, const char *text, unsigned int len)
|
|||||||
{
|
{
|
||||||
Extnts tex;
|
Extnts tex;
|
||||||
|
|
||||||
if (!font)
|
|
||||||
return -1;
|
|
||||||
drw_font_getexts(font, text, len, &tex);
|
drw_font_getexts(font, text, len, &tex);
|
||||||
|
|
||||||
return tex.w;
|
return tex.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,8 +392,6 @@ drw_cur_create(Drw *drw, int shape)
|
|||||||
{
|
{
|
||||||
Cur *cur;
|
Cur *cur;
|
||||||
|
|
||||||
if (!drw)
|
|
||||||
return NULL;
|
|
||||||
cur = ecalloc(1, sizeof(Cur));
|
cur = ecalloc(1, sizeof(Cur));
|
||||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||||
|
|
||||||
@ -414,7 +401,7 @@ drw_cur_create(Drw *drw, int shape)
|
|||||||
void
|
void
|
||||||
drw_cur_free(Drw *drw, Cur *cursor)
|
drw_cur_free(Drw *drw, Cur *cursor)
|
||||||
{
|
{
|
||||||
if (!drw || !cursor)
|
if (!cursor)
|
||||||
return;
|
return;
|
||||||
XFreeCursor(drw->dpy, cursor->cursor);
|
XFreeCursor(drw->dpy, cursor->cursor);
|
||||||
free(cursor);
|
free(cursor);
|
||||||
|
Loading…
Reference in New Issue
Block a user