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.
This commit is contained in:
Ryan Dwyer 2018-10-12 22:36:11 +10:00
parent f52af18e0d
commit c699a86e47
2 changed files with 89 additions and 88 deletions

View file

@ -223,11 +223,15 @@ void output_drag_icons_for_each_surface(struct sway_output *output,
}
}
static int scale_length(int length, int offset, float scale) {
return round((offset + length) * scale) - round(offset * scale);
}
static void scale_box(struct wlr_box *box, float scale) {
box->x *= scale;
box->y *= scale;
box->width *= scale;
box->height *= scale;
box->width = scale_length(box->width, box->x, scale);
box->height = scale_length(box->height, box->y, scale);
box->x = round(box->x * scale);
box->y = round(box->y * scale);
}
struct sway_workspace *output_get_active_workspace(struct sway_output *output) {