ssd: guard against negative sizes

We always create a SSD for 0x0 window since decorations are usually
requested before a window is mapped. Thus the sizes of some buffers/rects
like edge shadows could be negative, which is asserted in wlroots 0.19.
This commit is contained in:
tokyo4j 2025-05-04 22:33:12 +09:00 committed by Hiroaki Yamamoto
parent defa1d1a98
commit 93d77801c5
4 changed files with 16 additions and 23 deletions

View file

@ -49,7 +49,7 @@ ssd_border_create(struct ssd *ssd)
add_scene_rect(&subtree->parts, LAB_SSD_PART_BOTTOM, parent,
full_width, theme->border_width, 0, height, color);
add_scene_rect(&subtree->parts, LAB_SSD_PART_TOP, parent,
width - 2 * corner_width, theme->border_width,
MAX(width - 2 * corner_width, 0), theme->border_width,
theme->border_width + corner_width,
-(ssd->titlebar.height + theme->border_width), color);
} FOR_EACH_END
@ -123,7 +123,7 @@ ssd_border_update(struct ssd *ssd)
: 0;
int top_width = ssd->titlebar.height <= 0 || ssd->state.was_squared
? full_width
: width - 2 * corner_width;
: MAX(width - 2 * corner_width, 0);
int top_x = ssd->titlebar.height <= 0 || ssd->state.was_squared
? 0
: theme->border_width + corner_width;