move drawable to statusbar struct

This commit is contained in:
Julien Danjou 2007-09-15 14:58:41 +02:00
parent b490276b66
commit 6a11f10764
4 changed files with 26 additions and 25 deletions

View File

@ -62,7 +62,7 @@ cleanup(Display *disp, DC *drawcontext, awesome_config *awesomeconf)
else else
XFreeFont(disp, drawcontext->font.xfont); XFreeFont(disp, drawcontext->font.xfont);
XUngrabKey(disp, AnyKey, AnyModifier, DefaultRootWindow(disp)); XUngrabKey(disp, AnyKey, AnyModifier, DefaultRootWindow(disp));
XFreePixmap(disp, drawcontext->drawable); XFreePixmap(disp, awesomeconf->statusbar.drawable);
XFreeGC(disp, drawcontext->gc); XFreeGC(disp, drawcontext->gc);
XDestroyWindow(disp, awesomeconf->statusbar.window); XDestroyWindow(disp, awesomeconf->statusbar.window);
XFreeCursor(disp, drawcontext->cursor[CurNormal]); XFreeCursor(disp, drawcontext->cursor[CurNormal]);
@ -164,7 +164,7 @@ setup(Display *disp, DC *drawcontext, awesome_config *awesomeconf)
updatebarpos(disp, awesomeconf->statusbar); updatebarpos(disp, awesomeconf->statusbar);
XMapRaised(disp, awesomeconf->statusbar.window); XMapRaised(disp, awesomeconf->statusbar.window);
/* pixmap for everything */ /* pixmap for everything */
drawcontext->drawable = XCreatePixmap(disp, DefaultRootWindow(disp), DisplayWidth(disp, DefaultScreen(disp)), awesomeconf->statusbar.height, DefaultDepth(disp, DefaultScreen(disp))); awesomeconf->statusbar.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), DisplayWidth(disp, DefaultScreen(disp)), awesomeconf->statusbar.height, DefaultDepth(disp, DefaultScreen(disp)));
drawcontext->gc = XCreateGC(disp, DefaultRootWindow(disp), 0, 0); drawcontext->gc = XCreateGC(disp, DefaultRootWindow(disp), 0, 0);
XSetLineAttributes(disp, drawcontext->gc, 1, LineSolid, CapButt, JoinMiter); XSetLineAttributes(disp, drawcontext->gc, 1, LineSolid, CapButt, JoinMiter);
if(!drawcontext->font.set) if(!drawcontext->font.set)

View File

@ -41,7 +41,6 @@ typedef struct
int x, y, w, h; int x, y, w, h;
unsigned long norm[ColLast]; unsigned long norm[ColLast];
unsigned long sel[ColLast]; unsigned long sel[ColLast];
Drawable drawable;
GC gc; GC gc;
Cursor cursor[CurLast]; Cursor cursor[CurLast];
struct struct
@ -88,6 +87,8 @@ typedef struct
int position; int position;
/** Window */ /** Window */
Window window; Window window;
/** Drawable object */
Drawable drawable;
} Statusbar; } Statusbar;
/** Main configuration structure */ /** Main configuration structure */

35
draw.c
View File

