mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	backend/multi: disallow multiple renderers at the same time
This commit is contained in:
		
							parent
							
								
									a1631dd9ee
								
							
						
					
					
						commit
						52bd8aa716
					
				
					 2 changed files with 16 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -130,20 +130,29 @@ static struct subbackend_state *multi_backend_get_subbackend(struct wlr_multi_ba
 | 
			
		|||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wlr_multi_backend_add(struct wlr_backend *_multi,
 | 
			
		||||
bool wlr_multi_backend_add(struct wlr_backend *_multi,
 | 
			
		||||
		struct wlr_backend *backend) {
 | 
			
		||||
	assert(wlr_backend_is_multi(_multi));
 | 
			
		||||
	struct wlr_multi_backend *multi = (struct wlr_multi_backend *)_multi;
 | 
			
		||||
 | 
			
		||||
	if (multi_backend_get_subbackend(multi, backend)) {
 | 
			
		||||
		// already added
 | 
			
		||||
		return;
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	struct subbackend_state *sub;
 | 
			
		||||
	if (!(sub = calloc(1, sizeof(struct subbackend_state)))) {
 | 
			
		||||
	struct wlr_renderer *multi_renderer =
 | 
			
		||||
		multi_backend_get_renderer(&multi->backend);
 | 
			
		||||
	struct wlr_renderer *backend_renderer = wlr_backend_get_renderer(backend);
 | 
			
		||||
	if (multi_renderer != NULL && backend_renderer != NULL) {
 | 
			
		||||
		wlr_log(L_ERROR, "Could not add backend: multiple renderers at the "
 | 
			
		||||
			"same time aren't supported");
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	struct subbackend_state *sub = calloc(1, sizeof(struct subbackend_state));
 | 
			
		||||
	if (sub == NULL) {
 | 
			
		||||
		wlr_log(L_ERROR, "Could not add backend: allocation failed");
 | 
			
		||||
		return;
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	wl_list_insert(&multi->backends, &sub->link);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -160,6 +169,7 @@ void wlr_multi_backend_add(struct wlr_backend *_multi,
 | 
			
		|||
	sub->new_output.notify = new_output_reemit;
 | 
			
		||||
 | 
			
		||||
	wlr_signal_emit_safe(&multi->events.backend_add, backend);
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wlr_multi_backend_remove(struct wlr_backend *_multi,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue