Check the return value of wlr_output_layout_get() for NULL

wlr_output_layout_get() seems to return NULL for disabled outputs.

Fixes: #174
This commit is contained in:
John Lindgren 2021-12-24 15:53:49 -05:00 committed by Johan Malm
parent 46bd0d549f
commit 2ce961a0bd
2 changed files with 8 additions and 0 deletions

View file

@ -125,6 +125,10 @@ view_center(struct view *view)
struct wlr_output_layout *layout = view->server->output_layout;
struct wlr_output_layout_output *ol_output =
wlr_output_layout_get(layout, wlr_output);
if (!ol_output) {
return;
}
int center_x = ol_output->x + wlr_output->width / wlr_output->scale / 2;
int center_y = ol_output->y + wlr_output->height / wlr_output->scale / 2;
view_move(view, center_x - view->w / 2, center_y - view->h / 2);