mirror of
https://github.com/labwc/labwc.git
synced 2026-04-10 08:21:07 -04:00
graphic-helper: properly handle very small multi_rects
Before this patch, the multi_rect for a window switcher preview could be broken with a very small window (e.g. alacritty resized to 1x1).
This commit is contained in:
parent
44beeffbd7
commit
b503e48623
1 changed files with 9 additions and 2 deletions
|
|
@ -45,6 +45,7 @@ border_rect_set_size(struct border_rect *rect, int width, int height)
|
||||||
{
|
{
|
||||||
assert(rect);
|
assert(rect);
|
||||||
int border_width = rect->border_width;
|
int border_width = rect->border_width;
|
||||||
|
assert(MIN(width, height) >= rect->border_width * 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The border is drawn like below:
|
* The border is drawn like below:
|
||||||
|
|
@ -118,8 +119,14 @@ multi_rect_set_size(struct multi_rect *multi_rect, int width, int height)
|
||||||
assert(multi_rect);
|
assert(multi_rect);
|
||||||
int line_width = multi_rect->border_rects[0]->border_width;
|
int line_width = multi_rect->border_rects[0]->border_width;
|
||||||
for (size_t i = 0; i < 3; i++) {
|
for (size_t i = 0; i < 3; i++) {
|
||||||
border_rect_set_size(multi_rect->border_rects[i],
|
int w = width - i * line_width * 2;
|
||||||
width - i * line_width * 2, height - i * line_width * 2);
|
int h = height - i * line_width * 2;
|
||||||
|
bool is_valid_size = (w >= line_width * 2) && (h >= line_width * 2);
|
||||||
|
wlr_scene_node_set_enabled(&multi_rect->border_rects[i]->tree->node,
|
||||||
|
is_valid_size);
|
||||||
|
if (is_valid_size) {
|
||||||
|
border_rect_set_size(multi_rect->border_rects[i], w, h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue