diff --git a/config.c b/config.c index 8fa2bf80e..67acfe22b 100644 --- a/config.c +++ b/config.c @@ -66,25 +66,6 @@ extern const name_func_link_t UicbList[]; extern const name_func_link_t WidgetList[]; extern const name_func_link_t LayoutList[]; -static unsigned int -get_numlockmask(Display *disp) -{ - XModifierKeymap *modmap; - unsigned int mask = 0; - int i, j; - - modmap = XGetModifierMapping(disp); - for(i = 0; i < 8; i++) - for(j = 0; j < modmap->max_keypermod; j++) - if(modmap->modifiermap[i * modmap->max_keypermod + j] - == XKeysymToKeycode(disp, XK_Num_Lock)) - mask = (1 << i); - - XFreeModifiermap(modmap); - - return mask; -} - /** Lookup for a key mask from its name * \param keyname Key name * \return Key mask or 0 if not found @@ -331,21 +312,21 @@ config_parse_screen(cfg_t *cfg, int screen) eprint("awesome: cannot init font\n"); /* Colors */ - virtscreen->colors_normal[ColBorder] = initxcolor(phys_screen, + virtscreen->colors_normal[ColBorder] = initxcolor(globalconf.display, phys_screen, cfg_getstr(cfg_colors, "normal_border")); - virtscreen->colors_normal[ColBG] = initxcolor(phys_screen, + virtscreen->colors_normal[ColBG] = initxcolor(globalconf.display, phys_screen, cfg_getstr(cfg_colors, "normal_bg")); - virtscreen->colors_normal[ColFG] = initxcolor(phys_screen, + virtscreen->colors_normal[ColFG] = initxcolor(globalconf.display, phys_screen, cfg_getstr(cfg_colors, "normal_fg")); - virtscreen->colors_selected[ColBorder] = initxcolor(phys_screen, + virtscreen->colors_selected[ColBorder] = initxcolor(globalconf.display, phys_screen, cfg_getstr(cfg_colors, "focus_border")); - virtscreen->colors_selected[ColBG] = initxcolor(phys_screen, + virtscreen->colors_selected[ColBG] = initxcolor(globalconf.display, phys_screen, cfg_getstr(cfg_colors, "focus_bg")); - virtscreen->colors_selected[ColFG] = initxcolor(phys_screen, + virtscreen->colors_selected[ColFG] = initxcolor(globalconf.display, phys_screen, cfg_getstr(cfg_colors, "focus_fg")); - virtscreen->colors_urgent[ColBG] = initxcolor(phys_screen, + virtscreen->colors_urgent[ColBG] = initxcolor(globalconf.display, phys_screen, cfg_getstr(cfg_colors, "urgent_bg")); - virtscreen->colors_urgent[ColFG] = initxcolor(phys_screen, + virtscreen->colors_urgent[ColFG] = initxcolor(globalconf.display, phys_screen, cfg_getstr(cfg_colors, "urgent_fg")); /* Statusbar */ diff --git a/widgets/focustitle.c b/widgets/focustitle.c index 73e4b50b3..a3af44c6a 100644 --- a/widgets/focustitle.c +++ b/widgets/focustitle.c @@ -88,12 +88,12 @@ focustitle_new(Statusbar *statusbar, cfg_t *config) w->data = d = p_new(Data, 1); if((buf = cfg_getstr(config, "fg"))) - d->fg = initxcolor(phys_screen, buf); + d->fg = initxcolor(globalconf.display, phys_screen, buf); else d->fg = globalconf.screens[statusbar->screen].colors_selected[ColFG]; if((buf = cfg_getstr(config, "bg"))) - d->bg = initxcolor(phys_screen, buf); + d->bg = initxcolor(globalconf.display, phys_screen, buf); else d->bg = globalconf.screens[statusbar->screen].colors_selected[ColBG]; diff --git a/widgets/graph.c b/widgets/graph.c index 66a69fbe4..0f42f91d2 100644 --- a/widgets/graph.c +++ b/widgets/graph.c @@ -181,17 +181,17 @@ graph_new(Statusbar *statusbar, cfg_t *config) /* prevent: division by zero; with a MIN option one day, check for div/0's */ d->current_max = d->max = MAX(cfg_getfloat(config, "max"), 0.0001); if((color = cfg_getstr(config, "fg"))) - d->fg = initxcolor(phys_screen, color); + d->fg = initxcolor(globalconf.display, phys_screen, color); else d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG]; if((color = cfg_getstr(config, "bg"))) - d->bg = initxcolor(phys_screen, color); + d->bg = initxcolor(globalconf.display, phys_screen, color); else d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; if((color = cfg_getstr(config, "bordercolor"))) - d->bordercolor = initxcolor(phys_screen, color); + d->bordercolor = initxcolor(globalconf.display, phys_screen, color); else d->bordercolor = d->fg; diff --git a/widgets/progressbar.c b/widgets/progressbar.c index c5dbe0a23..b6c60a974 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -164,17 +164,17 @@ progressbar_new(Statusbar *statusbar, cfg_t *config) cfg = cfg_getnsec(config, "bar", i); if((color = cfg_getstr(cfg, "fg"))) - d->fg[i] = initxcolor(phys_screen, color); + d->fg[i] = initxcolor(globalconf.display, phys_screen, color); else d->fg[i] = globalconf.screens[statusbar->screen].colors_normal[ColFG]; if((color = cfg_getstr(cfg, "bg"))) - d->bg[i] = initxcolor(phys_screen, color); + d->bg[i] = initxcolor(globalconf.display, phys_screen, color); else d->bg[i] = globalconf.screens[statusbar->screen].colors_normal[ColBG]; if((color = cfg_getstr(cfg, "bordercolor"))) - d->bordercolor[i] = initxcolor(phys_screen, color); + d->bordercolor[i] = initxcolor(globalconf.display, phys_screen, color); else d->bordercolor[i] = d->fg[i]; diff --git a/widgets/tasklist.c b/widgets/tasklist.c index 8cb87b268..41d61c56b 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -222,22 +222,22 @@ tasklist_new(Statusbar *statusbar, cfg_t *config) w->data = d = p_new(Data, 1); if((buf = cfg_getstr(config, "fg"))) - d->fg = initxcolor(phys_screen, buf); + d->fg = initxcolor(globalconf.display, phys_screen, buf); else d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG]; if((buf = cfg_getstr(config, "bg"))) - d->bg = initxcolor(phys_screen, buf); + d->bg = initxcolor(globalconf.display, phys_screen, buf); else d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; if((buf = cfg_getstr(config, "focus_bg"))) - d->bg_sel = initxcolor(phys_screen, buf); + d->bg_sel = initxcolor(globalconf.display, phys_screen, buf); else d->bg_sel = globalconf.screens[statusbar->screen].colors_selected[ColBG]; if((buf = cfg_getstr(config, "focus_fg"))) - d->fg_sel = initxcolor(phys_screen, buf); + d->fg_sel = initxcolor(globalconf.display, phys_screen, buf); else d->fg_sel = globalconf.screens[statusbar->screen].colors_selected[ColFG]; diff --git a/widgets/textbox.c b/widgets/textbox.c index 16204f0d4..9a1fd195c 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -81,9 +81,9 @@ textbox_tell(Widget *widget, char *command) if (ntok) *ntok = 0; if (!i) - d->fg = initxcolor(phys_screen, tok); + d->fg = initxcolor(globalconf.display, phys_screen, tok); else - d->bg = initxcolor(phys_screen, tok); + d->bg = initxcolor(globalconf.display, phys_screen, tok); if (ntok) *ntok = ' '; tok = ntok + (ntok != NULL); @@ -109,12 +109,12 @@ textbox_new(Statusbar *statusbar, cfg_t *config) w->data = d = p_new(Data, 1); if((buf = cfg_getstr(config, "fg"))) - d->fg = initxcolor(statusbar->screen, buf); + d->fg = initxcolor(globalconf.display, statusbar->screen, buf); else d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG]; if((buf = cfg_getstr(config, "bg"))) - d->bg = initxcolor(get_phys_screen(statusbar->screen), buf); + d->bg = initxcolor(globalconf.display, get_phys_screen(statusbar->screen), buf); else d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; diff --git a/xutil.c b/xutil.c index 7a91f119a..fcf35d084 100644 --- a/xutil.c +++ b/xutil.c @@ -128,12 +128,12 @@ xgettextprop(Window w, Atom atom, char *text, ssize_t textlen) * \param colstr Color specification */ XColor -initxcolor(int phys_screen, const char *colstr) +initxcolor(Display *disp, int phys_screen, const char *colstr) { XColor screenColor, exactColor; - if(!XAllocNamedColor(globalconf.display, - DefaultColormap(globalconf.display, phys_screen), + if(!XAllocNamedColor(disp, + DefaultColormap(disp, phys_screen), colstr, &screenColor, &exactColor)) @@ -142,4 +142,23 @@ initxcolor(int phys_screen, const char *colstr) return screenColor; } +unsigned int +get_numlockmask(Display *disp) +{ + XModifierKeymap *modmap; + unsigned int mask = 0; + int i, j; + + modmap = XGetModifierMapping(disp); + for(i = 0; i < 8; i++) + for(j = 0; j < modmap->max_keypermod; j++) + if(modmap->modifiermap[i * modmap->max_keypermod + j] + == XKeysymToKeycode(disp, XK_Num_Lock)) + mask = (1 << i); + + XFreeModifiermap(modmap); + + return mask; +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/xutil.h b/xutil.h index 3eb606357..dfc87e548 100644 --- a/xutil.h +++ b/xutil.h @@ -26,7 +26,8 @@ #include "uicb.h" Bool xgettextprop(Window, Atom, char *, ssize_t); -XColor initxcolor(int, const char *); +XColor initxcolor(Display *, int, const char *); +unsigned int get_numlockmask(Display *); Uicb uicb_spawn; Uicb uicb_exec;