Skip to content

Commit

Permalink
#183 fix issue that could cause windows to tile with overlapped region
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Aug 1, 2019
1 parent e54e5e3 commit 6c846d4
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Exiting mission-control will invalidate the region assigned to Spaces/Views as because a Space may have been dragged to a different monitor [#](https://github.com/koekeishiya/yabai/issues/118)
- Application_Launched signal incorrectly fired multiple times due to accessibility retries [#175](https://github.com/koekeishiya/yabai/issues/175)
- Global space settings should properly apply again [#176](https://github.com/koekeishiya/yabai/issues/176)
- Fixed an issue that could cause windows to be overlapped when tiled [#183](https://github.com/koekeishiya/yabai/issues/183)

## [1.1.2] - 2019-07-15
### Changed
Expand Down
4 changes: 2 additions & 2 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,8 @@ static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_UP)
if (!window) window = window_manager_find_window_at_point(&g_window_manager, point);
if (window == g_mouse_state.window) window = NULL;

struct window_node *a_node = view_find_window_node(src_view->root, g_mouse_state.window->id);
struct window_node *b_node = window ? view_find_window_node(dst_view->root, window->id) : NULL;
struct window_node *a_node = view_find_window_node(src_view, g_mouse_state.window->id);
struct window_node *b_node = window ? view_find_window_node(dst_view, window->id) : NULL;

if (src_view->sid == dst_view->sid) {
if (a_node && b_node) {
Expand Down
2 changes: 1 addition & 1 deletion src/space_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void space_manager_toggle_window_split(struct space_manager *sm, struct window *
struct view *view = space_manager_find_view(sm, space_manager_active_space());
if (view->layout != VIEW_BSP) return;

struct window_node *node = view_find_window_node(view->root, window->id);
struct window_node *node = view_find_window_node(view, window->id);
if (node && window_node_is_intermediate(node)) {
node->parent->split = node->parent->split == SPLIT_Y ? SPLIT_X : SPLIT_Y;

Expand Down
35 changes: 12 additions & 23 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,24 +325,20 @@ struct window_node *view_find_min_depth_leaf_node(struct window_node *node)
return NULL;
}

struct window_node *view_find_window_node(struct window_node *node, uint32_t window_id)
struct window_node *view_find_window_node(struct view *view, uint32_t window_id)
{
if (node->window_id == window_id) return node;

if (!window_node_is_leaf(node)) {
struct window_node *left = view_find_window_node(node->left, window_id);
if (left) return left;

struct window_node *right = view_find_window_node(node->right, window_id);
if (right) return right;
struct window_node *node = window_node_find_first_leaf(view->root);
while (node) {
if (node->window_id == window_id) return node;
node = window_node_find_next_leaf(node);
}

return NULL;
}

void view_remove_window_node(struct view *view, struct window *window)
{
struct window_node *node = view_find_window_node(view->root, window->id);
struct window_node *node = view_find_window_node(view, window->id);
if (!node) return;

if (node == view->root) {
Expand Down Expand Up @@ -387,12 +383,13 @@ void view_add_window_node(struct view *view, struct window *window)
struct window_node *leaf = NULL;

if (view->insertion_point) {
leaf = view_find_window_node(view->root, view->insertion_point);
leaf = view_find_window_node(view, view->insertion_point);
view->insertion_point = 0;
}

if (!leaf) leaf = view_find_window_node(view->root, g_window_manager.focused_window_id);
if (!leaf) leaf = view_find_window_node(view, g_window_manager.focused_window_id);
if (!leaf) leaf = view_find_min_depth_leaf_node(view->root);

struct window *leaf_window = window_manager_find_window(&g_window_manager, leaf->window_id);
window_node_split(view, leaf, window);

Expand Down Expand Up @@ -548,16 +545,8 @@ struct view *view_create(uint64_t sid)
void view_clear(struct view *view)
{
if (view->root) {
if (view->root->left) {
window_node_destroy(view->root->left);
view->root->left = NULL;
}

if (view->root->right) {
window_node_destroy(view->root->right);
view->root->right = NULL;
}

view->root->window_id = 0;
if (view->root->left) window_node_destroy(view->root->left);
if (view->root->right) window_node_destroy(view->root->right);
memset(view->root, 0, sizeof(struct window_node));
}
}
2 changes: 1 addition & 1 deletion src/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct window_node *window_node_find_last_leaf(struct window_node *root);
struct window_node *window_node_find_prev_leaf(struct window_node *node);
struct window_node *window_node_find_next_leaf(struct window_node *node);

struct window_node *view_find_window_node(struct window_node *node, uint32_t window_id);
struct window_node *view_find_window_node(struct view *view, uint32_t window_id);
void view_remove_window_node(struct view *view, struct window *window);
void view_add_window_node(struct view *view, struct window *window);
uint32_t *view_find_window_list(struct view *view);
Expand Down
2 changes: 1 addition & 1 deletion src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void window_serialize(FILE *rsp, struct window *window)
}

struct view *view = window_manager_find_managed_window(&g_window_manager, window);
struct window_node *node = view ? view_find_window_node(view->root, window->id) : NULL;
struct window_node *node = view ? view_find_window_node(view, window->id) : NULL;

char split[MAXLEN];
snprintf(split, sizeof(split), "%s", window_node_split_str[node && node->parent ? node->parent->split : 0]);
Expand Down
26 changes: 13 additions & 13 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void window_manager_resize_window_relative(struct window_manager *wm, struct win
struct window_node *x_fence = NULL;
struct window_node *y_fence = NULL;

struct window_node *node = view_find_window_node(view->root, window->id);
struct window_node *node = view_find_window_node(view, window->id);
if (!node) return;

if (direction & HANDLE_TOP) x_fence = window_node_fence(node, DIR_NORTH);
Expand Down Expand Up @@ -613,7 +613,7 @@ struct window *window_manager_find_prev_managed_window(struct space_manager *sm,
struct view *view = space_manager_find_view(sm, space_manager_active_space());
if (!view) return NULL;

struct window_node *node = view_find_window_node(view->root, window->id);
struct window_node *node = view_find_window_node(view, window->id);
if (!node) return NULL;

struct window_node *prev = window_node_find_prev_leaf(node);
Expand All @@ -627,7 +627,7 @@ struct window *window_manager_find_next_managed_window(struct space_manager *sm,
struct view *view = space_manager_find_view(sm, space_manager_active_space());
if (!view) return NULL;

struct window_node *node = view_find_window_node(view->root, window->id);
struct window_node *node = view_find_window_node(view, window->id);
if (!node) return NULL;

struct window_node *prev = window_node_find_next_leaf(node);
Expand Down Expand Up @@ -663,7 +663,7 @@ struct window *window_manager_find_recent_managed_window(struct space_manager *s
struct view *view = space_manager_find_view(sm, space_manager_active_space());
if (!view) return NULL;

struct window_node *node = view_find_window_node(view->root, wm->last_window_id);
struct window_node *node = view_find_window_node(view, wm->last_window_id);
if (!node) return NULL;

return window_manager_find_window(wm, node->window_id);
Expand Down Expand Up @@ -987,11 +987,11 @@ void window_manager_set_window_insertion(struct space_manager *sm, struct window
struct view *view = space_manager_find_view(sm, sid);
if (view->layout != VIEW_BSP) return;

struct window_node *node = view_find_window_node(view->root, window->id);
struct window_node *node = view_find_window_node(view, window->id);
if (!node) return;

if (view->insertion_point && view->insertion_point != window->id) {
struct window_node *insert_node = view_find_window_node(view->root, view->insertion_point);
struct window_node *insert_node = view_find_window_node(view, view->insertion_point);
if (insert_node) {
insert_node->split = SPLIT_NONE;
insert_node->child = CHILD_NONE;
Expand Down Expand Up @@ -1050,10 +1050,10 @@ void window_manager_warp_window(struct space_manager *sm, struct window_manager
struct view *b_view = space_manager_find_view(sm, b_sid);
if (b_view->layout != VIEW_BSP) return;

struct window_node *a_node = view_find_window_node(a_view->root, a->id);
struct window_node *a_node = view_find_window_node(a_view, a->id);
if (!a_node) return;

struct window_node *b_node = view_find_window_node(b_view->root, b->id);
struct window_node *b_node = view_find_window_node(b_view, b->id);
if (!b_node) return;

if (a_node->parent == b_node->parent) {
Expand Down Expand Up @@ -1110,10 +1110,10 @@ void window_manager_swap_window(struct space_manager *sm, struct window_manager
struct view *b_view = space_manager_find_view(sm, b_sid);
if (b_view->layout != VIEW_BSP) return;

struct window_node *a_node = view_find_window_node(a_view->root, a->id);
struct window_node *a_node = view_find_window_node(a_view, a->id);
if (!a_node) return;

struct window_node *b_node = view_find_window_node(b_view->root, b->id);
struct window_node *b_node = view_find_window_node(b_view, b->id);
if (!b_node) return;

a_node->window_id = b->id;
Expand Down Expand Up @@ -1328,7 +1328,7 @@ void window_manager_toggle_window_parent(struct space_manager *sm, struct window
struct view *view = window_manager_find_managed_window(wm, window);
if (!view || view->layout != VIEW_BSP) return;

struct window_node *node = view_find_window_node(view->root, window->id);
struct window_node *node = view_find_window_node(view, window->id);
if (node->zoom) {
float offset = window_node_border_window_offset(window);
window_manager_move_window(window, node->area.x + offset, node->area.y + offset);
Expand All @@ -1347,7 +1347,7 @@ void window_manager_toggle_window_fullscreen(struct space_manager *sm, struct wi
struct view *view = window_manager_find_managed_window(wm, window);
if (!view || view->layout != VIEW_BSP) return;

struct window_node *node = view_find_window_node(view->root, window->id);
struct window_node *node = view_find_window_node(view, window->id);
if (node->zoom) {
float offset = window_node_border_window_offset(window);
window_manager_move_window(window, node->area.x + offset, node->area.y + offset);
Expand All @@ -1364,7 +1364,7 @@ void window_manager_toggle_window_fullscreen(struct space_manager *sm, struct wi
void window_manager_toggle_window_border(struct window_manager *wm, struct window *window)
{
struct view *view = window_manager_find_managed_window(wm, window);
struct window_node *node = view ? view_find_window_node(view->root, window->id) : NULL;
struct window_node *node = view ? view_find_window_node(view, window->id) : NULL;

if (window->border.enabled) {
border_window_hide(window);
Expand Down

0 comments on commit 6c846d4

Please sign in to comment.