From 9b89836e73ed14659d7ff6fdcbdd53747a84727a Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Mon, 14 Nov 2011 15:54:41 +0100 Subject: [PATCH] some cleanup --- dunst.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/dunst.c b/dunst.c index 9455695..c553dd9 100644 --- a/dunst.c +++ b/dunst.c @@ -104,25 +104,21 @@ append(msg_queue_t *queue, char *msg, int to, int urgency, const char *fg, const new->msg = fix_markup(msg); - new->urgency = urgency; - new->urgency = new->urgency > CRIT ? CRIT : new->urgency; + new->urgency = urgency > CRIT ? CRIT : urgency; if(fg == NULL || !XAllocNamedColor(dc->dpy, cmap, fg, &color, &color)) { new->colors[ColFG] = colors[new->urgency][ColFG]; } else { new->colors[ColFG] = color.pixel; } + if(bg == NULL || !XAllocNamedColor(dc->dpy, cmap, bg, &color, &color)) { new->colors[ColBG] = colors[new->urgency][ColBG]; } else { new->colors[ColBG] = color.pixel; } - if(to == -1) { - new->timeout = timeouts[urgency]; - } else { - new->timeout = to; - } + new->timeout = to == -1 ? timeouts[urgency] : to; new->start = 0; dunst_printf("%s (timeout: %d, urgency: %d)\n", new->msg, new->timeout, urgency); @@ -139,12 +135,9 @@ msg_queue_t* delete(msg_queue_t *elem) { msg_queue_t *prev; msg_queue_t *next; - if(msgqueue == NULL) { + if(msgqueue == NULL || elem == NULL) { return NULL; } - if(elem == NULL) { - return msgqueue; - } if(elem == msgqueue) { next = elem->next; @@ -507,14 +500,10 @@ setup(void) { void show_win(void) { - if(visible == True) { - /* window is already visible */ - return; - } - if(msgqueue == NULL) { - /* there's nothing to show */ + if(visible || msgqueue == NULL) { return; } + XMapRaised(dc->dpy, win); XGrabButton(dc->dpy, AnyButton, AnyModifier, win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);