@ -72,8 +72,9 @@ static size_t parse_outputs_env(const char *name) {
return outputs ;
return outputs ;
}
}
static struct wlr_backend * attempt_wl_backend ( struct wl_display * display ) {
static struct wlr_backend * attempt_wl_backend ( struct wl_display * display ,
struct wlr_backend * backend = wlr_wl_backend_create ( display , NULL ) ;
wlr_renderer_create_func_t create_renderer_func ) {
struct wlr_backend * backend = wlr_wl_backend_create ( display , NULL , create_renderer_func ) ;
if ( backend = = NULL ) {
if ( backend = = NULL ) {
return NULL ;
return NULL ;
}
}
@ -88,8 +89,8 @@ static struct wlr_backend *attempt_wl_backend(struct wl_display *display) {
# ifdef WLR_HAS_X11_BACKEND
# ifdef WLR_HAS_X11_BACKEND
static struct wlr_backend * attempt_x11_backend ( struct wl_display * display ,
static struct wlr_backend * attempt_x11_backend ( struct wl_display * display ,
const char * x11_display ) {
const char * x11_display , wlr_renderer_create_func_t create_renderer_func ) {
struct wlr_backend * backend = wlr_x11_backend_create ( display , x11_display );
struct wlr_backend * backend = wlr_x11_backend_create ( display , x11_display , create_renderer_func );
if ( backend = = NULL ) {
if ( backend = = NULL ) {
return NULL ;
return NULL ;
}
}
@ -104,8 +105,8 @@ static struct wlr_backend *attempt_x11_backend(struct wl_display *display,
# endif
# endif
static struct wlr_backend * attempt_headless_backend (
static struct wlr_backend * attempt_headless_backend (
struct wl_display * display ) {
struct wl_display * display , wlr_renderer_create_func_t create_renderer_func ) {
struct wlr_backend * backend = wlr_headless_backend_create ( display );
struct wlr_backend * backend = wlr_headless_backend_create ( display , create_renderer_func );
if ( backend = = NULL ) {
if ( backend = = NULL ) {
return NULL ;
return NULL ;
}
}
@ -119,7 +120,8 @@ static struct wlr_backend *attempt_headless_backend(
}
}
static struct wlr_backend * attempt_drm_backend ( struct wl_display * display ,
static struct wlr_backend * attempt_drm_backend ( struct wl_display * display ,
struct wlr_backend * backend , struct wlr_session * session ) {
struct wlr_backend * backend , struct wlr_session * session ,
wlr_renderer_create_func_t create_renderer_func ) {
int gpus [ 8 ] ;
int gpus [ 8 ] ;
size_t num_gpus = wlr_session_find_gpus ( session , 8 , gpus ) ;
size_t num_gpus = wlr_session_find_gpus ( session , 8 , gpus ) ;
struct wlr_backend * primary_drm = NULL ;
struct wlr_backend * primary_drm = NULL ;
@ -127,7 +129,7 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
for ( size_t i = 0 ; i < num_gpus ; + + i ) {
for ( size_t i = 0 ; i < num_gpus ; + + i ) {
struct wlr_backend * drm = wlr_drm_backend_create ( display , session ,
struct wlr_backend * drm = wlr_drm_backend_create ( display , session ,
gpus [ i ] , primary_drm );
gpus [ i ] , primary_drm , create_renderer_func );
if ( ! drm ) {
if ( ! drm ) {
wlr_log ( L_ERROR , " Failed to open DRM device %d " , gpus [ i ] ) ;
wlr_log ( L_ERROR , " Failed to open DRM device %d " , gpus [ i ] ) ;
continue ;
continue ;
@ -145,15 +147,15 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
static struct wlr_backend * attempt_backend_by_name ( struct wl_display * display ,
static struct wlr_backend * attempt_backend_by_name ( struct wl_display * display ,
struct wlr_backend * backend , struct wlr_session * * session ,
struct wlr_backend * backend , struct wlr_session * * session ,
const char * name ) {
const char * name , wlr_renderer_create_func_t create_renderer_func ) {
if ( strcmp ( name , " wayland " ) = = 0 ) {
if ( strcmp ( name , " wayland " ) = = 0 ) {
return attempt_wl_backend ( display );
return attempt_wl_backend ( display , create_renderer_func );
# ifdef WLR_HAS_X11_BACKEND
# ifdef WLR_HAS_X11_BACKEND
} else if ( strcmp ( name , " x11 " ) = = 0 ) {
} else if ( strcmp ( name , " x11 " ) = = 0 ) {
return attempt_x11_backend ( display , NULL );
return attempt_x11_backend ( display , NULL , create_renderer_func );
# endif
# endif
} else if ( strcmp ( name , " headless " ) = = 0 ) {
} else if ( strcmp ( name , " headless " ) = = 0 ) {
return attempt_headless_backend ( display );
return attempt_headless_backend ( display , create_renderer_func );
} 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
* session = wlr_session_create ( display ) ;
* session = wlr_session_create ( display ) ;
@ -165,7 +167,7 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
if ( strcmp ( name , " libinput " ) = = 0 ) {
if ( strcmp ( name , " libinput " ) = = 0 ) {
return wlr_libinput_backend_create ( display , * session ) ;
return wlr_libinput_backend_create ( display , * session ) ;
} else {
} else {
return attempt_drm_backend ( display , backend , * session );
return attempt_drm_backend ( display , backend , * session , create_renderer_func );
}
}
}
}
@ -173,7 +175,8 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
return NULL ;
return NULL ;
}
}
struct wlr_backend * wlr_backend_autocreate ( struct wl_display * display ) {
struct wlr_backend * wlr_backend_autocreate ( struct wl_display * display ,
wlr_renderer_create_func_t create_renderer_func ) {
struct wlr_backend * backend = wlr_multi_backend_create ( display ) ;
struct wlr_backend * backend = wlr_multi_backend_create ( display ) ;
if ( ! backend ) {
if ( ! backend ) {
wlr_log ( L_ERROR , " could not allocate multibackend " ) ;
wlr_log ( L_ERROR , " could not allocate multibackend " ) ;
@ -195,7 +198,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
char * name = strtok_r ( names , " , " , & saveptr ) ;
char * name = strtok_r ( names , " , " , & saveptr ) ;
while ( name ! = NULL ) {
while ( name ! = NULL ) {
struct wlr_backend * subbackend =
struct wlr_backend * subbackend =
attempt_backend_by_name ( display , backend , & session , name );
attempt_backend_by_name ( display , backend , & session , name , create_renderer_func );
if ( subbackend = = NULL ) {
if ( subbackend = = NULL ) {
wlr_log ( L_ERROR , " failed to start backend '%s' " , name ) ;
wlr_log ( L_ERROR , " failed to start backend '%s' " , name ) ;
wlr_backend_destroy ( backend ) ;
wlr_backend_destroy ( backend ) ;
@ -218,7 +221,8 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
if ( getenv ( " WAYLAND_DISPLAY " ) | | getenv ( " _WAYLAND_DISPLAY " ) | |
if ( getenv ( " WAYLAND_DISPLAY " ) | | getenv ( " _WAYLAND_DISPLAY " ) | |
getenv ( " WAYLAND_SOCKET " ) ) {
getenv ( " WAYLAND_SOCKET " ) ) {
struct wlr_backend * wl_backend = attempt_wl_backend ( display ) ;
struct wlr_backend * wl_backend = attempt_wl_backend ( display ,
create_renderer_func ) ;
if ( wl_backend ) {
if ( wl_backend ) {
wlr_multi_backend_add ( backend , wl_backend ) ;
wlr_multi_backend_add ( backend , wl_backend ) ;
return backend ;
return backend ;
@ -229,7 +233,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
const char * x11_display = getenv ( " DISPLAY " ) ;
const char * x11_display = getenv ( " DISPLAY " ) ;
if ( x11_display ) {
if ( x11_display ) {
struct wlr_backend * x11_backend =
struct wlr_backend * x11_backend =
attempt_x11_backend ( display , x11_display );
attempt_x11_backend ( display , x11_display , create_renderer_func );
if ( x11_backend ) {
if ( x11_backend ) {
wlr_multi_backend_add ( backend , x11_backend ) ;
wlr_multi_backend_add ( backend , x11_backend ) ;
return backend ;
return backend ;
@ -255,7 +259,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
wlr_multi_backend_add ( backend , libinput ) ;
wlr_multi_backend_add ( backend , libinput ) ;
struct wlr_backend * primary_drm =
struct wlr_backend * primary_drm =
attempt_drm_backend ( display , backend , session );
attempt_drm_backend ( display , backend , session , create_renderer_func );
if ( ! primary_drm ) {
if ( ! primary_drm ) {
wlr_log ( L_ERROR , " Failed to open any DRM device " ) ;
wlr_log ( L_ERROR , " Failed to open any DRM device " ) ;
wlr_backend_destroy ( libinput ) ;
wlr_backend_destroy ( libinput ) ;