Merge branch 'xft' into next
Conflicts: config.mk
This commit is contained in:
commit
9b4d9ec205
10
config.mk
10
config.mk
@ -5,18 +5,22 @@ MANPREFIX = ${PREFIX}/share/man
|
|||||||
X11INC = /usr/X11R6/include
|
X11INC = /usr/X11R6/include
|
||||||
X11LIB = /usr/X11R6/lib
|
X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
|
# Xft, comment if you don't want it
|
||||||
|
XFTINC = -I/usr/include/freetype2
|
||||||
|
XFTLIBS = -lXft -lXrender -lfreetype -lz -lfontconfig
|
||||||
|
|
||||||
# Xinerama, comment if you don't want it
|
# Xinerama, comment if you don't want it
|
||||||
XINERAMALIBS = -lXinerama
|
XINERAMALIBS = -lXinerama
|
||||||
XINERAMAFLAGS = -DXINERAMA
|
XINERAMAFLAGS = -DXINERAMA
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I${X11INC} -I/usr/lib/dbus-1.0/include -I/usr/include/dbus-1.0
|
INCS = -I${X11INC} -I/usr/lib/dbus-1.0/include -I/usr/include/dbus-1.0 ${XFTINC}
|
||||||
LIBS = -L${X11LIB} -lX11 -lXext -lXss -ldbus-1 -lpthread -lrt -liniparser ${XINERAMALIBS}
|
LIBS = -L${X11LIB} -lX11 -lXext -lXss -ldbus-1 ${XFTLIBS} -lpthread -liniparser lrt ${XINERAMALIBS}
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||||
CFLAGS = -g -ansi -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
|
CFLAGS = -g -ansi -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
|
||||||
LDFLAGS = -s ${LIBS}
|
LDFLAGS = ${LIBS}
|
||||||
|
|
||||||
# compiler and linker
|
# compiler and linker
|
||||||
CC = cc
|
CC = cc
|
||||||
|
108
draw.c
108
draw.c
@ -9,9 +9,6 @@
|
|||||||
|
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
#define DEFAULTFN "fixed"
|
|
||||||
|
|
||||||
static Bool loadfont(DC *dc, const char *fontstr);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color) {
|
drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color) {
|
||||||
@ -23,7 +20,7 @@ drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsign
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawtext(DC *dc, const char *text, unsigned long col[ColLast]) {
|
drawtext(DC *dc, const char *text, ColorSet *col) {
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
size_t mn, n = strlen(text);
|
size_t mn, n = strlen(text);
|
||||||
|
|
||||||
@ -35,19 +32,26 @@ drawtext(DC *dc, const char *text, unsigned long col[ColLast]) {
|
|||||||
if(mn < n)
|
if(mn < n)
|
||||||
for(n = MAX(mn-3, 0); n < mn; buf[n++] = '.');
|
for(n = MAX(mn-3, 0); n < mn; buf[n++] = '.');
|
||||||
|
|
||||||
drawrect(dc, 0, 0, dc->w, dc->h, True, BG(dc, col));
|
drawrect(dc, 0, 0, dc->w, dc->h, True, col->BG);
|
||||||
drawtextn(dc, buf, mn, col);
|
drawtextn(dc, buf, mn, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]) {
|
drawtextn(DC *dc, const char *text, size_t n, ColorSet *col) {
|
||||||
int x = dc->x + dc->font.height/2;
|
int x = dc->x + dc->font.height/2;
|
||||||
int y = dc->y + dc->font.ascent+1;
|
int y = dc->y + dc->font.ascent+1;
|
||||||
|
|
||||||
XSetForeground(dc->dpy, dc->gc, FG(dc, col));
|
XSetForeground(dc->dpy, dc->gc, col->FG);
|
||||||
if(dc->font.set)
|
if(dc->font.xft_font) {
|
||||||
|
if (!dc->xftdraw)
|
||||||
|
eprintf("error, xft drawable does not exist");
|
||||||
|
printf("XftDrawStringUtf8\n");
|
||||||
|
XftDrawStringUtf8(dc->xftdraw, &col->FG_xft,
|
||||||
|
dc->font.xft_font, x, y, (unsigned char*)text, n);
|
||||||
|
} else if(dc->font.set) {
|
||||||
|
printf("XmbDrawString\n");
|
||||||
XmbDrawString(dc->dpy, dc->canvas, dc->font.set, dc->gc, x, y, text, n);
|
XmbDrawString(dc->dpy, dc->canvas, dc->font.set, dc->gc, x, y, text, n);
|
||||||
else {
|
} else {
|
||||||
XSetFont(dc->dpy, dc->gc, dc->font.xfont->fid);
|
XSetFont(dc->dpy, dc->gc, dc->font.xfont->fid);
|
||||||
XDrawString(dc->dpy, dc->canvas, dc->gc, x, y, text, n);
|
XDrawString(dc->dpy, dc->canvas, dc->gc, x, y, text, n);
|
||||||
}
|
}
|
||||||
@ -68,16 +72,33 @@ eprintf(const char *fmt, ...) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
freecol(DC *dc, ColorSet *col) {
|
||||||
|
if(col) {
|
||||||
|
if(&col->FG_xft)
|
||||||
|
XftColorFree(dc->dpy, DefaultVisual(dc->dpy, DefaultScreen(dc->dpy)),
|
||||||
|
DefaultColormap(dc->dpy, DefaultScreen(dc->dpy)), &col->FG_xft);
|
||||||
|
free(col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freedc(DC *dc) {
|
freedc(DC *dc) {
|
||||||
|
if(dc->font.xft_font) {
|
||||||
|
XftFontClose(dc->dpy, dc->font.xft_font);
|
||||||
|
XftDrawDestroy(dc->xftdraw);
|
||||||
|
}
|
||||||
if(dc->font.set)
|
if(dc->font.set)
|
||||||
XFreeFontSet(dc->dpy, dc->font.set);
|
XFreeFontSet(dc->dpy, dc->font.set);
|
||||||
if(dc->font.xfont)
|
if(dc->font.xfont)
|
||||||
XFreeFont(dc->dpy, dc->font.xfont);
|
XFreeFont(dc->dpy, dc->font.xfont);
|
||||||
if(dc->canvas)
|
if(dc->canvas)
|
||||||
XFreePixmap(dc->dpy, dc->canvas);
|
XFreePixmap(dc->dpy, dc->canvas);
|
||||||
|
if(dc->gc)
|
||||||
XFreeGC(dc->dpy, dc->gc);
|
XFreeGC(dc->dpy, dc->gc);
|
||||||
|
if(dc->dpy)
|
||||||
XCloseDisplay(dc->dpy);
|
XCloseDisplay(dc->dpy);
|
||||||
|
if(dc)
|
||||||
free(dc);
|
free(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +112,20 @@ getcolor(DC *dc, const char *colstr) {
|
|||||||
return color.pixel;
|
return color.pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColorSet *
|
||||||
|
initcolor(DC *dc, const char * foreground, const char * background) {
|
||||||
|
ColorSet * col = (ColorSet *)malloc(sizeof(ColorSet));
|
||||||
|
if(!col)
|
||||||
|
eprintf("error, cannot allocate memory for color set");
|
||||||
|
col->BG = getcolor(dc, background);
|
||||||
|
col->FG = getcolor(dc, foreground);
|
||||||
|
if(dc->font.xft_font)
|
||||||
|
if(!XftColorAllocName(dc->dpy, DefaultVisual(dc->dpy, DefaultScreen(dc->dpy)),
|
||||||
|
DefaultColormap(dc->dpy, DefaultScreen(dc->dpy)), foreground, &col->FG_xft))
|
||||||
|
eprintf("error, cannot allocate xft font color '%s'\n", foreground);
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
DC *
|
DC *
|
||||||
initdc(void) {
|
initdc(void) {
|
||||||
DC *dc;
|
DC *dc;
|
||||||
@ -109,38 +144,33 @@ initdc(void) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
initfont(DC *dc, const char *fontstr) {
|
initfont(DC *dc, const char *fontstr) {
|
||||||
if(!loadfont(dc, fontstr ? fontstr : DEFAULTFN)) {
|
|
||||||
if(fontstr != NULL)
|
|
||||||
fprintf(stderr, "cannot load font '%s'\n", fontstr);
|
|
||||||
if(fontstr == NULL || !loadfont(dc, DEFAULTFN))
|
|
||||||
eprintf("cannot load font '%s'\n", DEFAULTFN);
|
|
||||||
}
|
|
||||||
dc->font.height = dc->font.ascent + dc->font.descent;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bool
|
|
||||||
loadfont(DC *dc, const char *fontstr) {
|
|
||||||
char *def, **missing, **names;
|
char *def, **missing, **names;
|
||||||
int i, n = 1;
|
int i, n;
|
||||||
XFontStruct **xfonts;
|
XFontStruct **xfonts;
|
||||||
|
|
||||||
if(!*fontstr)
|
missing = NULL;
|
||||||
return False;
|
if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) {
|
||||||
if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def)))
|
dc->font.ascent = dc->font.xfont->ascent;
|
||||||
|
dc->font.descent = dc->font.xfont->descent;
|
||||||
|
dc->font.width = dc->font.xfont->max_bounds.width;
|
||||||
|
} else if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) {
|
||||||
n = XFontsOfFontSet(dc->font.set, &xfonts, &names);
|
n = XFontsOfFontSet(dc->font.set, &xfonts, &names);
|
||||||
else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr)))
|
|
||||||
xfonts = &dc->font.xfont;
|
|
||||||
else
|
|
||||||
n = 0;
|
|
||||||
|
|
||||||
for(i = 0; i < n; i++) {
|
for(i = 0; i < n; i++) {
|
||||||
dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent);
|
dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent);
|
||||||
dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent);
|
dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent);
|
||||||
dc->font.width = MAX(dc->font.width, xfonts[i]->max_bounds.width);
|
dc->font.width = MAX(dc->font.width, xfonts[i]->max_bounds.width);
|
||||||
}
|
}
|
||||||
|
} else if((dc->font.xft_font = XftFontOpenName(dc->dpy, DefaultScreen(dc->dpy), fontstr))) {
|
||||||
|
dc->font.ascent = dc->font.xft_font->ascent;
|
||||||
|
dc->font.descent = dc->font.xft_font->descent;
|
||||||
|
dc->font.width = dc->font.xft_font->max_advance_width;
|
||||||
|
} else {
|
||||||
|
eprintf("cannot load font '%s'\n", fontstr);
|
||||||
|
}
|
||||||
if(missing)
|
if(missing)
|
||||||
XFreeStringList(missing);
|
XFreeStringList(missing);
|
||||||
return (dc->font.set || dc->font.xfont);
|
dc->font.height = dc->font.ascent + dc->font.descent;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -150,20 +180,32 @@ mapdc(DC *dc, Window win, unsigned int w, unsigned int h) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
resizedc(DC *dc, unsigned int w, unsigned int h) {
|
resizedc(DC *dc, unsigned int w, unsigned int h) {
|
||||||
|
int screen = DefaultScreen(dc->dpy);
|
||||||
if(dc->canvas)
|
if(dc->canvas)
|
||||||
XFreePixmap(dc->dpy, dc->canvas);
|
XFreePixmap(dc->dpy, dc->canvas);
|
||||||
|
|
||||||
dc->w = w;
|
dc->w = w;
|
||||||
dc->h = h;
|
dc->h = h;
|
||||||
dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h,
|
dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h,
|
||||||
DefaultDepth(dc->dpy, DefaultScreen(dc->dpy)));
|
DefaultDepth(dc->dpy, screen));
|
||||||
|
if(dc->xftdraw) {
|
||||||
|
XftDrawDestroy(dc->xftdraw);
|
||||||
|
}
|
||||||
|
if(dc->font.xft_font) {
|
||||||
|
dc->xftdraw = XftDrawCreate(dc->dpy, dc->canvas, DefaultVisual(dc->dpy,screen), DefaultColormap(dc->dpy,screen));
|
||||||
|
if(!(dc->xftdraw))
|
||||||
|
eprintf("error, cannot create xft drawable\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
textnw(DC *dc, const char *text, size_t len) {
|
textnw(DC *dc, const char *text, size_t len) {
|
||||||
if(dc->font.set) {
|
if(dc->font.xft_font) {
|
||||||
|
XGlyphInfo gi;
|
||||||
|
XftTextExtentsUtf8(dc->dpy, dc->font.xft_font, (const FcChar8*)text, len, &gi);
|
||||||
|
return gi.width;
|
||||||
|
} else if(dc->font.set) {
|
||||||
XRectangle r;
|
XRectangle r;
|
||||||
|
|
||||||
XmbTextExtents(dc->font.set, text, len, NULL, &r);
|
XmbTextExtents(dc->font.set, text, len, NULL, &r);
|
||||||
return r.width;
|
return r.width;
|
||||||
}
|
}
|
||||||
|
22
draw.h
22
draw.h
@ -1,12 +1,9 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
#ifndef DRAW_H
|
#ifndef DRAW_H
|
||||||
#define DRAW_H
|
#define DRAW_H
|
||||||
|
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
#define FG(dc, col) ((col)[(dc)->invert ? ColBG : ColFG])
|
|
||||||
#define BG(dc, col) ((col)[(dc)->invert ? ColFG : ColBG])
|
|
||||||
|
|
||||||
enum { ColBG, ColFG, ColBorder, ColLast };
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
@ -14,6 +11,7 @@ typedef struct {
|
|||||||
Display *dpy;
|
Display *dpy;
|
||||||
GC gc;
|
GC gc;
|
||||||
Pixmap canvas;
|
Pixmap canvas;
|
||||||
|
XftDraw *xftdraw;
|
||||||
struct {
|
struct {
|
||||||
int ascent;
|
int ascent;
|
||||||
int descent;
|
int descent;
|
||||||
@ -21,19 +19,29 @@ typedef struct {
|
|||||||
int width;
|
int width;
|
||||||
XFontSet set;
|
XFontSet set;
|
||||||
XFontStruct *xfont;
|
XFontStruct *xfont;
|
||||||
|
XftFont *xft_font;
|
||||||
} font;
|
} font;
|
||||||
} DC; /* draw context */
|
} DC; /* draw context */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned long FG;
|
||||||
|
XftColor FG_xft;
|
||||||
|
unsigned long BG;
|
||||||
|
} ColorSet;
|
||||||
|
|
||||||
void drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color);
|
void drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsigned long color);
|
||||||
void drawtext(DC *dc, const char *text, unsigned long col[ColLast]);
|
void drawtext(DC *dc, const char *text, ColorSet *col);
|
||||||
void drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]);
|
void drawtextn(DC *dc, const char *text, size_t n, ColorSet *col);
|
||||||
|
void freecol(DC *dc, ColorSet *col);
|
||||||
void eprintf(const char *fmt, ...);
|
void eprintf(const char *fmt, ...);
|
||||||
void freedc(DC *dc);
|
void freedc(DC *dc);
|
||||||
unsigned long getcolor(DC *dc, const char *colstr);
|
unsigned long getcolor(DC *dc, const char *colstr);
|
||||||
|
ColorSet *initcolor(DC *dc, const char *foreground, const char *background);
|
||||||
DC *initdc(void);
|
DC *initdc(void);
|
||||||
void initfont(DC *dc, const char *fontstr);
|
void initfont(DC *dc, const char *fontstr);
|
||||||
void mapdc(DC *dc, Window win, unsigned int w, unsigned int h);
|
void mapdc(DC *dc, Window win, unsigned int w, unsigned int h);
|
||||||
void resizedc(DC *dc, unsigned int w, unsigned int h);
|
void resizedc(DC *dc, unsigned int w, unsigned int h);
|
||||||
int textnw(DC *dc, const char *text, size_t len);
|
int textnw(DC *dc, const char *text, size_t len);
|
||||||
int textw(DC *dc, const char *text);
|
int textw(DC *dc, const char *text);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
62
dunst.c
62
dunst.c
@ -27,6 +27,8 @@
|
|||||||
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||||
#define FONT_HEIGHT_BORDER 2
|
#define FONT_HEIGHT_BORDER 2
|
||||||
|
|
||||||
|
#define DEFFONT "Monospace-11"
|
||||||
|
|
||||||
#define MSG 1
|
#define MSG 1
|
||||||
#define INFO 2
|
#define INFO 2
|
||||||
#define DEBUG 3
|
#define DEBUG 3
|
||||||
@ -60,7 +62,8 @@ int verbosity = 0;
|
|||||||
|
|
||||||
rule_t *rules = NULL;
|
rule_t *rules = NULL;
|
||||||
/* index of colors fit to urgency level */
|
/* index of colors fit to urgency level */
|
||||||
static unsigned long colors[3][ColLast];
|
static ColorSet *colors[3];
|
||||||
|
static const char *color_strings[3][3];
|
||||||
static Atom utf8;
|
static Atom utf8;
|
||||||
static DC *dc;
|
static DC *dc;
|
||||||
static Window win;
|
static Window win;
|
||||||
@ -358,13 +361,13 @@ drawmsg(void) {
|
|||||||
|
|
||||||
resizedc(dc, width, height*font_h);
|
resizedc(dc, width, height*font_h);
|
||||||
XResizeWindow(dc->dpy, win, width, height*font_h);
|
XResizeWindow(dc->dpy, win, width, height*font_h);
|
||||||
drawrect(dc, 0, 0, width, height*font_h, True, BG(dc, colors[NORM]));
|
drawrect(dc, 0, 0, width, height*font_h, True, colors[NORM]->BG);
|
||||||
|
|
||||||
for(i = 0; i < drawn_msg_count; i++) {
|
for(i = 0; i < drawn_msg_count; i++) {
|
||||||
if(cur_msg->start == 0)
|
if(cur_msg->start == 0)
|
||||||
cur_msg->start = now;
|
cur_msg->start = now;
|
||||||
|
|
||||||
drawrect(dc, 0, dc->y, width, font_h, True, BG(dc, cur_msg->colors));
|
drawrect(dc, 0, dc->y, width, font_h, True, cur_msg->colors->BG);
|
||||||
drawtext(dc, cur_msg->msg, cur_msg->colors);
|
drawtext(dc, cur_msg->msg, cur_msg->colors);
|
||||||
|
|
||||||
dc->y += font_h;
|
dc->y += font_h;
|
||||||
@ -373,7 +376,8 @@ drawmsg(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(hidden_count) {
|
if(hidden_count) {
|
||||||
drawrect(dc, 0, dc->y, width, font_h, True, BG(dc, colors[NORM]));
|
drawrect(dc, 0, dc->y, width, font_h, True, colors[NORM]->BG);
|
||||||
|
|
||||||
drawtext(dc, hidden, colors[hidden_color_idx]);
|
drawtext(dc, hidden, colors[hidden_color_idx]);
|
||||||
dc->y += font_h;
|
dc->y += font_h;
|
||||||
}
|
}
|
||||||
@ -506,21 +510,10 @@ handleXEvents(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_set_color(msg_queue_t *msg, int color_idx) {
|
|
||||||
Colormap cmap = DefaultColormap(dc->dpy, DefaultScreen(dc->dpy));
|
|
||||||
XColor color;
|
|
||||||
if(msg->color_strings[color_idx] == NULL
|
|
||||||
|| !XAllocNamedColor(dc->dpy, cmap,
|
|
||||||
msg->color_strings[color_idx], &color, &color)) {
|
|
||||||
msg->colors[color_idx] = colors[msg->urgency][color_idx];
|
|
||||||
} else {
|
|
||||||
msg->colors[color_idx] = color.pixel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
initmsg(msg_queue_t *msg) {
|
initmsg(msg_queue_t *msg) {
|
||||||
|
const char *fg = NULL;
|
||||||
|
const char *bg = NULL;
|
||||||
msg->format = format;
|
msg->format = format;
|
||||||
apply_rules(msg);
|
apply_rules(msg);
|
||||||
|
|
||||||
@ -534,8 +527,21 @@ initmsg(msg_queue_t *msg) {
|
|||||||
/* urgency > CRIT -> array out of range */
|
/* urgency > CRIT -> array out of range */
|
||||||
msg->urgency = msg->urgency > CRIT ? CRIT : msg->urgency;
|
msg->urgency = msg->urgency > CRIT ? CRIT : msg->urgency;
|
||||||
|
|
||||||
_set_color(msg, ColFG);
|
|
||||||
_set_color(msg, ColBG);
|
|
||||||
|
if (msg->color_strings[ColFG]) {
|
||||||
|
fg = msg->color_strings[ColFG];
|
||||||
|
} else {
|
||||||
|
fg = color_strings[ColFG][msg->urgency];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg->color_strings[ColBG]) {
|
||||||
|
bg = msg->color_strings[ColBG];
|
||||||
|
} else {
|
||||||
|
bg = color_strings[ColBG][msg->urgency];
|
||||||
|
}
|
||||||
|
|
||||||
|
msg->colors = initcolor(dc, fg, bg);
|
||||||
|
|
||||||
msg->timeout = msg->timeout == -1 ? timeouts[msg->urgency] : msg->timeout;
|
msg->timeout = msg->timeout == -1 ? timeouts[msg->urgency] : msg->timeout;
|
||||||
msg->start = 0;
|
msg->start = 0;
|
||||||
@ -630,13 +636,6 @@ setup(void) {
|
|||||||
}
|
}
|
||||||
root = RootWindow(dc->dpy, DefaultScreen(dc->dpy));
|
root = RootWindow(dc->dpy, DefaultScreen(dc->dpy));
|
||||||
|
|
||||||
colors[0][ColBG] = getcolor(dc, lowbgcolor);
|
|
||||||
colors[0][ColFG] = getcolor(dc, lowfgcolor);
|
|
||||||
colors[1][ColBG] = getcolor(dc, normbgcolor);
|
|
||||||
colors[1][ColFG] = getcolor(dc, normfgcolor);
|
|
||||||
colors[2][ColBG] = getcolor(dc, critbgcolor);
|
|
||||||
colors[2][ColFG] = getcolor(dc, critfgcolor);
|
|
||||||
|
|
||||||
utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);
|
utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);
|
||||||
|
|
||||||
/* menu geometry */
|
/* menu geometry */
|
||||||
@ -1010,6 +1009,17 @@ main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
initdbus();
|
initdbus();
|
||||||
initfont(dc, font);
|
initfont(dc, font);
|
||||||
|
colors[LOW] = initcolor(dc, lowfgcolor, lowbgcolor);
|
||||||
|
colors[NORM] = initcolor(dc, normfgcolor, normbgcolor);
|
||||||
|
colors[CRIT] = initcolor(dc, critfgcolor, critbgcolor);
|
||||||
|
|
||||||
|
color_strings[ColFG][LOW] = lowfgcolor;
|
||||||
|
color_strings[ColFG][NORM] = normfgcolor;
|
||||||
|
color_strings[ColFG][LOW] = lowfgcolor;
|
||||||
|
|
||||||
|
color_strings[ColBG][LOW] = lowbgcolor;
|
||||||
|
color_strings[ColBG][NORM] = normbgcolor;
|
||||||
|
color_strings[ColBG][CRIT] = critbgcolor;
|
||||||
setup();
|
setup();
|
||||||
if(msgqueue != NULL) {
|
if(msgqueue != NULL) {
|
||||||
show_win();
|
show_win();
|
||||||
|
8
dunst.h
8
dunst.h
@ -7,6 +7,10 @@
|
|||||||
#define NORM 1
|
#define NORM 1
|
||||||
#define CRIT 2
|
#define CRIT 2
|
||||||
|
|
||||||
|
#define ColLast 2
|
||||||
|
#define ColFG 1
|
||||||
|
#define ColBG 0
|
||||||
|
|
||||||
typedef struct _rule_t {
|
typedef struct _rule_t {
|
||||||
char *name;
|
char *name;
|
||||||
/* filters */
|
/* filters */
|
||||||
@ -36,8 +40,8 @@ typedef struct _msg_queue_t {
|
|||||||
time_t start;
|
time_t start;
|
||||||
int timeout;
|
int timeout;
|
||||||
int urgency;
|
int urgency;
|
||||||
unsigned long colors[ColLast];
|
ColorSet *colors;
|
||||||
char *color_strings[ColLast];
|
char *color_strings[2];
|
||||||
} msg_queue_t;
|
} msg_queue_t;
|
||||||
|
|
||||||
typedef struct _dimension_t {
|
typedef struct _dimension_t {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user