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

@ -55,15 +55,7 @@ add_scene_rect(struct wl_list *list, enum ssd_part_type type,
struct wlr_scene_tree *parent, int width, int height,
int x, int y, float color[4])
{
/*
* When initialized without surface being mapped,
* size may be negative. Just set to 0, next call
* to ssd_*_update() will update the rect to use
* its correct size.
*/
width = width >= 0 ? width : 0;
height = height >= 0 ? height : 0;
assert(width >= 0 && height >= 0);
struct ssd_part *part = add_scene_part(list, type);
part->node = &wlr_scene_rect_create(
parent, width, height, color)->node;