diff options
author | Bonicgamer <44382222+Bonicgamer@users.noreply.github.com> | 2020-09-08 14:53:34 -0400 |
---|---|---|
committer | Guido Cella <guido@guidocella.xyz> | 2020-12-19 18:35:25 +0100 |
commit | 679f6493c97df30cf6604778ac1ce6014dec952b (patch) | |
tree | 00795794b706a782a0ce2c5736de77c70d058f7e | |
parent | 9c2524b06a486cd01bfc06b73d10e2b903e3d82d (diff) |
Made scalebox the way sway does it
Scaling a wlr_box without rounding can sometimes make the borders not
connected and nice. I noticed this when setting scale in monrules to 1.2
So I've went and copied what Sway did in desktop/output.c but without
having a second function and now using a random rounding macro I found
on the internet so as to not use round from math.h.
-rw-r--r-- | dwl.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -55,6 +55,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 @@ -1896,10 +1897,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 * |