From 0cff22c46a3f35cc0470295c07cdb4224cae7ff4 Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Sat, 18 Aug 2012 22:26:48 +0200 Subject: [PATCH] handle_mouse_click: handle split notifications --- dunst.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/dunst.c b/dunst.c index d4ecabf..c707fba 100644 --- a/dunst.c +++ b/dunst.c @@ -669,22 +669,25 @@ char void handle_mouse_click(XEvent ev) { - l_node *iter = displayed_notifications->head; - notification *n; if (ev.xbutton.button == Button3) { move_all_to_history(); - } else if (ev.xbutton.button == Button1) { - int i = ev.xbutton.y / font_h; - for (; i > 0; i--) { - /* if the user clicks on the "(x more)" message, - * keep iter at the last displayed message and - * remove that instead - */ - if (iter->next) { - iter = iter->next; - } + + return; + } + + if (ev.xbutton.button == Button1) { + int y = 0; + notification *n; + l_node *iter = displayed_notifications->head; + assert(iter); + for(; iter; iter = iter->next ) { + n = (notification *) iter->data; + int height = font_h * n->draw_txt_buf.line_count; + if (ev.xbutton.y > y && ev.xbutton.y < y + height) + break; + else + y += height; } - n = (notification *) iter->data; close_notification(n, 2); } }