move font to awesomeconf

This commit is contained in:
Julien Danjou 2007-10-10 13:34:25 +02:00
parent 2d0526696c
commit f57d275df1
5 changed files with 23 additions and 22 deletions

View file

@ -67,7 +67,7 @@ cleanup(DC *drawcontext, awesome_config *awesomeconf)
for(screen = 0; screen < get_screen_count(awesomeconf->display); screen++)
{
XftFontClose(awesomeconf->display, drawcontext->font);
XftFontClose(awesomeconf->display, awesomeconf->font);
XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, awesomeconf[screen].phys_screen));
@ -203,7 +203,7 @@ setup(DC *drawcontext, awesome_config *awesomeconf)
compileregs(awesomeconf->rules, awesomeconf->nrules);
/* bar */
awesomeconf->statusbar.height = drawcontext->font->height + 2;
awesomeconf->statusbar.height = awesomeconf->font->height + 2;
initstatusbar(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar, awesomeconf->cursor[CurNormal]);
drawcontext->gc = XCreateGC(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), 0, 0);
XSetLineAttributes(awesomeconf->display, drawcontext->gc, 1, LineSolid, CapButt, JoinMiter);
@ -325,7 +325,7 @@ main(int argc, char *argv[])
for(screen = 0; screen < get_screen_count(dpy); screen++)
{
parse_config(dpy, screen, &dc[screen], confpath, &awesomeconf[screen]);
parse_config(dpy, screen, confpath, &awesomeconf[screen]);
setup(&dc[screen], &awesomeconf[screen]);
drawstatusbar(dpy, &dc[screen], &awesomeconf[screen]);
}

View file

@ -165,7 +165,7 @@ name_func_lookup(const char *funcname, const NameFuncLink * list)
* \param drawcontext Draw context
*/
void
parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg, awesome_config *awesomeconf)
parse_config(Display * disp, int scr,const char *confpatharg, awesome_config *awesomeconf)
{
static cfg_opt_t general_opts[] =
{
@ -302,8 +302,8 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
awesomeconf->resize_hints = cfg_getbool(cfg_general, "resize_hints");
awesomeconf->opacity_unfocused = cfg_getint(cfg_general, "opacity_unfocused");
awesomeconf->focus_move_pointer = cfg_getbool(cfg_general, "focus_move_pointer");
drawcontext->font = XftFontOpenName(disp, awesomeconf->phys_screen, cfg_getstr(cfg_general, "font"));
if(!drawcontext->font)
awesomeconf->font = XftFontOpenName(disp, awesomeconf->phys_screen, cfg_getstr(cfg_general, "font"));
if(!awesomeconf->font)
eprint("awesome: cannot init font\n");
/* Colors */
@ -341,7 +341,7 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
continue;
}
awesomeconf->layouts[i].symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol"));
txtlen = drawcontext->font->height + textwidth(disp, drawcontext->font, awesomeconf->layouts[i].symbol, a_strlen(awesomeconf->layouts[i].symbol));
txtlen = awesomeconf->font->height + textwidth(disp, awesomeconf->font, awesomeconf->layouts[i].symbol, a_strlen(awesomeconf->layouts[i].symbol));
if(txtlen > awesomeconf->statusbar.width)
awesomeconf->statusbar.width = txtlen;
}

View file

@ -40,7 +40,6 @@ enum
typedef struct
{
GC gc;
XftFont *font;
} DC;
typedef struct
@ -159,8 +158,10 @@ struct awesome_config
XColor colors_selected[ColLast];
/** Cursors */
Cursor cursor[CurLast];
/** Font */
XftFont *font;
};
void parse_config(Display *, int, DC *, const char *, awesome_config *); /* parse configuration file */
void parse_config(Display *, int, const char *, awesome_config *); /* parse configuration file */
#endif

View file

@ -155,7 +155,7 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
{
for(i = 0; i < awesomeconf[screen].ntags; i++)
{
x += textwidth(e->xany.display, dc[screen].font, awesomeconf[screen].tags[i].name, a_strlen(awesomeconf[screen].tags[i].name)) + dc[screen].font->height;
x += textwidth(e->xany.display, awesomeconf[screen].font, awesomeconf[screen].tags[i].name, a_strlen(awesomeconf[screen].tags[i].name)) + awesomeconf[screen].font->height;
if(ev->x < x)
{
if(ev->button == Button1)

View file

@ -55,49 +55,49 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
for(i = 0; i < awesomeconf->ntags; i++)
{
w = textwidth(disp, drawcontext->font, awesomeconf->tags[i].name, a_strlen(awesomeconf->tags[i].name)) + drawcontext->font->height;
w = textwidth(disp, awesomeconf->font, awesomeconf->tags[i].name, a_strlen(awesomeconf->tags[i].name)) + awesomeconf->font->height;
if(awesomeconf->tags[i].selected)
{
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, awesomeconf->tags[i].name, awesomeconf->colors_selected);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->tags[i].name, awesomeconf->colors_selected);
if(isoccupied(i, awesomeconf->screen))
drawsquare(disp, x, y, (drawcontext->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], awesomeconf->colors_selected[ColFG]);
drawsquare(disp, x, y, (awesomeconf->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], awesomeconf->colors_selected[ColFG]);
}
else
{
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, awesomeconf->tags[i].name, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->tags[i].name, awesomeconf->colors_normal);
if(isoccupied(i, awesomeconf->screen))
drawsquare(disp, x, y, (drawcontext->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], awesomeconf->colors_normal[ColFG]);
drawsquare(disp, x, y, (awesomeconf->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], awesomeconf->colors_normal[ColFG]);
}
x += w;
}
w = awesomeconf->statusbar.width;
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, awesomeconf->current_layout->symbol, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->current_layout->symbol, awesomeconf->colors_normal);
z = x + w;
w = textwidth(disp, drawcontext->font, awesomeconf->statustext, a_strlen(awesomeconf->statustext)) + drawcontext->font->height;
w = textwidth(disp, awesomeconf->font, awesomeconf->statustext, a_strlen(awesomeconf->statustext)) + awesomeconf->font->height;
x = si[awesomeconf->screen].width - w;
if(x < z)
{
x = z;
w = si[awesomeconf->screen].width - z;
}
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, awesomeconf->statustext, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->statustext, awesomeconf->colors_normal);
if((w = x - z) > awesomeconf->statusbar.height)
{
x = z;
if(sel)
{
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, sel->name, awesomeconf->colors_selected);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, sel->name, awesomeconf->colors_selected);
if(sel->isfloating)
drawsquare(disp, x, y, (drawcontext->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel->ismax, awesomeconf->colors_selected[ColFG]);
drawsquare(disp, x, y, (awesomeconf->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel->ismax, awesomeconf->colors_selected[ColFG]);
}
else if(IS_ARRANGE(layout_tile) || IS_ARRANGE(layout_tileleft))
{
char buf[256];
snprintf(buf, sizeof(buf), "nmaster: %d ncol: %d mwfact: %.2lf", awesomeconf->nmaster, awesomeconf->ncol, awesomeconf->mwfact);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, buf, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, buf, awesomeconf->colors_normal);
}
else
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, drawcontext->font, NULL, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, NULL, awesomeconf->colors_normal);
}
XCopyArea(disp, awesomeconf->statusbar.drawable, awesomeconf->statusbar.window, drawcontext->gc, 0, 0, si[awesomeconf->screen].width, awesomeconf->statusbar.height, 0, 0);
XSync(disp, False);