From 9f285828208b46da9951da3f7413c47c3222ead7 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 16 Jan 2008 15:22:40 +0100 Subject: [PATCH] add Display as arg --- config.c | 35 ++++++++--------------------------- widgets/focustitle.c | 4 ++-- widgets/graph.c | 6 +++--- widgets/progressbar.c | 6 +++--- widgets/tasklist.c | 8 ++++---- widgets/textbox.c | 8 ++++---- xutil.c | 25 ++++++++++++++++++++++--- xutil.h | 3 ++- 8 files changed, 48 insertions(+), 47 deletions(-) diff --git a/config.c b/config.c index 8fa2bf80..67acfe22 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 73e4b50b..a3af44c6 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 66a69fbe..0f42f91d 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 c5dbe0a2..b6c60a97 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 8cb87b26..41d61c56 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 16204f0d..9a1fd195 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 7a91f119..fcf35d08 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 3eb60635..dfc87e54 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;