next_win()
replaced copy&paste code with function
This commit is contained in:
		
							parent
							
								
									86ee9b11bb
								
							
						
					
					
						commit
						c7c46243a7
					
				
							
								
								
									
										32
									
								
								dunst.c
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								dunst.c
									
									
									
									
									
								
							| @ -61,6 +61,7 @@ msg_queue_t *pop(msg_queue_t *queue); | |||||||
| void drawmsg(const char *msg); | void drawmsg(const char *msg); | ||||||
| void handleXEvents(void); | void handleXEvents(void); | ||||||
| void hide_win(void); | void hide_win(void); | ||||||
|  | void next_win(void); | ||||||
| void run(void); | void run(void); | ||||||
| void setup(void); | void setup(void); | ||||||
| void show_win(void); | void show_win(void); | ||||||
| @ -146,19 +147,13 @@ handleXEvents(void) { | |||||||
|                 XRaiseWindow(dc->dpy, win); |                 XRaiseWindow(dc->dpy, win); | ||||||
|             break; |             break; | ||||||
|         case ButtonPress: |         case ButtonPress: | ||||||
|             if(ev.xbutton.window == win && msgqueuehead != NULL) { |             if(ev.xbutton.window == win) { | ||||||
|                 msgqueuehead = pop(msgqueuehead); |                 next_win(); | ||||||
|                 if(msgqueuehead == NULL) { |  | ||||||
|                     hide_win(); |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|             break; |             break; | ||||||
|         case KeyPress: |         case KeyPress: | ||||||
|             if (XLookupKeysym(&ev.xkey, 0) == KEY  && msgqueuehead != NULL) { |             if(XLookupKeysym(&ev.xkey, 0) == KEY) { | ||||||
|                 msgqueuehead = pop(msgqueuehead); |                 next_win(); | ||||||
|                 if(msgqueuehead == NULL) { |  | ||||||
|                     hide_win(); |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -177,6 +172,17 @@ hide_win(void) { | |||||||
|     visible = False; |     visible = False; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void | ||||||
|  | next_win(void) { | ||||||
|  |     if(msgqueuehead == NULL) { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |     msgqueuehead = pop(msgqueuehead); | ||||||
|  |     if(msgqueuehead == NULL) { | ||||||
|  |         hide_win(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void | void | ||||||
| run(void) { | run(void) { | ||||||
| 
 | 
 | ||||||
| @ -189,11 +195,7 @@ run(void) { | |||||||
|         if(msgqueuehead != NULL) { |         if(msgqueuehead != NULL) { | ||||||
|             show_win(); |             show_win(); | ||||||
|             if(difftime(now, msgqueuehead->start) > global_timeout) { |             if(difftime(now, msgqueuehead->start) > global_timeout) { | ||||||
|                 msgqueuehead = pop(msgqueuehead); |                 next_win(); | ||||||
|                 if(msgqueuehead == NULL) { |  | ||||||
|                     hide_win(); |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|             } |             } | ||||||
|             handleXEvents(); |             handleXEvents(); | ||||||
|         } else if (!loop) { |         } else if (!loop) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Sascha Kruse
						Sascha Kruse