desktop: Avoid centering views without initial geometry

This commit is contained in:
John Lindgren 2023-02-15 12:52:57 -05:00 committed by Johan Malm
parent e465a41c0a
commit 859eba1c6b
2 changed files with 17 additions and 2 deletions

View file

@ -46,10 +46,21 @@ desktop_move_to_back(struct view *view)
void void
desktop_arrange_all_views(struct server *server) desktop_arrange_all_views(struct server *server)
{ {
/* Adjust window positions/sizes */ /*
* Adjust window positions/sizes. Skip views with no size since
* we can't do anything useful with them; they will presumably
* be initialized with valid positions/sizes later.
*
* We do not simply check view->mapped/been_mapped here because
* views can have maximized/fullscreen geometry applied while
* still unmapped. We do want to adjust the geometry of those
* views.
*/
struct view *view; struct view *view;
wl_list_for_each(view, &server->views, link) { wl_list_for_each(view, &server->views, link) {
view_adjust_for_layout_change(view); if (!wlr_box_empty(&view->pending)) {
view_adjust_for_layout_change(view);
}
} }
} }

View file

@ -245,6 +245,10 @@ view_output(struct view *view)
static bool static bool
view_compute_centered_position(struct view *view, int w, int h, int *x, int *y) view_compute_centered_position(struct view *view, int w, int h, int *x, int *y)
{ {
if (w <= 0 || h <= 0) {
wlr_log(WLR_ERROR, "view has empty geometry, not centering");
return false;
}
struct output *output = view_output(view); struct output *output = view_output(view);
if (!output) { if (!output) {
return false; return false;