]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/layers.c: prevent crash with no outputs available
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 26 Dec 2022 22:11:01 +0000 (23:11 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Tue, 3 Jan 2023 19:46:31 +0000 (19:46 +0000)
src/layers.c

index eb5c6a6cff1477ed4a852affc4e758e9b7e371d0..7e27e0e59111af2fe5a9ef5bbea27b071448b0e9 100644 (file)
@@ -316,6 +316,12 @@ handle_new_layer_surface(struct wl_listener *listener, void *data)
                struct wlr_output *output = wlr_output_layout_output_at(
                        server->output_layout, server->seat.cursor->x,
                        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;
        }
 
@@ -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,
                &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
         * it can easily be arranged.