tree-wide: do not try to use outputs with no scene_output

- check for valid scene_output in output_is_usable()
- change many "output != NULL" checks to use output_is_usable()
- remove one now-redundant separate check for valid scene_output

Fixes a crash at startup (with autoEnableOutputs=no) due to
dereferencing null scene_output in create_output_config() since:

7d7ece21d9
("output: suppress error when output position is unavailable")

Fixes: #3357
This commit is contained in:
John Lindgren 2026-02-04 10:31:06 -05:00 committed by Johan Malm
parent 81778a16bb
commit 4f8b80700e
9 changed files with 24 additions and 31 deletions

View file

@ -1409,7 +1409,7 @@ run_action(struct view *view, struct server *server, struct action *action,
break;
}
struct output *output = view->output;
if (!output) {
if (!output_is_usable(output)) {
break;
}
const char *region_name = action_get_str(action, "region", NULL);

View file

@ -145,7 +145,7 @@ try_to_focus_next_layer_or_toplevel(struct server *server)
{
struct seat *seat = &server->seat;
struct output *output = output_nearest_to_cursor(server);
if (!output) {
if (!output_is_usable(output)) {
goto no_output;
}
@ -589,16 +589,14 @@ handle_new_layer_surface(struct wl_listener *listener, void *data)
struct wlr_layer_surface_v1 *layer_surface = data;
if (!layer_surface->output) {
struct wlr_output *output = wlr_output_layout_output_at(
server->output_layout, server->seat.cursor->x,
server->seat.cursor->y);
if (!output) {
struct output *output = output_nearest_to_cursor(server);
if (!output_is_usable(output)) {
wlr_log(WLR_INFO,
"No output available to assign layer surface");
wlr_layer_surface_v1_destroy(layer_surface);
return;
}
layer_surface->output = output;
layer_surface->output = output->wlr_output;
}
struct lab_layer_surface *surface = znew(*surface);

View file

@ -731,7 +731,7 @@ menu_reposition(struct menu *menu, struct wlr_box anchor_rect)
/* Get output usable area to place the menu within */
struct output *output = output_nearest_to(menu->server,
anchor_rect.x, anchor_rect.y);
if (!output) {
if (!output_is_usable(output)) {
wlr_log(WLR_ERROR, "no output found around (%d,%d)",
anchor_rect.x, anchor_rect.y);
return;

View file

@ -128,17 +128,6 @@ handle_output_frame(struct wl_listener *listener, void *data)
return;
}
if (!output->scene_output) {
/*
* TODO: This is a short term fix for issue #1667,
* a proper fix would require restructuring
* the life cycle of scene outputs, e.g.
* creating them on handle_new_output() only.
*/
wlr_log(WLR_INFO, "Failed to render new frame: no scene-output");
return;
}
if (output->gamma_lut_changed) {
/*
* We are not mixing the gamma state with
@ -1062,8 +1051,14 @@ output_get_adjacent(struct output *output, enum lab_edge edge, bool wrap)
bool
output_is_usable(struct output *output)
{
/* output_is_usable(NULL) is safe and returns false */
return output && output->wlr_output->enabled;
/*
* output_is_usable(NULL) is safe and returns false.
*
* Checking output->scene_output != NULL is necessary in case the
* wlr_output was initially enabled but hasn't been configured yet
* (occurs with autoEnableOutputs=no).
*/
return output && output->wlr_output->enabled && output->scene_output;
}
/* returns true if usable area changed */
@ -1123,7 +1118,7 @@ output_update_all_usable_areas(struct server *server, bool layout_changed)
struct wlr_box
output_usable_area_in_layout_coords(struct output *output)
{
if (!output) {
if (!output_is_usable(output)) {
return (struct wlr_box){0};
}
struct wlr_box box = output->usable_area;

View file

@ -53,7 +53,7 @@ regions_from_cursor(struct server *server)
struct wlr_output *wlr_output = wlr_output_layout_output_at(
server->output_layout, lx, ly);
struct output *output = output_from_wlr_output(server, wlr_output);
if (!output) {
if (!output_is_usable(output)) {
return NULL;
}

View file

@ -95,7 +95,7 @@ ssd_extents_update(struct ssd *ssd)
wlr_scene_node_set_enabled(&ssd->extents.tree->node, true);
}
if (!view->output) {
if (!output_is_usable(view->output)) {
return;
}

View file

@ -1105,7 +1105,7 @@ view_place_by_policy(struct view *view, bool allow_cursor,
void
view_constrain_size_to_that_of_usable_area(struct view *view)
{
if (!view || !view->output || view->fullscreen) {
if (!view || !output_is_usable(view->output) || view->fullscreen) {
return;
}
@ -1900,7 +1900,7 @@ view_move_to_edge(struct view *view, enum lab_edge direction, bool snap_to_windo
/* Otherwise, move to edge of next adjacent display, if possible */
struct output *output =
output_get_adjacent(view->output, direction, /* wrap */ false);
if (!output) {
if (!output_is_usable(output)) {
return;
}
@ -2080,7 +2080,7 @@ view_snap_to_edge(struct view *view, enum lab_edge edge,
*/
output = output_get_adjacent(view->output, edge,
/* wrap */ false);
if (!output) {
if (!output_is_usable(output)) {
return;
}
edge = invert_edge;

View file

@ -500,7 +500,7 @@ handle_request_maximize(struct wl_listener *listener, void *data)
return;
}
if (!view->mapped && !view->output) {
if (!view->mapped && !output_is_usable(view->output)) {
view_set_output(view, output_nearest_to_cursor(view->server));
}
bool maximized = toplevel->requested.maximized;
@ -521,7 +521,7 @@ handle_request_fullscreen(struct wl_listener *listener, void *data)
return;
}
if (!view->mapped && !view->output) {
if (!view->mapped && !output_is_usable(view->output)) {
view_set_output(view, output_nearest_to_cursor(view->server));
}
set_fullscreen_from_request(view,
@ -819,7 +819,7 @@ handle_map(struct wl_listener *listener, void *data)
* An output should have been chosen when the surface was first
* created, but take one more opportunity to assign an output if not.
*/
if (!view->output) {
if (!output_is_usable(view->output)) {
view_set_output(view, output_nearest_to_cursor(view->server));
}

View file

@ -228,7 +228,7 @@ ensure_initial_geometry_and_output(struct view *view)
view->pending = view->current;
}
}
if (!view->output) {
if (!output_is_usable(view->output)) {
/*
* Just use the cursor output since we don't know yet
* whether the surface position is meaningful.