move txtlenwidth initlization in initstatusbar()

This commit is contained in:
Julien Danjou 2007-10-15 12:06:43 +02:00
parent d75a512f5d
commit 77609263dc
4 changed files with 14 additions and 16 deletions

View File

@ -200,7 +200,7 @@ setup(awesome_config *awesomeconf)
compileregs(awesomeconf->rules, awesomeconf->nrules);
/* bar */
initstatusbar(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar, awesomeconf->cursor[CurNormal], awesomeconf->font);
initstatusbar(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar, awesomeconf->cursor[CurNormal], awesomeconf->font, awesomeconf->layouts, awesomeconf->nlayouts);
}
/** Startup Error handler to check if another window manager

View File

@ -19,7 +19,6 @@
*
*/
/**
* \defgroup ui_callback
*/
@ -237,7 +236,7 @@ parse_config(Display * disp, int scr,const char *confpatharg, awesome_config *aw
const char *tmp, *homedir;
char *confpath;
KeySym tmp_key;
ssize_t confpath_len, txtlen;
ssize_t confpath_len;
if(confpatharg)
confpath = a_strdup(confpatharg);
@ -320,9 +319,6 @@ parse_config(Display * disp, int scr,const char *confpatharg, awesome_config *aw
continue;
}
awesomeconf->layouts[i].symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol"));
txtlen = awesomeconf->font->height + textwidth(disp, awesomeconf->font, awesomeconf->layouts[i].symbol, a_strlen(awesomeconf->layouts[i].symbol));
if(txtlen > awesomeconf->statusbar.txtlayoutwidth)
awesomeconf->statusbar.txtlayoutwidth = txtlen;
}
awesomeconf->mwfact = cfg_getfloat(cfg_layouts, "mwfact");

View File

@ -177,21 +177,18 @@ drawstatusbar(Display *disp, awesome_config * awesomeconf)
}
void
initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, XftFont *font)
initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, XftFont *font, Layout *layouts, int nlayouts)
{
XSetWindowAttributes wa;
int phys_screen;
ScreenInfo *si;
int i, phys_screen = get_phys_screen(disp, screen);
ScreenInfo *si = get_screen_info(disp, screen, NULL);
phys_screen = get_phys_screen(disp, screen);
statusbar->screen = screen;
si = get_screen_info(disp, screen, NULL);
statusbar->width = si[screen].width;
statusbar->height = font->height + 2;
p_delete(&si);
statusbar->screen = screen;
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
wa.cursor = cursor;
@ -202,7 +199,8 @@ initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, Xf
statusbar->width,
statusbar->height,
0, DefaultDepth(disp, phys_screen), CopyFromParent,
DefaultVisual(disp, phys_screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
DefaultVisual(disp, phys_screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(disp, statusbar->window, cursor);
updatebarpos(disp, *statusbar);
XMapRaised(disp, statusbar->window);
@ -211,6 +209,10 @@ initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, Xf
statusbar->width,
statusbar->height,
DefaultDepth(disp, phys_screen));
for(i = 0; i < nlayouts; i++)
statusbar->txtlayoutwidth = MAX(statusbar->txtlayoutwidth,
(font->height + textwidth(disp, font, layouts[i].symbol, a_strlen(layouts[i].symbol))));
}
void

View File

@ -24,7 +24,7 @@
#include "common.h"
void initstatusbar(Display *, int, Statusbar *, Cursor, XftFont *);
void initstatusbar(Display *, int, Statusbar *, Cursor, XftFont *, Layout *, int);
void drawstatusbar(Display *, awesome_config *);
void updatebarpos(Display *, Statusbar);