aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/output.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-12 22:36:11 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-12 22:36:11 +1000
commitc699a86e472d81c4654f19d39e42eb8cfd64bd94 (patch)
treed73f1824e5d76f4a6556e1d9a880329517847e00 /sway/desktop/output.c
parentMerge pull request #2821 from meakio/master (diff)
downloadsway-c699a86e472d81c4654f19d39e42eb8cfd64bd94.tar.gz
sway-c699a86e472d81c4654f19d39e42eb8cfd64bd94.tar.zst
sway-c699a86e472d81c4654f19d39e42eb8cfd64bd94.zip
Fix pixel leaks when using fractional scaling
The basic idea here is to apply rounding after scaling. It's not as simple as this, though, and I've detailed it in the comments for a function. In order to fix some pixel leaks in the title bar, I found it easier to change how we place rectangles to fill the area. Instead of placing two rectangles across the full width above and below the title and having shorter rectangles in the inner area, it's now pieced together in vertical chunks. This method involves drawing two less rectangles per container.
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r--sway/desktop/output.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index adc1ee10..fc52dd28 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -223,11 +223,15 @@ void output_drag_icons_for_each_surface(struct sway_output *output,
223 } 223 }
224} 224}
225 225
226static int scale_length(int length, int offset, float scale) {
227 return round((offset + length) * scale) - round(offset * scale);
228}
229
226static void scale_box(struct wlr_box *box, float scale) { 230static void scale_box(struct wlr_box *box, float scale) {
227 box->x *= scale; 231 box->width = scale_length(box->width, box->x, scale);
228 box->y *= scale; 232 box->height = scale_length(box->height, box->y, scale);
229 box->width *= scale; 233 box->x = round(box->x * scale);
230 box->height *= scale; 234 box->y = round(box->y * scale);
231} 235}
232 236
233struct sway_workspace *output_get_active_workspace(struct sway_output *output) { 237struct sway_workspace *output_get_active_workspace(struct sway_output *output) {