diff --git a/examples/basic/viewport.c b/examples/basic/viewport.c index a9b8961..506ec78 100644 --- a/examples/basic/viewport.c +++ b/examples/basic/viewport.c @@ -10,8 +10,8 @@ static void resize(MwWidget handle, void* user, void* call) { (void)call; MwVaApply(vp, - MwNwidth, w - 10, - MwNheight, h - 10, + MwNwidth, w - 10 - 100, + MwNheight, h - 10 - 100, NULL); } @@ -23,7 +23,7 @@ int main() { w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480, MwNtitle, "test", NULL); - vp = MwCreateWidget(MwViewportClass, "vp", w, 5, 5, 630, 470); + vp = MwCreateWidget(MwViewportClass, "vp", w, 5 + 100, 5 + 100, 640 - 10 - 100, 480 - 10 - 100); px = MwLoadImage(vp, "examples/picture.png"); diff --git a/src/backend/wayland.c b/src/backend/wayland.c index b7ef2f1..24b7014 100644 --- a/src/backend/wayland.c +++ b/src/backend/wayland.c @@ -1741,18 +1741,17 @@ static void clip(MwLL handle) { y = 0; cx = 0; cy = 0; - // # ws is traversed result - // # ws[ws.length - 1] is ignored bc it's toplevel + // ws is traversed result + // ws[ws.length - 1] is ignored bc it's toplevel for(i = arrlen(ws) - 2; i >= 0; i--) { x += ws[i]->wayland.x; y += ws[i]->wayland.y; + cx += MAX(-ws[i]->wayland.x, 0); + cy += MAX(-ws[i]->wayland.y, 0); w = MIN(ws[i]->wayland.ww - MAX(-x, 0), w); h = MIN(ws[i]->wayland.wh - MAX(-y, 0), h); } - cx = MAX(-x, 0); - cy = MAX(-y, 0); - arrfree(ws); handle->wayland.clipping_rect.x = cx;