From 852a44c084644aa559a0e7996cfa33e9c622c3b7 Mon Sep 17 00:00:00 2001 From: koekeishiya Date: Wed, 24 Aug 2022 15:48:07 +0200 Subject: [PATCH] #1370 fix window focus interaction when assigned to space through rule --- CHANGELOG.md | 1 + src/display_manager.c | 2 +- src/space_manager.c | 8 -------- src/window_manager.c | 8 +++++--- src/window_manager.h | 2 +- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4d90968..cf6f9ea6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/display_manager.c b/src/display_manager.c index 8ec2ca4f..39b6405f 100644 --- a/src/display_manager.c +++ b/src/display_manager.c @@ -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 { diff --git a/src/space_manager.c b/src/space_manager.c index ec0ba17e..cf8fea64 100644 --- a/src/space_manager.c +++ b/src/space_manager.c @@ -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; diff --git a/src/window_manager.c b/src/window_manager.c index 53449f8c..e860424d 100644 --- a/src/window_manager.c +++ b/src/window_manager.c @@ -578,7 +578,7 @@ 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); @@ -586,6 +586,8 @@ struct window *window_manager_find_window_on_space_by_rank(struct window_manager 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; @@ -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 { @@ -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 { diff --git a/src/window_manager.h b/src/window_manager.h index 0e098bf8..ffb0acec 100644 --- a/src/window_manager.h +++ b/src/window_manager.h @@ -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);