rename initxcolor to draw_color_new() and move it to draw.c
This commit is contained in:
parent
16607e39e6
commit
b6642e45c8
1
client.c
1
client.c
|
@ -26,7 +26,6 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "rules.h"
|
#include "rules.h"
|
||||||
#include "xutil.h"
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
|
|
|
@ -407,4 +407,25 @@ draw_get_align(const char *align)
|
||||||
return AlignLeft;
|
return AlignLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Initialize an X color
|
||||||
|
* \param disp display ref
|
||||||
|
* \param screen Physical screen number
|
||||||
|
* \param colstr Color specification
|
||||||
|
* \return XColor struct
|
||||||
|
*/
|
||||||
|
XColor
|
||||||
|
draw_color_new(Display *disp, int phys_screen, const char *colstr)
|
||||||
|
{
|
||||||
|
XColor screenColor, exactColor;
|
||||||
|
|
||||||
|
if(!XAllocNamedColor(disp,
|
||||||
|
DefaultColormap(disp, phys_screen),
|
||||||
|
colstr,
|
||||||
|
&screenColor,
|
||||||
|
&exactColor))
|
||||||
|
eprint("awesome: error, cannot allocate color '%s'\n", colstr);
|
||||||
|
|
||||||
|
return screenColor;
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
@ -70,6 +70,7 @@ Area draw_get_image_size(const char *filename);
|
||||||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||||
unsigned short draw_textwidth(Display *, XftFont *, char *);
|
unsigned short draw_textwidth(Display *, XftFont *, char *);
|
||||||
Alignment draw_get_align(const char *);
|
Alignment draw_get_align(const char *);
|
||||||
|
XColor draw_color_new(Display *, int, const char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// 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
|
||||||
|
|
16
config.c
16
config.c
|
@ -323,21 +323,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(globalconf.display, phys_screen,
|
virtscreen->colors_normal[ColBorder] = draw_color_new(globalconf.display, phys_screen,
|
||||||
cfg_getstr(cfg_colors, "normal_border"));
|
cfg_getstr(cfg_colors, "normal_border"));
|
||||||
virtscreen->colors_normal[ColBG] = initxcolor(globalconf.display, phys_screen,
|
virtscreen->colors_normal[ColBG] = draw_color_new(globalconf.display, phys_screen,
|
||||||
cfg_getstr(cfg_colors, "normal_bg"));
|
cfg_getstr(cfg_colors, "normal_bg"));
|
||||||
virtscreen->colors_normal[ColFG] = initxcolor(globalconf.display, phys_screen,
|
virtscreen->colors_normal[ColFG] = draw_color_new(globalconf.display, phys_screen,
|
||||||
cfg_getstr(cfg_colors, "normal_fg"));
|
cfg_getstr(cfg_colors, "normal_fg"));
|
||||||
virtscreen->colors_selected[ColBorder] = initxcolor(globalconf.display, phys_screen,
|
virtscreen->colors_selected[ColBorder] = draw_color_new(globalconf.display, phys_screen,
|
||||||
cfg_getstr(cfg_colors, "focus_border"));
|
cfg_getstr(cfg_colors, "focus_border"));
|
||||||
virtscreen->colors_selected[ColBG] = initxcolor(globalconf.display, phys_screen,
|
virtscreen->colors_selected[ColBG] = draw_color_new(globalconf.display, phys_screen,
|
||||||
cfg_getstr(cfg_colors, "focus_bg"));
|
cfg_getstr(cfg_colors, "focus_bg"));
|
||||||
virtscreen->colors_selected[ColFG] = initxcolor(globalconf.display, phys_screen,
|
virtscreen->colors_selected[ColFG] = draw_color_new(globalconf.display, phys_screen,
|
||||||
cfg_getstr(cfg_colors, "focus_fg"));
|
cfg_getstr(cfg_colors, "focus_fg"));
|
||||||
virtscreen->colors_urgent[ColBG] = initxcolor(globalconf.display, phys_screen,
|
virtscreen->colors_urgent[ColBG] = draw_color_new(globalconf.display, phys_screen,
|
||||||
cfg_getstr(cfg_colors, "urgent_bg"));
|
cfg_getstr(cfg_colors, "urgent_bg"));
|
||||||
virtscreen->colors_urgent[ColFG] = initxcolor(globalconf.display, phys_screen,
|
virtscreen->colors_urgent[ColFG] = draw_color_new(globalconf.display, phys_screen,
|
||||||
cfg_getstr(cfg_colors, "urgent_fg"));
|
cfg_getstr(cfg_colors, "urgent_fg"));
|
||||||
|
|
||||||
/* Statusbar */
|
/* Statusbar */
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "xutil.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
|
||||||
|
@ -88,12 +87,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(globalconf.display, phys_screen, buf);
|
d->fg = draw_color_new(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(globalconf.display, phys_screen, buf);
|
d->bg = draw_color_new(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];
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include "common/draw.h"
|
#include "common/draw.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "xutil.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
|
||||||
|
@ -291,7 +290,7 @@ graph_new(Statusbar *statusbar, cfg_t *config)
|
||||||
cfg = cfg_getnsec(config, "data", i);
|
cfg = cfg_getnsec(config, "data", i);
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "fg")))
|
if((color = cfg_getstr(cfg, "fg")))
|
||||||
tmp_color = initxcolor(globalconf.display, phys_screen, color);
|
tmp_color = draw_color_new(globalconf.display, phys_screen, color);
|
||||||
else
|
else
|
||||||
tmp_color = globalconf.screens[statusbar->screen].colors_normal[ColFG];
|
tmp_color = globalconf.screens[statusbar->screen].colors_normal[ColFG];
|
||||||
|
|
||||||
|
@ -335,12 +334,12 @@ graph_new(Statusbar *statusbar, cfg_t *config)
|
||||||
}
|
}
|
||||||
|
|
||||||
if((color = cfg_getstr(config, "bg")))
|
if((color = cfg_getstr(config, "bg")))
|
||||||
d->bg = initxcolor(globalconf.display, phys_screen, color);
|
d->bg = draw_color_new(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(globalconf.display, phys_screen, color);
|
d->bordercolor = draw_color_new(globalconf.display, phys_screen, color);
|
||||||
else
|
else
|
||||||
d->bordercolor = tmp_color;
|
d->bordercolor = tmp_color;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "xutil.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
|
||||||
|
@ -163,17 +162,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(globalconf.display, phys_screen, color);
|
d->fg[i] = draw_color_new(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(globalconf.display, phys_screen, color);
|
d->bg[i] = draw_color_new(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(globalconf.display, phys_screen, color);
|
d->bordercolor[i] = draw_color_new(globalconf.display, phys_screen, color);
|
||||||
else
|
else
|
||||||
d->bordercolor[i] = d->fg[i];
|
d->bordercolor[i] = d->fg[i];
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "xutil.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
|
@ -241,22 +240,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(globalconf.display, phys_screen, buf);
|
d->fg = draw_color_new(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(globalconf.display, phys_screen, buf);
|
d->bg = draw_color_new(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(globalconf.display, phys_screen, buf);
|
d->bg_sel = draw_color_new(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(globalconf.display, phys_screen, buf);
|
d->fg_sel = draw_color_new(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];
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "xutil.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
|
||||||
|
@ -81,9 +80,9 @@ textbox_tell(Widget *widget, char *command)
|
||||||
if (ntok)
|
if (ntok)
|
||||||
*ntok = 0;
|
*ntok = 0;
|
||||||
if (!i)
|
if (!i)
|
||||||
d->fg = initxcolor(globalconf.display, phys_screen, tok);
|
d->fg = draw_color_new(globalconf.display, phys_screen, tok);
|
||||||
else
|
else
|
||||||
d->bg = initxcolor(globalconf.display, phys_screen, tok);
|
d->bg = draw_color_new(globalconf.display, phys_screen, tok);
|
||||||
if (ntok)
|
if (ntok)
|
||||||
*ntok = ' ';
|
*ntok = ' ';
|
||||||
tok = ntok + (ntok != NULL);
|
tok = ntok + (ntok != NULL);
|
||||||
|
@ -109,12 +108,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(globalconf.display, statusbar->screen, buf);
|
d->fg = draw_color_new(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(globalconf.display, get_phys_screen(statusbar->screen), buf);
|
d->bg = draw_color_new(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];
|
||||||
|
|
||||||
|
|
19
xutil.c
19
xutil.c
|
@ -123,25 +123,6 @@ xgettextprop(Window w, Atom atom, char *text, ssize_t textlen)
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize an X color
|
|
||||||
* \param screen Physical screen number
|
|
||||||
* \param colstr Color specification
|
|
||||||
*/
|
|
||||||
XColor
|
|
||||||
initxcolor(Display *disp, int phys_screen, const char *colstr)
|
|
||||||
{
|
|
||||||
XColor screenColor, exactColor;
|
|
||||||
|
|
||||||
if(!XAllocNamedColor(disp,
|
|
||||||
DefaultColormap(disp, phys_screen),
|
|
||||||
colstr,
|
|
||||||
&screenColor,
|
|
||||||
&exactColor))
|
|
||||||
eprint("awesome: error, cannot allocate color '%s'\n", colstr);
|
|
||||||
|
|
||||||
return screenColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
get_numlockmask(Display *disp)
|
get_numlockmask(Display *disp)
|
||||||
{
|
{
|
||||||
|
|
1
xutil.h
1
xutil.h
|
@ -26,7 +26,6 @@
|
||||||
#include "uicb.h"
|
#include "uicb.h"
|
||||||
|
|
||||||
Bool xgettextprop(Window, Atom, char *, ssize_t);
|
Bool xgettextprop(Window, Atom, char *, ssize_t);
|
||||||
XColor initxcolor(Display *, int, const char *);
|
|
||||||
unsigned int get_numlockmask(Display *);
|
unsigned int get_numlockmask(Display *);
|
||||||
Uicb uicb_spawn;
|
Uicb uicb_spawn;
|
||||||
Uicb uicb_exec;
|
Uicb uicb_exec;
|
||||||
|
|
Loading…
Reference in New Issue