add Display as arg

This commit is contained in:
Julien Danjou 2008-01-16 15:22:40 +01:00
parent bbe0254393
commit 9f28582820
8 changed files with 48 additions and 47 deletions

View File

@ -66,25 +66,6 @@ extern const name_func_link_t UicbList[];
extern const name_func_link_t WidgetList[]; extern const name_func_link_t WidgetList[];
extern const name_func_link_t LayoutList[]; 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 /** Lookup for a key mask from its name
* \param keyname Key name * \param keyname Key name
* \return Key mask or 0 if not found * \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"); eprint("awesome: cannot init font\n");
/* Colors */ /* Colors */
virtscreen->colors_normal[ColBorder] = initxcolor(phys_screen, virtscreen->colors_normal[ColBorder] = initxcolor(globalconf.display, phys_screen,
cfg_getstr(cfg_colors, "normal_border")); 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")); 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")); 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")); 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")); 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")); 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")); 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")); cfg_getstr(cfg_colors, "urgent_fg"));
/* Statusbar */ /* Statusbar */

View File

@ -88,12 +88,12 @@ focustitle_new(Statusbar *statusbar, cfg_t *config)
w->data = d = p_new(Data, 1); w->data = d = p_new(Data, 1);
if((buf = cfg_getstr(config, "fg"))) if((buf = cfg_getstr(config, "fg")))
d->fg = initxcolor(phys_screen, buf); d->fg = initxcolor(globalconf.display, phys_screen, buf);
else else
d->fg = globalconf.screens[statusbar->screen].colors_selected[ColFG]; d->fg = globalconf.screens[statusbar->screen].colors_selected[ColFG];
if((buf = cfg_getstr(config, "bg"))) if((buf = cfg_getstr(config, "bg")))
d->bg = initxcolor(phys_screen, buf); d->bg = initxcolor(globalconf.display, phys_screen, buf);
else else
d->bg = globalconf.screens[statusbar->screen].colors_selected[ColBG]; d->bg = globalconf.screens[statusbar->screen].colors_selected[ColBG];

View File

