aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonicgamer <44382222+Bonicgamer@users.noreply.github.com>2020-09-08 14:53:34 -0400
committerGitHub <noreply@github.com>2020-09-08 14:53:34 -0400
commit4915214e47d8f9233bfe4446a223300908455865 (patch)
tree7c4d3eaffd4a21752b193b042678d0dbba81cc44
parent45a2e25d6d84819ca8e81cc0c19aa72a38b342cb (diff)
Made scalebox the way sway does it
-rw-r--r--dwl.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/dwl.c b/dwl.c
index 730e46a..d54c702 100644
--- a/dwl.c
+++ b/dwl.c
@@ -50,6 +50,7 @@
#define LENGTH(X) (sizeof X / sizeof X[0])
#define END(A) ((A) + LENGTH(A))
#define TAGMASK ((1 << LENGTH(tags)) - 1)
+#define ROUND(X) ((X)>=0?(long)((X)+0.5):(long)((X)-0.5))
#ifdef XWAYLAND
#define WLR_SURFACE(C) ((C)->type != XDGShell ? (C)->surface.xwayland->surface : (C)->surface.xdg->surface)
#else
@@ -1344,10 +1345,10 @@ run(char *startup_cmd)
void
scalebox(struct wlr_box *box, float scale)
{
- box->x *= scale;
- box->y *= scale;
- box->width *= scale;
- box->height *= scale;
+ box->width = ROUND((box->x + box->width) * scale) - ROUND(box->x * scale);
+ box->height = ROUND((box->y + box->height) * scale) - ROUND(box->y * scale);
+ box->x = ROUND(box->x * scale);
+ box->y = ROUND(box->y * scale);
}
Client *