Skip to content

Commit

Permalink
render: fix titlebar texture clipping
Browse files Browse the repository at this point in the history
We need to provide an unclipped dst_box.

Fixes: #7573
Regressed by: #7552
  • Loading branch information
emersion authored and kennylevinsen committed May 9, 2023
1 parent 0a95151 commit 19cc36a
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions sway/desktop/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,23 +509,24 @@ static void render_titlebar(struct render_context *ctx, struct sway_container *c
texture_box.y = round((bg_y - output_y) * output_scale) +
ob_padding_above;

if (ob_inner_width < texture_box.width) {
texture_box.width = ob_inner_width;
struct wlr_box clip_box = texture_box;
if (ob_inner_width < clip_box.width) {
clip_box.width = ob_inner_width;
}
render_texture(ctx, marks_texture,
NULL, &texture_box, NULL, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);
NULL, &texture_box, &clip_box, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);

// Padding above
memcpy(&color, colors->background, sizeof(float) * 4);
premultiply_alpha(color, con->alpha);
box.x = texture_box.x + round(output_x * output_scale);
box.x = clip_box.x + round(output_x * output_scale);
box.y = roundf((y + titlebar_border_thickness) * output_scale);
box.width = texture_box.width;
box.width = clip_box.width;
box.height = ob_padding_above;
render_rect(ctx, &box, color);

// Padding below
box.y += ob_padding_above + texture_box.height;
box.y += ob_padding_above + clip_box.height;
box.height = ob_padding_below;
render_rect(ctx, &box, color);
}
Expand Down Expand Up @@ -579,24 +580,25 @@ static void render_titlebar(struct render_context *ctx, struct sway_container *c
texture_box.y =
round((bg_y - output_y) * output_scale) + ob_padding_above;

if (ob_inner_width - ob_marks_width < texture_box.width) {
texture_box.width = ob_inner_width - ob_marks_width;
struct wlr_box clip_box = texture_box;
if (ob_inner_width - ob_marks_width < clip_box.width) {
clip_box.width = ob_inner_width - ob_marks_width;
}

render_texture(ctx, title_texture,
NULL, &texture_box, NULL, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);
NULL, &texture_box, &clip_box, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);

// Padding above
memcpy(&color, colors->background, sizeof(float) * 4);
premultiply_alpha(color, con->alpha);
box.x = texture_box.x + round(output_x * output_scale);
box.x = clip_box.x + round(output_x * output_scale);
box.y = roundf((y + titlebar_border_thickness) * output_scale);
box.width = texture_box.width;
box.width = clip_box.width;
box.height = ob_padding_above;
render_rect(ctx, &box, color);

// Padding below
box.y += ob_padding_above + texture_box.height;
box.y += ob_padding_above + clip_box.height;
box.height = ob_padding_below;
render_rect(ctx, &box, color);
}
Expand Down

0 comments on commit 19cc36a

Please sign in to comment.