src/layers.c: prevent crash with no outputs available

This commit is contained in:
Consolatis 2022-12-26 23:11:01 +01:00 committed by Johan Malm
parent e9aac4ce8f
commit cd645318e7

View file

@ -316,6 +316,12 @@ handle_new_layer_surface(struct wl_listener *listener, void *data)
struct wlr_output *output = wlr_output_layout_output_at( struct wlr_output *output = wlr_output_layout_output_at(
server->output_layout, server->seat.cursor->x, server->output_layout, server->seat.cursor->x,
server->seat.cursor->y); server->seat.cursor->y);
if (!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;
} }
@ -361,11 +367,6 @@ handle_new_layer_surface(struct wl_listener *listener, void *data)
wl_signal_add(&surface->scene_layer_surface->tree->node.events.destroy, wl_signal_add(&surface->scene_layer_surface->tree->node.events.destroy,
&surface->node_destroy); &surface->node_destroy);
if (!output) {
wlr_log(WLR_ERROR, "no output for layer");
return;
}
/* /*
* Temporarily set the layer's current state to pending so that * Temporarily set the layer's current state to pending so that
* it can easily be arranged. * it can easily be arranged.