Skip to content

Commit

Permalink
#141 fix space padding and gap underflow when modified with a relativ…
Browse files Browse the repository at this point in the history
…e value
  • Loading branch information
koekeishiya committed Jul 28, 2019
1 parent 13dc822 commit 8873ca7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Work around macOS craziness so that we can properly tile a window after it leaves native fullscreen mode [#36](https://github.com/koekeishiya/yabai/issues/36)
- Return an error for queries with invalid, named selectors [#158](https://github.com/koekeishiya/yabai/issues/158)
- Resolve a potential multi-threaded issue due to "undefined behaviour" regarding x86 instruction ordering [#153](https://github.com/koekeishiya/yabai/issues/153)
- Fix space padding and gap underflow when modified with a relative value [#141](https://github.com/koekeishiya/yabai/issues/141)

## [1.1.2] - 2019-07-15
### Changed
Expand Down
1 change: 1 addition & 0 deletions src/misc/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define array_count(a) (sizeof((a)) / sizeof(*(a)))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define add_and_clamp_to_zero(a, b) (((a) + (b) <= 0) ? 0 : (a) + (b))

#define MAXLEN 512

Expand Down
10 changes: 5 additions & 5 deletions src/space_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void space_manager_set_gap_for_space(struct space_manager *sm, uint64_t sid, int
if (type == TYPE_ABS) {
view->window_gap = gap;
} else if (type == TYPE_REL) {
view->window_gap += gap;
view->window_gap = add_and_clamp_to_zero(view->window_gap, gap);
}

view_update(view);
Expand Down Expand Up @@ -272,10 +272,10 @@ void space_manager_set_padding_for_space(struct space_manager *sm, uint64_t sid,
view->left_padding = left;
view->right_padding = right;
} else if (type == TYPE_REL) {
view->top_padding += top;
view->bottom_padding += bottom;
view->left_padding += left;
view->right_padding += right;
view->top_padding = add_and_clamp_to_zero(view->top_padding, top);
view->bottom_padding = add_and_clamp_to_zero(view->bottom_padding, bottom);
view->left_padding = add_and_clamp_to_zero(view->left_padding, left);
view->right_padding = add_and_clamp_to_zero(view->right_padding, right);
}

view_update(view);
Expand Down
10 changes: 5 additions & 5 deletions src/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ struct view
struct window_node *root;
enum view_type layout;
uint32_t insertion_point;
uint32_t top_padding;
uint32_t bottom_padding;
uint32_t left_padding;
uint32_t right_padding;
uint32_t window_gap;
int top_padding;
int bottom_padding;
int left_padding;
int right_padding;
int window_gap;
bool custom_layout;
bool custom_top_padding;
bool custom_bottom_padding;
Expand Down

0 comments on commit 8873ca7

Please sign in to comment.