aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2023-05-09 16:39:48 +0200
committerLibravatar Kenny Levinsen <kl@kl.wtf>2023-05-09 18:12:06 +0200
commit19cc36accc0d5a9997fd264c98df92b8b0ed8bea (patch)
tree5fd35dce841d47efaba02bc1a7d19746fc8b735c
parentrender: Clear using wlr_output dimensions (diff)
downloadsway-19cc36accc0d5a9997fd264c98df92b8b0ed8bea.tar.gz
sway-19cc36accc0d5a9997fd264c98df92b8b0ed8bea.tar.zst
sway-19cc36accc0d5a9997fd264c98df92b8b0ed8bea.zip
render: fix titlebar texture clipping
We need to provide an unclipped dst_box. Fixes: https://github.com/swaywm/sway/issues/7573 Regressed by: https://github.com/swaywm/sway/pull/7552
-rw-r--r--sway/desktop/render.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index edefa658..223457b2 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -509,23 +509,24 @@ static void render_titlebar(struct render_context *ctx, struct sway_container *c
509 texture_box.y = round((bg_y - output_y) * output_scale) + 509 texture_box.y = round((bg_y - output_y) * output_scale) +
510 ob_padding_above; 510 ob_padding_above;
511 511
512 if (ob_inner_width < texture_box.width) { 512 struct wlr_box clip_box = texture_box;
513 texture_box.width = ob_inner_width; 513 if (ob_inner_width < clip_box.width) {
514 clip_box.width = ob_inner_width;
514 } 515 }
515 render_texture(ctx, marks_texture, 516 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);
517 518
518 // Padding above 519 // Padding above
519 memcpy(&color, colors->background, sizeof(float) * 4); 520 memcpy(&color, colors->background, sizeof(float) * 4);
520 premultiply_alpha(color, con->alpha); 521 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);
522 box.y = roundf((y + titlebar_border_thickness) * output_scale); 523 box.y = roundf((y + titlebar_border_thickness) * output_scale);
523 box.width = texture_box.width; 524 box.width = clip_box.width;
524 box.height = ob_padding_above; 525 box.height = ob_padding_above;
525 render_rect(ctx, &box, color); 526 render_rect(ctx, &box, color);
526 527
527 // Padding below 528 // Padding below
528 box.y += ob_padding_above + texture_box.height; 529 box.y += ob_padding_above + clip_box.height;
529 box.height = ob_padding_below; 530 box.height = ob_padding_below;
530 render_rect(ctx, &box, color); 531 render_rect(ctx, &box, color);
531 } 532 }
@@ -579,24 +580,25 @@ static void render_titlebar(struct render_context *ctx, struct sway_container *c
579 texture_box.y = 580 texture_box.y =
580 round((bg_y - output_y) * output_scale) + ob_padding_above; 581 round((bg_y - output_y) * output_scale) + ob_padding_above;
581 582
582 if (ob_inner_width - ob_marks_width < texture_box.width) { 583 struct wlr_box clip_box = texture_box;
583 texture_box.width = ob_inner_width - ob_marks_width; 584 if (ob_inner_width - ob_marks_width < clip_box.width) {
585 clip_box.width = ob_inner_width - ob_marks_width;
584 } 586 }
585 587
586 render_texture(ctx, title_texture, 588 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);
588 590
589 // Padding above 591 // Padding above
590 memcpy(&color, colors->background, sizeof(float) * 4); 592 memcpy(&color, colors->background, sizeof(float) * 4);
591 premultiply_alpha(color, con->alpha); 593 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);
593 box.y = roundf((y + titlebar_border_thickness) * output_scale); 595 box.y = roundf((y + titlebar_border_thickness) * output_scale);
594 box.width = texture_box.width; 596 box.width = clip_box.width;
595 box.height = ob_padding_above; 597 box.height = ob_padding_above;
596 render_rect(ctx, &box, color); 598 render_rect(ctx, &box, color);
597 599
598 // Padding below 600 // Padding below
599 box.y += ob_padding_above + texture_box.height; 601 box.y += ob_padding_above + clip_box.height;
600 box.height = ob_padding_below; 602 box.height = ob_padding_below;
601 render_rect(ctx, &box, color); 603 render_rect(ctx, &box, color);
602 } 604 }