mirror of
https://github.com/FelixKratz/SketchyBar
synced 2025-01-30 04:23:26 +00:00
stabilize against uint32_t underflow
This commit is contained in:
parent
3d2431c687
commit
0410214b27
1 changed files with 15 additions and 5 deletions
20
src/bar.c
20
src/bar.c
|
@ -149,9 +149,15 @@ void bar_calculate_bounds(struct bar* bar) {
|
|||
bar,
|
||||
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
|
||||
- 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
|
||||
- 2*g_bar_manager.margin
|
||||
|
@ -192,11 +198,15 @@ void bar_calculate_bounds(struct bar* bar) {
|
|||
|
||||
if (bar_item->position == POSITION_RIGHT
|
||||
|| 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 {
|
||||
*next_position += bar_item->background.padding_left;
|
||||
*next_position += max((int)-*next_position,
|
||||
bar_item->background.padding_left);
|
||||
}
|
||||
|
||||
bar_item->graph.rtl = rtl;
|
||||
|
|
Loading…
Reference in a new issue