@ -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 */ /* 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); d->current_max = d->max = MAX(cfg_getfloat(config, "max"), 0.0001);
if((color = cfg_getstr(config, "fg"))) if((color = cfg_getstr(config, "fg")))
d->fg = initxcolor(phys_screen, color); d->fg = initxcolor(globalconf.display, phys_screen, color);
else else
d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG]; d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG];
if((color = cfg_getstr(config, "bg"))) if((color = cfg_getstr(config, "bg")))
d->bg = initxcolor(phys_screen, color); d->bg = initxcolor(globalconf.display, phys_screen, color);
else else
d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG];
if((color = cfg_getstr(config, "bordercolor"))) if((color = cfg_getstr(config, "bordercolor")))
d->bordercolor = initxcolor(phys_screen, color); d->bordercolor = initxcolor(globalconf.display, phys_screen, color);
else else
d->bordercolor = d->fg; d->bordercolor = d->fg;

View File

@ -164,17 +164,17 @@ progressbar_new(Statusbar *statusbar, cfg_t *config)
cfg = cfg_getnsec(config, "bar", i); cfg = cfg_getnsec(config, "bar", i);
if((color = cfg_getstr(cfg, "fg"))) if((color = cfg_getstr(cfg, "fg")))
d->fg[i] = initxcolor(phys_screen, color); d->fg[i] = initxcolor(globalconf.display, phys_screen, color);
else else
d->fg[i] = globalconf.screens[statusbar->screen].colors_normal[ColFG]; d->fg[i] = globalconf.screens[statusbar->screen].colors_normal[ColFG];
if((color = cfg_getstr(cfg, "bg"))) if((color = cfg_getstr(cfg, "bg")))
d->bg[i] = initxcolor(phys_screen, color); d->bg[i] = initxcolor(globalconf.display, phys_screen, color);
else else
d->bg[i] = globalconf.screens[statusbar->screen].colors_normal[ColBG]; d->bg[i] = globalconf.screens[statusbar->screen].colors_normal[ColBG];
if((color = cfg_getstr(cfg, "bordercolor"))) if((color = cfg_getstr(cfg, "bordercolor")))
d->bordercolor[i] = initxcolor(phys_screen, color); d->bordercolor[i] = initxcolor(globalconf.display, phys_screen, color);
else else
d->bordercolor[i] = d->fg[i]; d->bordercolor[i] = d->fg[i];

View File

@ -222,22 +222,22 @@ tasklist_new(Statusbar *statusbar, cfg_t *config)
w->data = d = p_new(Data, 1); w->data = d = p_new(Data, 1);
if((buf = cfg_getstr(config, "fg"))) if((buf = cfg_getstr(config, "fg")))
d->fg = initxcolor(phys_screen, buf); d->fg = initxcolor(globalconf.display, phys_screen, buf);
else else
d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG]; d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG];
if((buf = cfg_getstr(config, "bg"))) if((buf = cfg_getstr(config, "bg")))
d->bg = initxcolor(phys_screen, buf); d->bg = initxcolor(globalconf.display, phys_screen, buf);
else else
d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG];
if((buf = cfg_getstr(config, "focus_bg"))) if((buf = cfg_getstr(config, "focus_bg")))
d->bg_sel = initxcolor(phys_screen, buf); d->bg_sel = initxcolor(globalconf.display, phys_screen, buf);
else else
d->bg_sel = globalconf.screens[statusbar->screen].colors_selected[ColBG]; d->bg_sel = globalconf.screens[statusbar->screen].colors_selected[ColBG];
if((buf = cfg_getstr(config, "focus_fg"))) if((buf = cfg_getstr(config, "focus_fg")))
d->fg_sel = initxcolor(phys_screen, buf); d->fg_sel = initxcolor(globalconf.display, phys_screen, buf);
else else
d->fg_sel = globalconf.screens[statusbar->screen].colors_selected[ColFG]; d->fg_sel = globalconf.screens[statusbar->screen].colors_selected[ColFG];

View File

@ -81,9 +81,9 @@ textbox_tell(Widget *widget, char *command)
if (ntok) if (ntok)
*ntok = 0; *ntok = 0;
if (!i) if (!i)
d->fg = initxcolor(phys_screen, tok); d->fg = initxcolor(globalconf.display, phys_screen, tok);
else else
d->bg = initxcolor(phys_screen, tok); d->bg = initxcolor(globalconf.display, phys_screen, tok);
if (ntok) if (ntok)
*ntok = ' '; *ntok = ' ';
tok = ntok + (ntok != NULL); tok = ntok + (ntok != NULL);
@ -109,12 +109,12 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
w->data = d = p_new(Data, 1); w->data = d = p_new(Data, 1);
if((buf = cfg_getstr(config, "fg"))) if((buf = cfg_getstr(config, "fg")))
d->fg = initxcolor(statusbar->screen, buf); d->fg = initxcolor(globalconf.display, statusbar->screen, buf);
else else
d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG]; d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG];
if((buf = cfg_getstr(config, "bg"))) 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 else
d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG];

25
xutil.c
View File

@ -128,12 +128,12 @@ xgettextprop(Window w, Atom atom, char *text, ssize_t textlen)
* \param colstr Color specification * \param colstr Color specification
*/ */
XColor XColor
initxcolor(int phys_screen, const char *colstr) initxcolor(Display *disp, int phys_screen, const char *colstr)
{ {
XColor screenColor, exactColor; XColor screenColor, exactColor;
if(!XAllocNamedColor(globalconf.display, if(!XAllocNamedColor(disp,
DefaultColormap(globalconf.display, phys_screen), DefaultColormap(disp, phys_screen),
colstr, colstr,
&screenColor, &screenColor,
&exactColor)) &exactColor))
@ -142,4 +142,23 @@ initxcolor(int phys_screen, const char *colstr)
return screenColor; 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 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -26,7 +26,8 @@
#include "uicb.h" #include "uicb.h"
Bool xgettextprop(Window, Atom, char *, ssize_t); 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_spawn;
Uicb uicb_exec; Uicb uicb_exec;