mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
graphic-helper: properly handle very small multi_rects
For example, alacritty can be resized to 1x1 and the size of the scene-rects inside the multi_rect for the window switcher preview could be negative.
This commit is contained in:
parent
93d77801c5
commit
6305cc0f78
1 changed files with 10 additions and 5 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
#include <wlr/util/box.h>
|
#include <wlr/util/box.h>
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "common/graphic-helpers.h"
|
#include "common/graphic-helpers.h"
|
||||||
|
#include "common/macros.h"
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -57,7 +58,7 @@ multi_rect_set_size(struct multi_rect *rect, int width, int height)
|
||||||
* +-+-----+-+ |
|
* +-+-----+-+ |
|
||||||
* +---------+ ---
|
* +---------+ ---
|
||||||
*/
|
*/
|
||||||
for (size_t i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
/* Reposition, top and left don't ever change */
|
/* Reposition, top and left don't ever change */
|
||||||
wlr_scene_node_set_position(&rect->right[i]->node,
|
wlr_scene_node_set_position(&rect->right[i]->node,
|
||||||
width - (i + 1) * line_width, (i + 1) * line_width);
|
width - (i + 1) * line_width, (i + 1) * line_width);
|
||||||
|
|
@ -66,13 +67,17 @@ multi_rect_set_size(struct multi_rect *rect, int width, int height)
|
||||||
|
|
||||||
/* Update sizes */
|
/* Update sizes */
|
||||||
wlr_scene_rect_set_size(rect->top[i],
|
wlr_scene_rect_set_size(rect->top[i],
|
||||||
width - i * line_width * 2, line_width);
|
MAX(width - i * line_width * 2, 0),
|
||||||
|
line_width);
|
||||||
wlr_scene_rect_set_size(rect->bottom[i],
|
wlr_scene_rect_set_size(rect->bottom[i],
|
||||||
width - i * line_width * 2, line_width);
|
MAX(width - i * line_width * 2, 0),
|
||||||
|
line_width);
|
||||||
wlr_scene_rect_set_size(rect->left[i],
|
wlr_scene_rect_set_size(rect->left[i],
|
||||||
line_width, height - (i + 1) * line_width * 2);
|
line_width,
|
||||||
|
MAX(height - (i + 1) * line_width * 2, 0));
|
||||||
wlr_scene_rect_set_size(rect->right[i],
|
wlr_scene_rect_set_size(rect->right[i],
|
||||||
line_width, height - (i + 1) * line_width * 2);
|
line_width,
|
||||||
|
MAX(height - (i + 1) * line_width * 2, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue