delete clicked msg

This commit is contained in:
Sascha Kruse 2011-11-27 03:38:47 +01:00
parent 22759b87c5
commit b1be9ee92c

23
dunst.c
View File

@ -65,6 +65,7 @@ void drawmsg(void);
void dunst_printf(int level, const char *fmt, ...); void dunst_printf(int level, const char *fmt, ...);
char *fix_markup(char *str); char *fix_markup(char *str);
void free_msgqueue_t(msg_queue_t *elem); void free_msgqueue_t(msg_queue_t *elem);
void handle_mouse_click(XEvent ev);
void handleXEvents(void); void handleXEvents(void);
void initmsg(msg_queue_t *msg); void initmsg(msg_queue_t *msg);
char *string_replace(const char *needle, const char *replacement, char *haystack); char *string_replace(const char *needle, const char *replacement, char *haystack);
@ -395,6 +396,22 @@ free_msgqueue_t(msg_queue_t *elem) {
free(elem); free(elem);
} }
void
handle_mouse_click(XEvent ev) {
msg_queue_t *cur_msg = msgqueue;
int i;
if(ev.xbutton.button == Button3) {
delete_all_msg();
} else if(ev.xbutton.button == Button1) {
i = ev.xbutton.y / font_h;
printf("i: %d\n",i);
for(i = i; i > 0; i--) {
cur_msg = cur_msg->next;
}
delete_msg(cur_msg);
}
}
void void
handleXEvents(void) { handleXEvents(void) {
XEvent ev; XEvent ev;
@ -414,11 +431,7 @@ handleXEvents(void) {
break; break;
case ButtonPress: case ButtonPress:
if(ev.xbutton.window == win) { if(ev.xbutton.window == win) {
if(ev.xbutton.button == Button1) { handle_mouse_click(ev);
delete_msg(NULL);
} else if(ev.xbutton.button == Button3) {
delete_all_msg();
}
} }
break; break;
case KeyPress: case KeyPress: