mirror of
				https://github.com/swaywm/sway.git
				synced 2025-10-29 05:40:18 -04:00 
			
		
		
		
	swaybar: add free_hotspots helper function
This commit is contained in:
		
							parent
							
								
									a67fa8a05d
								
							
						
					
					
						commit
						19f0bf3864
					
				
					 3 changed files with 15 additions and 18 deletions
				
			
		|  | @ -102,6 +102,7 @@ bool bar_setup(struct swaybar *bar, const char *socket_path); | ||||||
| void bar_run(struct swaybar *bar); | void bar_run(struct swaybar *bar); | ||||||
| void bar_teardown(struct swaybar *bar); | void bar_teardown(struct swaybar *bar); | ||||||
| 
 | 
 | ||||||
|  | void free_hotspots(struct wl_list *list); | ||||||
| void free_workspaces(struct wl_list *list); | void free_workspaces(struct wl_list *list); | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -35,6 +35,17 @@ static void bar_init(struct swaybar *bar) { | ||||||
| 	wl_list_init(&bar->outputs); | 	wl_list_init(&bar->outputs); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void free_hotspots(struct wl_list *list) { | ||||||
|  | 	struct swaybar_hotspot *hotspot, *tmp; | ||||||
|  | 	wl_list_for_each_safe(hotspot, tmp, list, link) { | ||||||
|  | 		wl_list_remove(&hotspot->link); | ||||||
|  | 		if (hotspot->destroy) { | ||||||
|  | 			hotspot->destroy(hotspot->data); | ||||||
|  | 		} | ||||||
|  | 		free(hotspot); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void free_workspaces(struct wl_list *list) { | void free_workspaces(struct wl_list *list) { | ||||||
| 	struct swaybar_workspace *ws, *tmp; | 	struct swaybar_workspace *ws, *tmp; | ||||||
| 	wl_list_for_each_safe(ws, tmp, list, link) { | 	wl_list_for_each_safe(ws, tmp, list, link) { | ||||||
|  | @ -59,14 +70,8 @@ static void swaybar_output_free(struct swaybar_output *output) { | ||||||
| 	wl_output_destroy(output->output); | 	wl_output_destroy(output->output); | ||||||
| 	destroy_buffer(&output->buffers[0]); | 	destroy_buffer(&output->buffers[0]); | ||||||
| 	destroy_buffer(&output->buffers[1]); | 	destroy_buffer(&output->buffers[1]); | ||||||
|  | 	free_hotspots(&output->hotspots); | ||||||
| 	free_workspaces(&output->workspaces); | 	free_workspaces(&output->workspaces); | ||||||
| 	struct swaybar_hotspot *hotspot, *hotspot_tmp; |  | ||||||
| 	wl_list_for_each_safe(hotspot, hotspot_tmp, &output->hotspots, link) { |  | ||||||
| 		if (hotspot->destroy) { |  | ||||||
| 			hotspot->destroy(hotspot->data); |  | ||||||
| 		} |  | ||||||
| 		free(hotspot); |  | ||||||
| 	} |  | ||||||
| 	wl_list_remove(&output->link); | 	wl_list_remove(&output->link); | ||||||
| 	free(output->name); | 	free(output->name); | ||||||
| 	free(output); | 	free(output); | ||||||
|  | @ -75,9 +80,7 @@ static void swaybar_output_free(struct swaybar_output *output) { | ||||||
| static void set_output_dirty(struct swaybar_output *output) { | static void set_output_dirty(struct swaybar_output *output) { | ||||||
| 	if (output->frame_scheduled) { | 	if (output->frame_scheduled) { | ||||||
| 		output->dirty = true; | 		output->dirty = true; | ||||||
| 		return; | 	} else if (output->surface) { | ||||||
| 	} |  | ||||||
| 	if (output->surface) { |  | ||||||
| 		render_frame(output); | 		render_frame(output); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -491,14 +491,7 @@ static const struct wl_callback_listener output_frame_listener = { | ||||||
| void render_frame(struct swaybar_output *output) { | void render_frame(struct swaybar_output *output) { | ||||||
| 	assert(output->surface != NULL); | 	assert(output->surface != NULL); | ||||||
| 
 | 
 | ||||||
| 	struct swaybar_hotspot *hotspot, *tmp; | 	free_hotspots(&output->hotspots); | ||||||
| 	wl_list_for_each_safe(hotspot, tmp, &output->hotspots, link) { |  | ||||||
| 		if (hotspot->destroy) { |  | ||||||
| 			hotspot->destroy(hotspot->data); |  | ||||||
| 		} |  | ||||||
| 		wl_list_remove(&hotspot->link); |  | ||||||
| 		free(hotspot); |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	cairo_surface_t *recorder = cairo_recording_surface_create( | 	cairo_surface_t *recorder = cairo_recording_surface_create( | ||||||
| 			CAIRO_CONTENT_COLOR_ALPHA, NULL); | 			CAIRO_CONTENT_COLOR_ALPHA, NULL); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ian Fan
						Ian Fan