only redraw when needed
This commit is contained in:
		
							parent
							
								
									8e29c4dc5b
								
							
						
					
					
						commit
						5e66f5d007
					
				
							
								
								
									
										31
									
								
								dunst.c
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								dunst.c
									
									
									
									
									
								
							| @ -77,6 +77,8 @@ static char **dmenu_cmd; | |||||||
| static unsigned long framec; | static unsigned long framec; | ||||||
| static unsigned long sep_custom_col; | static unsigned long sep_custom_col; | ||||||
| 
 | 
 | ||||||
|  | bool force_redraw = false; | ||||||
|  | 
 | ||||||
| bool dunst_grab_errored = false; | bool dunst_grab_errored = false; | ||||||
| 
 | 
 | ||||||
| int next_notification_id = 1; | int next_notification_id = 1; | ||||||
| @ -493,6 +495,7 @@ void update_lists() | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 g_queue_insert_sorted(displayed, n, cmp_notification_data, NULL); |                 g_queue_insert_sorted(displayed, n, cmp_notification_data, NULL); | ||||||
|  |                 force_redraw = true; | ||||||
|         } |         } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -948,8 +951,7 @@ void handleXEvents(void) | |||||||
|                 switch (ev.type) { |                 switch (ev.type) { | ||||||
|                 case Expose: |                 case Expose: | ||||||
|                         if (ev.xexpose.count == 0 && visible) { |                         if (ev.xexpose.count == 0 && visible) { | ||||||
|                                 draw_win(); |                                 force_redraw = true; | ||||||
|                                 mapdc(dc, win, scr.dim.w, font_h); |  | ||||||
|                         } |                         } | ||||||
|                         break; |                         break; | ||||||
|                 case SelectionNotify: |                 case SelectionNotify: | ||||||
| @ -962,6 +964,7 @@ void handleXEvents(void) | |||||||
|                 case ButtonPress: |                 case ButtonPress: | ||||||
|                         if (ev.xbutton.window == win) { |                         if (ev.xbutton.window == win) { | ||||||
|                                 handle_mouse_click(ev); |                                 handle_mouse_click(ev); | ||||||
|  |                                 force_redraw = true; | ||||||
|                         } |                         } | ||||||
|                         break; |                         break; | ||||||
|                 case KeyPress: |                 case KeyPress: | ||||||
| @ -987,6 +990,8 @@ void handleXEvents(void) | |||||||
|                             && context_ks.mask == ev.xkey.state) { |                             && context_ks.mask == ev.xkey.state) { | ||||||
|                                 context_menu(); |                                 context_menu(); | ||||||
|                         } |                         } | ||||||
|  |                         force_redraw = true; | ||||||
|  |                         break; | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
| } | } | ||||||
| @ -1305,6 +1310,7 @@ bool is_idle(void) | |||||||
| 
 | 
 | ||||||
| void run(void) | void run(void) | ||||||
| { | { | ||||||
|  |         time_t last_time = time(&last_time); | ||||||
|         while (true) { |         while (true) { | ||||||
|                 if (visible) { |                 if (visible) { | ||||||
|                         dbus_poll(50); |                         dbus_poll(50); | ||||||
| @ -1312,21 +1318,21 @@ void run(void) | |||||||
|                         dbus_poll(200); |                         dbus_poll(200); | ||||||
|                 } |                 } | ||||||
|                 now = time(&now); |                 now = time(&now); | ||||||
|  |                 time_t delta = now - last_time; | ||||||
|  |                 last_time = now; | ||||||
| 
 | 
 | ||||||
|                 /* move messages from notification_queue to displayed_notifications */ |                 /* move messages from notification_queue to displayed_notifications */ | ||||||
|                 update_lists(); |                 update_lists(); | ||||||
|                 if (displayed->length > 0) { |                 if (displayed->length > 0 && ! visible) | ||||||
|                         if (!visible) { |  | ||||||
|                         map_win(); |                         map_win(); | ||||||
|                         } else { |                 if (displayed->length == 0 && visible) | ||||||
|                                 draw_win(); |  | ||||||
|                         } |  | ||||||
|                 } else { |  | ||||||
|                         if (visible) { |  | ||||||
|                         hide_win(); |                         hide_win(); | ||||||
|                         } | 
 | ||||||
|                 } |  | ||||||
|                 handleXEvents(); |                 handleXEvents(); | ||||||
|  | 
 | ||||||
|  |                 if (visible && (force_redraw || delta > 0)) | ||||||
|  |                         draw_win(); | ||||||
|  |                 force_redraw = false; | ||||||
|         } |         } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -1551,9 +1557,8 @@ void map_win(void) | |||||||
| 
 | 
 | ||||||
|         update_screen_info(); |         update_screen_info(); | ||||||
|         XMapRaised(dc->dpy, win); |         XMapRaised(dc->dpy, win); | ||||||
|         draw_win(); |  | ||||||
|         XFlush(dc->dpy); |  | ||||||
|         visible = true; |         visible = true; | ||||||
|  |         force_redraw = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void parse_follow_mode(const char *mode) | void parse_follow_mode(const char *mode) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Sascha Kruse
						Sascha Kruse