Skip to content

Commit 19cc36a

Browse files
emersionkennylevinsen
authored andcommitted
render: fix titlebar texture clipping
We need to provide an unclipped dst_box. Fixes: swaywm#7573 Regressed by: swaywm#7552
1 parent 0a95151 commit 19cc36a

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

sway/desktop/render.c

+14-12
Original file line numberDiff line numberDiff line change
@@ -509,23 +509,24 @@ static void render_titlebar(struct render_context *ctx, struct sway_container *c
509509
texture_box.y = round((bg_y - output_y) * output_scale) +
510510
ob_padding_above;
511511

512-
if (ob_inner_width < texture_box.width) {
513-
texture_box.width = ob_inner_width;
512+
struct wlr_box clip_box = texture_box;
513+
if (ob_inner_width < clip_box.width) {
514+
clip_box.width = ob_inner_width;
514515
}
515516
render_texture(ctx, marks_texture,
516-
NULL, &texture_box, NULL, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);
517+
NULL, &texture_box, &clip_box, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);
517518

518519
// Padding above
519520
memcpy(&color, colors->background, sizeof(float) * 4);
520521
premultiply_alpha(color, con->alpha);
521-
box.x = texture_box.x + round(output_x * output_scale);
522+
box.x = clip_box.x + round(output_x * output_scale);
522523
box.y = roundf((y + titlebar_border_thickness) * output_scale);
523-
box.width = texture_box.width;
524+
box.width = clip_box.width;
524525
box.height = ob_padding_above;
525526
render_rect(ctx, &box, color);
526527

527528
// Padding below
528-
box.y += ob_padding_above + texture_box.height;
529+
box.y += ob_padding_above + clip_box.height;
529530
box.height = ob_padding_below;
530531
render_rect(ctx, &box, color);
531532
}
@@ -579,24 +580,25 @@ static void render_titlebar(struct render_context *ctx, struct sway_container *c
579580
texture_box.y =
580581
round((bg_y - output_y) * output_scale) + ob_padding_above;
581582

582-
if (ob_inner_width - ob_marks_width < texture_box.width) {
583-
texture_box.width = ob_inner_width - ob_marks_width;
583+
struct wlr_box clip_box = texture_box;
584+
if (ob_inner_width - ob_marks_width < clip_box.width) {
585+
clip_box.width = ob_inner_width - ob_marks_width;
584586
}
585587

586588
render_texture(ctx, title_texture,
587-
NULL, &texture_box, NULL, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);
589+
NULL, &texture_box, &clip_box, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);
588590

589591
// Padding above
590592
memcpy(&color, colors->background, sizeof(float) * 4);
591593
premultiply_alpha(color, con->alpha);
592-
box.x = texture_box.x + round(output_x * output_scale);
594+
box.x = clip_box.x + round(output_x * output_scale);
593595
box.y = roundf((y + titlebar_border_thickness) * output_scale);
594-
box.width = texture_box.width;
596+
box.width = clip_box.width;
595597
box.height = ob_padding_above;
596598
render_rect(ctx, &box, color);
597599

598600
// Padding below
599-
box.y += ob_padding_above + texture_box.height;
601+
box.y += ob_padding_above + clip_box.height;
600602
box.height = ob_padding_below;
601603
render_rect(ctx, &box, color);
602604
}

0 commit comments

Comments
 (0)