]> git.mdlowis.com Git - proto/labwc.git/commitdiff
desktop: Avoid centering views without initial geometry
authorJohn Lindgren <john@jlindgren.net>
Wed, 15 Feb 2023 17:52:57 +0000 (12:52 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 15 Feb 2023 18:59:26 +0000 (18:59 +0000)
src/desktop.c
src/view.c

index 0e9827259096a3cd06beee2772db3d9ce3e57386..56d4a393edb999221e5e59014e984d397a21e841 100644 (file)
@@ -46,10 +46,21 @@ desktop_move_to_back(struct view *view)
 void
 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;
        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);
+               }
        }
 }
 
index eeb768f2199c3fe04e312ca652db1238b3957643..1bc0069e06da4326bd5f965f6c9f93d5c758e3dd 100644 (file)
@@ -245,6 +245,10 @@ view_output(struct view *view)
 static bool
 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);
        if (!output) {
                return false;