]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: prevent child views from opening right/bottom of usable area
authortokyo4j <hrak1529@gmail.com>
Wed, 5 Jun 2024 02:09:10 +0000 (11:09 +0900)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 5 Jun 2024 17:52:10 +0000 (19:52 +0200)
src/view.c

index ab106208f0bcb83b4b267fab34d1b496d717a4e9..f83c9a6630adb4d237a8a78dfab4ce017ae6a85e 100644 (file)
@@ -728,12 +728,16 @@ view_compute_centered_position(struct view *view, const struct wlr_box *ref,
        *x = ref->x + (ref->width - width) / 2;
        *y = ref->y + (ref->height - height) / 2;
 
-       /* If view is bigger than usable area, just top/left align it */
+       /* Fit the view within the usable area */
        if (*x < usable.x) {
                *x = usable.x;
+       } else if (*x + width > usable.x + usable.width) {
+               *x = usable.x + usable.width - width;
        }
        if (*y < usable.y) {
                *y = usable.y;
+       } else if (*y + height > usable.y + usable.height) {
+               *y = usable.y + usable.height - height;
        }
 
        *x += margin.left;