Skip to content

Commit

Permalink
#2387 newly stacked windows are placed after the focused window
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Aug 12, 2024
1 parent 3a1ab2f commit 817f6bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- When a new window is added to a stack it is placed after the currently focused window (instead of the end) [#2387](https://github.com/koekeishiya/yabai/issues/2387)

## [7.1.2] - 2024-08-10
### Changed
Expand Down
15 changes: 14 additions & 1 deletion src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,20 @@ struct window_node *view_remove_window_node(struct view *view, struct window *wi

void view_stack_window_node(struct window_node *node, struct window *window)
{
node->window_list[node->window_count] = window->id;
int insert_index = node->window_count;

for (int i = 0; i < node->window_count; ++i) {
if (node->window_list[i] == node->window_order[0]) {
insert_index = i+1;
break;
}
}

if (insert_index < node->window_count) {
memmove(node->window_list + insert_index + 1, node->window_list + insert_index, sizeof(uint32_t) * (node->window_count - insert_index));
}

node->window_list[insert_index] = window->id;
memmove(node->window_order + 1, node->window_order, sizeof(uint32_t) * node->window_count);
node->window_order[0] = window->id;
++node->window_count;
Expand Down

1 comment on commit 817f6bd

@jbriales
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks so much!

Please sign in to comment.