Skip to content

Commit

Permalink
#1370 fix window focus interaction when assigned to space through rule
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Aug 24, 2022
1 parent 1e00a59 commit 852a44c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [Unreleased]
### Changed
- Fixed an issue that in rare occasions caused yabai to freeze when focusing an inactve space on an inactive display [#1309](https://github.com/koekeishiya/yabai/issues/1309).
- Fixed an issue that caused a window to incorrectly become focused when assigned to a space through rules [#1370](https://github.com/koekeishiya/yabai/issues/1370)

## [4.0.1] - 2022-05-17
### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/display_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ out:;

void display_manager_focus_display(uint32_t did, uint64_t sid)
{
struct window *window = window_manager_find_window_on_space_by_rank(&g_window_manager, sid, 1);
struct window *window = window_manager_find_window_on_space_by_rank_filtering_window(&g_window_manager, sid, 1, 0);
if (window) {
window_manager_focus_window_with_raise(&window->application->psn, window->id, window->ref);
} else {
Expand Down
8 changes: 0 additions & 8 deletions src/space_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ void space_manager_mark_view_invalid(struct space_manager *sm, uint64_t sid)
view->is_valid = false;
}

void space_manager_mark_view_dirty(struct space_manager *sm, uint64_t sid)
{
struct view *view = space_manager_find_view(sm, sid);
if (view->layout == VIEW_FLOAT) return;

view->is_dirty = true;
}

void space_manager_untile_window(struct space_manager *sm, struct view *view, struct window *window)
{
if (view->layout == VIEW_FLOAT) return;
Expand Down
8 changes: 5 additions & 3 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,14 +578,16 @@ int window_manager_find_rank_of_window_in_list(uint32_t wid, uint32_t *window_li
return INT_MAX;
}

struct window *window_manager_find_window_on_space_by_rank(struct window_manager *wm, uint64_t sid, int rank)
struct window *window_manager_find_window_on_space_by_rank_filtering_window(struct window_manager *wm, uint64_t sid, int rank, uint32_t filter_wid)
{
int count;
uint32_t *window_list = space_window_list(sid, &count, false);
if (!window_list) return NULL;

struct window *result = NULL;
for (int i = 0, j = 0; i < count; ++i) {
if (window_list[i] == filter_wid) continue;

struct window *window = window_manager_find_window(wm, window_list[i]);
if (!window) continue;

Expand Down Expand Up @@ -1219,7 +1221,7 @@ enum window_op_error window_manager_warp_window(struct space_manager *sm, struct
window_manager_add_managed_window(wm, a, b_view);

if (wm->focused_window_id == a->id) {
struct window *next = window_manager_find_window_on_space_by_rank(wm, a_view->sid, 2);
struct window *next = window_manager_find_window_on_space_by_rank_filtering_window(wm, a_view->sid, 2, 0);
if (next) {
window_manager_focus_window_with_raise(&next->application->psn, next->id, next->ref);
} else {
Expand Down Expand Up @@ -1334,7 +1336,7 @@ void window_manager_send_window_to_space(struct space_manager *sm, struct window
}

if ((space_is_visible(src_sid) && (moved_by_rule || wm->focused_window_id == window->id))) {
struct window *next = window_manager_find_window_on_space_by_rank(wm, src_sid, 2);
struct window *next = window_manager_find_window_on_space_by_rank_filtering_window(wm, src_sid, 1, window->id);
if (next) {
window_manager_focus_window_with_raise(&next->application->psn, next->id, next->ref);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void window_manager_resize_window(struct window *window, float width, float heig
enum window_op_error window_manager_adjust_window_ratio(struct window_manager *wm, struct window *window, int action, float ratio);
void window_manager_set_window_frame(struct window *window, float x, float y, float width, float height);
int window_manager_find_rank_of_window_in_list(uint32_t wid, uint32_t *window_list, int window_count);
struct window *window_manager_find_window_on_space_by_rank(struct window_manager *wm, uint64_t sid, int rank);
struct window *window_manager_find_window_on_space_by_rank_filtering_window(struct window_manager *wm, uint64_t sid, int rank, uint32_t filter_wid);
struct window *window_manager_find_window_at_point_filtering_window(struct window_manager *wm, CGPoint point, uint32_t filter_wid);
struct window *window_manager_find_window_at_point(struct window_manager *wm, CGPoint point);
struct window *window_manager_find_window_below_cursor(struct window_manager *wm);
Expand Down

0 comments on commit 852a44c

Please sign in to comment.