diff --git a/awesome.c b/awesome.c index 24c6426a..d26b02c6 100644 --- a/awesome.c +++ b/awesome.c @@ -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 diff --git a/config.c b/config.c index a85f86f8..d795c5a8 100644 --- a/config.c +++ b/config.c @@ -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"); diff --git a/statusbar.c b/statusbar.c index c6f53c26..a5c8349a 100644 --- a/statusbar.c +++ b/statusbar.c @@ -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 diff --git a/statusbar.h b/statusbar.h index 69b35186..c2935bd9 100644 --- a/statusbar.h +++ b/statusbar.h @@ -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);