@ -26,7 +26,7 @@ extern Client *clients, *sel, *stack; /* global client list and stack */
/* static */ /* static */
static void static void
drawtext(Display *disp, DC drawcontext, const char *text, unsigned long col[ColLast]) drawtext(Display *disp, DC drawcontext, Statusbar * statusbar, const char *text, unsigned long col[ColLast])
{ {
int x, y, w, h; int x, y, w, h;
static char buf[256]; static char buf[256];
@ -34,7 +34,7 @@ drawtext(Display *disp, DC drawcontext, const char *text, unsigned long col[ColL
XRectangle r = { drawcontext.x, drawcontext.y, drawcontext.w, drawcontext.h }; XRectangle r = { drawcontext.x, drawcontext.y, drawcontext.w, drawcontext.h };
XSetForeground(disp, drawcontext.gc, col[ColBG]); XSetForeground(disp, drawcontext.gc, col[ColBG]);
XFillRectangles(disp, drawcontext.drawable, drawcontext.gc, &r, 1); XFillRectangles(disp, statusbar->drawable, drawcontext.gc, &r, 1);
if(!text) if(!text)
return; return;
w = 0; w = 0;
@ -62,13 +62,13 @@ drawtext(Display *disp, DC drawcontext, const char *text, unsigned long col[ColL
} }
XSetForeground(disp, drawcontext.gc, col[ColFG]); XSetForeground(disp, drawcontext.gc, col[ColFG]);
if(drawcontext.font.set) if(drawcontext.font.set)
XmbDrawString(disp, drawcontext.drawable, drawcontext.font.set, drawcontext.gc, x, y, buf, len); XmbDrawString(disp, statusbar->drawable, drawcontext.font.set, drawcontext.gc, x, y, buf, len);
else else
XDrawString(disp, drawcontext.drawable, drawcontext.gc, x, y, buf, len); XDrawString(disp, statusbar->drawable, drawcontext.gc, x, y, buf, len);
} }
static void static void
drawsquare(Bool filled, Bool empty, unsigned long col[ColLast], Display *disp, DC drawcontext) drawsquare(Bool filled, Bool empty, unsigned long col[ColLast], Display *disp, DC drawcontext, Statusbar *statusbar)
{ {
int x; int x;
XGCValues gcv; XGCValues gcv;
@ -82,12 +82,12 @@ drawsquare(Bool filled, Bool empty, unsigned long col[ColLast], Display *disp, D
if(filled) if(filled)
{ {
r.width = r.height = x + 1; r.width = r.height = x + 1;
XFillRectangles(disp, drawcontext.drawable, drawcontext.gc, &r, 1); XFillRectangles(disp, statusbar->drawable, drawcontext.gc, &r, 1);
} }
else if(empty) else if(empty)
{ {
r.width = r.height = x; r.width = r.height = x;
XDrawRectangles(disp, drawcontext.drawable, drawcontext.gc, &r, 1); XDrawRectangles(disp, statusbar->drawable, drawcontext.gc, &r, 1);
} }
} }
@ -106,7 +106,6 @@ isoccupied(unsigned int t)
return False; return False;
} }
/* extern */ /* extern */
unsigned int unsigned int
@ -132,18 +131,18 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
drawcontext->w = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->tags[i], drawcontext->font.height); drawcontext->w = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->tags[i], drawcontext->font.height);
if(awesomeconf->selected_tags[i]) if(awesomeconf->selected_tags[i])
{ {
drawtext(disp, *drawcontext, awesomeconf->tags[i], drawcontext->sel); drawtext(disp, *drawcontext, &awesomeconf->statusbar, awesomeconf->tags[i], drawcontext->sel);
drawsquare(sel && sel->tags[i], isoccupied(i), drawcontext->sel, disp, *drawcontext); drawsquare(sel && sel->tags[i], isoccupied(i), drawcontext->sel, disp, *drawcontext, &awesomeconf->statusbar);
} }
else else
{ {
drawtext(disp, *drawcontext, awesomeconf->tags[i], drawcontext->norm); drawtext(disp, *drawcontext, &awesomeconf->statusbar, awesomeconf->tags[i], drawcontext->norm);
drawsquare(sel && sel->tags[i], isoccupied(i), drawcontext->norm, disp, *drawcontext); drawsquare(sel && sel->tags[i], isoccupied(i), drawcontext->norm, disp, *drawcontext, &awesomeconf->statusbar);
} }
drawcontext->x += drawcontext->w; drawcontext->x += drawcontext->w;
} }
drawcontext->w = awesomeconf->statusbar.width; drawcontext->w = awesomeconf->statusbar.width;
drawtext(disp, *drawcontext, awesomeconf->current_layout->symbol, drawcontext->norm); drawtext(disp, *drawcontext, &awesomeconf->statusbar, awesomeconf->current_layout->symbol, drawcontext->norm);
x = drawcontext->x + drawcontext->w; x = drawcontext->x + drawcontext->w;
drawcontext->w = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->statustext, drawcontext->font.height); drawcontext->w = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->statustext, drawcontext->font.height);
drawcontext->x = DisplayWidth(disp, DefaultScreen(disp)) - drawcontext->w; drawcontext->x = DisplayWidth(disp, DefaultScreen(disp)) - drawcontext->w;
@ -152,18 +151,18 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
drawcontext->x = x; drawcontext->x = x;
drawcontext->w = DisplayWidth(disp, DefaultScreen(disp)) - x; drawcontext->w = DisplayWidth(disp, DefaultScreen(disp)) - x;
} }
drawtext(disp, *drawcontext, awesomeconf->statustext, drawcontext->norm); drawtext(disp, *drawcontext, &awesomeconf->statusbar, awesomeconf->statustext, drawcontext->norm);
if((drawcontext->w = drawcontext->x - x) > awesomeconf->statusbar.height) if((drawcontext->w = drawcontext->x - x) > awesomeconf->statusbar.height)
{ {
drawcontext->x = x; drawcontext->x = x;
if(sel) if(sel)
{ {
drawtext(disp, *drawcontext, sel->name, drawcontext->sel); drawtext(disp, *drawcontext, &awesomeconf->statusbar, sel->name, drawcontext->sel);
drawsquare(sel->ismax, sel->isfloating, drawcontext->sel, disp, *drawcontext); drawsquare(sel->ismax, sel->isfloating, drawcontext->sel, disp, *drawcontext, &awesomeconf->statusbar);
} }
else else
drawtext(disp, *drawcontext, NULL, drawcontext->norm); drawtext(disp, *drawcontext, &awesomeconf->statusbar, NULL, drawcontext->norm);
} }
XCopyArea(disp, drawcontext->drawable, awesomeconf->statusbar.window, drawcontext->gc, 0, 0, DisplayWidth(disp, DefaultScreen(disp)), awesomeconf->statusbar.height, 0, 0); XCopyArea(disp, awesomeconf->statusbar.drawable, awesomeconf->statusbar.window, drawcontext->gc, 0, 0, DisplayWidth(disp, DefaultScreen(disp)), awesomeconf->statusbar.height, 0, 0);
XSync(disp, False); XSync(disp, False);
} }

