diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 553275d7..c0f7134e 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -380,22 +380,24 @@ struct wlr_box *wlr_output_layout_get_box( } } else { // layout extents - int min_x = INT_MAX, min_y = INT_MAX; - int max_x = INT_MIN, max_y = INT_MIN; - wl_list_for_each(l_output, &layout->outputs, link) { - struct wlr_box *box = output_layout_output_get_box(l_output); - - if (box->x < min_x) { - min_x = box->x; - } - if (box->y < min_y) { - min_y = box->y; - } - if (box->x + box->width > max_x) { - max_x = box->x + box->width; - } - if (box->y + box->height > max_y) { - max_y = box->y + box->height; + int min_x = 0, max_x = 0, min_y = 0, max_y = 0; + if (!wl_list_empty(&layout->outputs)) { + min_x = min_y = INT_MAX; + max_x = max_y = INT_MIN; + wl_list_for_each(l_output, &layout->outputs, link) { + struct wlr_box *box = output_layout_output_get_box(l_output); + if (box->x < min_x) { + min_x = box->x; + } + if (box->y < min_y) { + min_y = box->y; + } + if (box->x + box->width > max_x) { + max_x = box->x + box->width; + } + if (box->y + box->height > max_y) { + max_y = box->y + box->height; + } } }