]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: Make view_apply_special_geometry() return void
authorJohn Lindgren <john@jlindgren.net>
Mon, 20 Feb 2023 21:29:41 +0000 (16:29 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 5 Mar 2023 08:44:03 +0000 (08:44 +0000)
This makes the conditions for calling it explicit and more obvious.

src/view.c

index bcf8e20c586348b9a27c8e700e988100214392f0..39f34109feb1cc9c3a11c0104c40f00381325fe2 100644 (file)
@@ -496,9 +496,12 @@ view_apply_maximized_geometry(struct view *view)
        view_move_resize(view, box);
 }
 
-static bool
+static void
 view_apply_special_geometry(struct view *view)
 {
+       assert(view);
+       assert(!view_is_floating(view));
+
        if (view->fullscreen) {
                view_apply_fullscreen_geometry(view);
        } else if (view->maximized) {
@@ -508,9 +511,8 @@ view_apply_special_geometry(struct view *view)
        } else if (view->tiled_region || view->tiled_region_evacuate) {
                view_apply_region_geometry(view);
        } else {
-               return false;
+               assert(false); // not reached
        }
-       return true;
 }
 
 /* For internal use only. Does not update geometry. */
@@ -590,8 +592,10 @@ view_maximize(struct view *view, bool maximize, bool store_natural_geometry)
                }
        }
        set_maximized(view, maximize);
-       if (!view_apply_special_geometry(view)) {
+       if (view_is_floating(view)) {
                view_apply_natural_geometry(view);
+       } else {
+               view_apply_special_geometry(view);
        }
 }
 
@@ -675,7 +679,9 @@ view_set_decorations(struct view *view, bool decorations)
                } else {
                        undecorate(view);
                }
-               view_apply_special_geometry(view);
+               if (!view_is_floating(view)) {
+                       view_apply_special_geometry(view);
+               }
        }
 }
 
@@ -741,8 +747,10 @@ view_set_fullscreen(struct view *view, bool fullscreen)
        }
 
        set_fullscreen(view, fullscreen);
-       if (!view_apply_special_geometry(view)) {
+       if (view_is_floating(view)) {
                view_apply_natural_geometry(view);
+       } else {
+               view_apply_special_geometry(view);
        }
 }
 
@@ -761,20 +769,20 @@ view_adjust_for_layout_change(struct view *view)
         * Floating views are always assigned to the nearest output.
         * Maximized/tiled views remain on the same output if possible.
         */
-       if (view_is_floating(view) || !output_is_usable(view->output)) {
+       bool is_floating = view_is_floating(view);
+       if (is_floating || !output_is_usable(view->output)) {
                view_discover_output(view);
        }
 
-       if (!view_apply_special_geometry(view)) {
-               if (was_fullscreen) {
-                       view_apply_natural_geometry(view);
-               } else {
-                       /* reposition view if it's offscreen */
-                       if (!wlr_output_layout_intersects(
-                                       view->server->output_layout,
-                                       NULL, &view->pending)) {
-                               view_center(view, NULL);
-                       }
+       if (!is_floating) {
+               view_apply_special_geometry(view);
+       } else if (was_fullscreen) {
+               view_apply_natural_geometry(view);
+       } else {
+               /* reposition view if it's offscreen */
+               if (!wlr_output_layout_intersects(view->server->output_layout,
+                               NULL, &view->pending)) {
+                       view_center(view, NULL);
                }
        }
        if (view->toplevel.handle) {