View File

@ -260,10 +260,11 @@ handle_event_configurenotify(XEvent * e, awesome_config *awesomeconf)
{ {
DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)) = ev->width; DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)) = ev->width;
DisplayHeight(e->xany.display, DefaultScreen(e->xany.display)) = ev->height; DisplayHeight(e->xany.display, DefaultScreen(e->xany.display)) = ev->height;
XFreePixmap(e->xany.display, dc.drawable); XFreePixmap(e->xany.display, awesomeconf->statusbar.drawable);
dc.drawable = XCreatePixmap(e->xany.display, DefaultRootWindow(e->xany.display), awesomeconf->statusbar.drawable = XCreatePixmap(e->xany.display, DefaultRootWindow(e->xany.display),
DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)), DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)),
awesomeconf->statusbar.height, DefaultDepth(e->xany.display, DefaultScreen(e->xany.display))); awesomeconf->statusbar.height,
DefaultDepth(e->xany.display, DefaultScreen(e->xany.display)));
XResizeWindow(e->xany.display, awesomeconf->statusbar.window, XResizeWindow(e->xany.display, awesomeconf->statusbar.window,
DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)), awesomeconf->statusbar.height); DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)), awesomeconf->statusbar.height);
updatebarpos(e->xany.display, awesomeconf->statusbar); updatebarpos(e->xany.display, awesomeconf->statusbar);