mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-10-29 05:40:12 -04:00 
			
		
		
		
	backend: fix attempt_backend_by_name multi backend self insertion
This commit is contained in:
		
							parent
							
								
									25bb92faee
								
							
						
					
					
						commit
						c0fd60be63
					
				
					 1 changed files with 20 additions and 30 deletions
				
			
		|  | @ -258,46 +258,46 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display, | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| static struct wlr_backend *attempt_backend_by_name(struct wl_display *display, | static bool attempt_backend_by_name(struct wl_display *display, | ||||||
| 		struct wlr_backend *backend, struct wlr_session **session, | 		struct wlr_multi_backend *multi, char *name) { | ||||||
| 		const char *name) { | 	struct wlr_backend *backend = NULL; | ||||||
| 	if (strcmp(name, "wayland") == 0) { | 	if (strcmp(name, "wayland") == 0) { | ||||||
| 		return attempt_wl_backend(display); | 		backend = attempt_wl_backend(display); | ||||||
| #if WLR_HAS_X11_BACKEND | #if WLR_HAS_X11_BACKEND | ||||||
| 	} else if (strcmp(name, "x11") == 0) { | 	} else if (strcmp(name, "x11") == 0) { | ||||||
| 		return attempt_x11_backend(display, NULL); | 		backend = attempt_x11_backend(display, NULL); | ||||||
| #endif | #endif | ||||||
| 	} else if (strcmp(name, "headless") == 0) { | 	} else if (strcmp(name, "headless") == 0) { | ||||||
| 		return attempt_headless_backend(display); | 		backend = attempt_headless_backend(display); | ||||||
| 	} else if (strcmp(name, "noop") == 0) { | 	} else if (strcmp(name, "noop") == 0) { | ||||||
| 		return attempt_noop_backend(display); | 		backend = attempt_noop_backend(display); | ||||||
| 	} else if (strcmp(name, "drm") == 0 || strcmp(name, "libinput") == 0) { | 	} else if (strcmp(name, "drm") == 0 || strcmp(name, "libinput") == 0) { | ||||||
| 		// DRM and libinput need a session
 | 		// DRM and libinput need a session
 | ||||||
| 		if (!*session) { | 		if (multi->session == NULL) { | ||||||
| 			*session = session_create_and_wait(display); | 			multi->session = session_create_and_wait(display); | ||||||
| 			if (!*session) { | 			if (multi->session == NULL) { | ||||||
| 				wlr_log(WLR_ERROR, "failed to start a session"); | 				wlr_log(WLR_ERROR, "failed to start a session"); | ||||||
| 				return NULL; | 				return false; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (strcmp(name, "libinput") == 0) { | 		if (strcmp(name, "libinput") == 0) { | ||||||
| #if WLR_HAS_LIBINPUT_BACKEND | #if WLR_HAS_LIBINPUT_BACKEND | ||||||
| 			return wlr_libinput_backend_create(display, *session); | 			backend = wlr_libinput_backend_create(display, multi->session); | ||||||
| #else |  | ||||||
| 			return NULL; |  | ||||||
| #endif | #endif | ||||||
| 		} else { | 		} else { | ||||||
| #if WLR_HAS_DRM_BACKEND | #if WLR_HAS_DRM_BACKEND | ||||||
| 			return attempt_drm_backend(display, backend, *session); | 			// attempt_drm_backend adds the multi drm backends itself
 | ||||||
| #else | 			return attempt_drm_backend(display, &multi->backend, | ||||||
| 			return NULL; | 					multi->session) != NULL; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
|  | 	} else { | ||||||
|  | 		wlr_log(WLR_ERROR, "unrecognized backend '%s'", name); | ||||||
|  | 		return false; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	wlr_log(WLR_ERROR, "unrecognized backend '%s'", name); | 	return wlr_multi_backend_add(&multi->backend, backend); | ||||||
| 	return NULL; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) { | struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) { | ||||||
|  | @ -323,17 +323,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) { | ||||||
| 		char *saveptr; | 		char *saveptr; | ||||||
| 		char *name = strtok_r(names, ",", &saveptr); | 		char *name = strtok_r(names, ",", &saveptr); | ||||||
| 		while (name != NULL) { | 		while (name != NULL) { | ||||||
| 			struct wlr_backend *subbackend = attempt_backend_by_name(display, | 			if (!attempt_backend_by_name(display, multi, name)) { | ||||||
| 				backend, &multi->session, name); |  | ||||||
| 			if (subbackend == NULL) { |  | ||||||
| 				wlr_log(WLR_ERROR, "failed to start backend '%s'", name); |  | ||||||
| 				wlr_session_destroy(multi->session); |  | ||||||
| 				wlr_backend_destroy(backend); |  | ||||||
| 				free(names); |  | ||||||
| 				return NULL; |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			if (!wlr_multi_backend_add(backend, subbackend)) { |  | ||||||
| 				wlr_log(WLR_ERROR, "failed to add backend '%s'", name); | 				wlr_log(WLR_ERROR, "failed to add backend '%s'", name); | ||||||
| 				wlr_session_destroy(multi->session); | 				wlr_session_destroy(multi->session); | ||||||
| 				wlr_backend_destroy(backend); | 				wlr_backend_destroy(backend); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Simon Zeni
						Simon Zeni