avoid DC in drawsquare()

This commit is contained in:
Julien Danjou 2007-10-09 21:43:26 +02:00
parent aa645b15ab
commit 2887bb8b86
3 changed files with 9 additions and 14 deletions

15
draw.c
View File

@ -69,25 +69,20 @@ drawtext(Display *disp, int screen, int x, int y, int w, int h, GC gc, Drawable
} }
void void
drawsquare(Display *disp, DC drawcontext, Drawable drawable, Bool filled, unsigned long col) drawsquare(Display *disp, int x, int y, int h, GC gc, Drawable drawable, Bool filled, unsigned long col)
{ {
int x;
XGCValues gcv; XGCValues gcv;
XRectangle r = { drawcontext.x, drawcontext.y, drawcontext.w, drawcontext.h }; XRectangle r = { x, y, h, h };
x = (drawcontext.font->ascent + drawcontext.font->descent + 2) / 4;
gcv.foreground = col; gcv.foreground = col;
XChangeGC(disp, drawcontext.gc, GCForeground, &gcv); XChangeGC(disp, gc, GCForeground, &gcv);
r.x = drawcontext.x + 1;
r.y = drawcontext.y + 1;
r.width = r.height = x;
if(filled) if(filled)
{ {
r.width++; r.height++; r.width++; r.height++;
XFillRectangles(disp, drawable, drawcontext.gc, &r, 1); XFillRectangles(disp, drawable, gc, &r, 1);
} }
else else
XDrawRectangles(disp, drawable, drawcontext.gc, &r, 1); XDrawRectangles(disp, drawable, gc, &r, 1);
} }

2
draw.h
View File

@ -24,7 +24,7 @@
#include "config.h" #include "config.h"
void drawsquare(Display *, DC, Drawable, Bool, unsigned long);
void drawtext(Display *, int, int, int, int, int, GC, Drawable, XftFont *, const char *, unsigned long *, XColor); void drawtext(Display *, int, int, int, int, int, GC, Drawable, XftFont *, const char *, unsigned long *, XColor);
void drawsquare(Display *, int, int, int, GC, Drawable, Bool, unsigned long);
inline unsigned short textwidth(Display *, XftFont *, char *, ssize_t); inline unsigned short textwidth(Display *, XftFont *, char *, ssize_t);
#endif #endif

View File

@ -61,13 +61,13 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
{ {
drawtext(disp, awesomeconf->phys_screen, drawcontext->x, drawcontext->y, drawcontext->w, drawcontext->h, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, awesomeconf->tags[i].name, drawcontext->sel, drawcontext->text_selected); drawtext(disp, awesomeconf->phys_screen, drawcontext->x, drawcontext->y, drawcontext->w, drawcontext->h, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, awesomeconf->tags[i].name, drawcontext->sel, drawcontext->text_selected);
if(isoccupied(i, awesomeconf->screen)) if(isoccupied(i, awesomeconf->screen))
drawsquare(disp, *drawcontext, awesomeconf->statusbar.drawable, sel && sel->tags[i], drawcontext->sel[ColFG]); drawsquare(disp, drawcontext->x, drawcontext->y, (drawcontext->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], drawcontext->sel[ColFG]);
} }
else else
{ {
drawtext(disp, awesomeconf->phys_screen, drawcontext->x, drawcontext->y, drawcontext->w, drawcontext->h, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, awesomeconf->tags[i].name, drawcontext->norm, drawcontext->text_normal); drawtext(disp, awesomeconf->phys_screen, drawcontext->x, drawcontext->y, drawcontext->w, drawcontext->h, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, awesomeconf->tags[i].name, drawcontext->norm, drawcontext->text_normal);
if(isoccupied(i, awesomeconf->screen)) if(isoccupied(i, awesomeconf->screen))
drawsquare(disp, *drawcontext, awesomeconf->statusbar.drawable, sel && sel->tags[i], drawcontext->norm[ColFG]); drawsquare(disp, drawcontext->x, drawcontext->y, (drawcontext->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], drawcontext->norm[ColFG]);
} }
drawcontext->x += drawcontext->w; drawcontext->x += drawcontext->w;
} }
@ -89,7 +89,7 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
{ {
drawtext(disp, awesomeconf->phys_screen, drawcontext->x, drawcontext->y, drawcontext->w, drawcontext->h, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, sel->name, drawcontext->sel, drawcontext->text_selected); drawtext(disp, awesomeconf->phys_screen, drawcontext->x, drawcontext->y, drawcontext->w, drawcontext->h, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, sel->name, drawcontext->sel, drawcontext->text_selected);
if(sel->isfloating) if(sel->isfloating)
drawsquare(disp, *drawcontext, awesomeconf->statusbar.drawable, sel->ismax, drawcontext->sel[ColFG]); drawsquare(disp, drawcontext->x, drawcontext->y, (drawcontext->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel->ismax, drawcontext->sel[ColFG]);
} }
else if(IS_ARRANGE(layout_tile) || IS_ARRANGE(layout_tileleft)) else if(IS_ARRANGE(layout_tile) || IS_ARRANGE(layout_tileleft))
{ {