2
0
Fork 0
mirror of https://github.com/FelixKratz/SketchyBar synced 2025-02-19 22:18:29 +00:00

stabilize against uint32_t underflow

This commit is contained in:
Felix Kratz 2022-08-19 14:42:10 +02:00
parent 3d2431c687
commit 0410214b27

View file

@ -149,9 +149,15 @@ void bar_calculate_bounds(struct bar* bar) {
bar, bar,
POSITION_CENTER); POSITION_CENTER);
uint32_t bar_left_first_item_x = g_bar_manager.background.padding_left; uint32_t bar_left_first_item_x = g_bar_manager.background.padding_left > 0
? g_bar_manager.background.padding_left
: 0;
uint32_t bar_right_first_item_x = bar->window.frame.size.width uint32_t bar_right_first_item_x = bar->window.frame.size.width
- g_bar_manager.background.padding_right; - (g_bar_manager.background.padding_right
> 0
? g_bar_manager.background.padding_right
: 0 );
uint32_t bar_center_first_item_x = (bar->window.frame.size.width uint32_t bar_center_first_item_x = (bar->window.frame.size.width
- 2*g_bar_manager.margin - 2*g_bar_manager.margin
@ -192,11 +198,15 @@ void bar_calculate_bounds(struct bar* bar) {
if (bar_item->position == POSITION_RIGHT if (bar_item->position == POSITION_RIGHT
|| bar_item->position == POSITION_CENTER_LEFT) { || bar_item->position == POSITION_CENTER_LEFT) {
*next_position -= bar_item_display_length
+ bar_item->background.padding_right; *next_position = min(*next_position - bar_item_display_length
- bar_item->background.padding_right,
bar->window.frame.size.width
- bar_item_display_length );
} }
else { else {
*next_position += bar_item->background.padding_left; *next_position += max((int)-*next_position,
bar_item->background.padding_left);
} }
bar_item->graph.rtl = rtl; bar_item->graph.rtl = rtl;