From 82afc44337e55ecc8463d809c1a3af94ceb66763 Mon Sep 17 00:00:00 2001 From: koekeishiya Date: Sat, 9 May 2020 20:13:35 +0200 Subject: [PATCH] #505 fix focus issue when sending the last window of one display to another display --- CHANGELOG.md | 1 + src/window_manager.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f982bb6..191c0e92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Update scripting addition for macOS 10.15.5 Beta (19F72f) [#501](https://github.com/koekeishiya/yabai/issues/501) - Allow calling `space --label` without an argument to intentionally remove a previously assigned label [#514](https://github.com/koekeishiya/yabai/issues/514) - Fixed an issue where a window moved across displays using *mouse action move* would be invisible [#506](https://github.com/koekeishiya/yabai/issues/506) +- Fixed an issue where the last window on a display would not properly update the focused window of the original display upon move, causing selectors to not work as expected [#505](https://github.com/koekeishiya/yabai/issues/505) ## [3.0.0] - 2020-05-01 ### Removed diff --git a/src/window_manager.c b/src/window_manager.c index eb1f59b9..6cd88d33 100644 --- a/src/window_manager.c +++ b/src/window_manager.c @@ -1101,10 +1101,9 @@ enum window_op_error window_manager_warp_window(struct space_manager *sm, struct if (a_view->sid != b_view->sid) { window_manager_remove_managed_window(wm, a->id); window_manager_add_managed_window(wm, a, b_view); - space_manager_move_window_to_space(b_view->sid, a); if (wm->focused_window_id == a->id) { - struct window *next = window_manager_find_window_on_space_by_rank(wm, a_view->sid, 1); + struct window *next = window_manager_find_window_on_space_by_rank(wm, a_view->sid, 2); if (next) { window_manager_focus_window_with_raise(&next->application->psn, next->id, next->ref); } else { @@ -1115,6 +1114,8 @@ enum window_op_error window_manager_warp_window(struct space_manager *sm, struct _SLPSSetFrontProcessWithOptions(&g_process_manager.finder_psn, 0, kCPSNoWindows); } } + + space_manager_move_window_to_space(b_view->sid, a); } space_manager_tile_window_on_space_with_insertion_point(sm, a, b_view->sid, b->id); @@ -1214,15 +1215,8 @@ void window_manager_send_window_to_space(struct space_manager *sm, struct window window_manager_purify_window(wm, window); } - space_manager_move_window_to_space(dst_sid, window); - - if (window_manager_should_manage_window(window) && !window->is_minimized) { - struct view *view = space_manager_tile_window_on_space(sm, window, dst_sid); - window_manager_add_managed_window(wm, window, view); - } - 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, 1); + struct window *next = window_manager_find_window_on_space_by_rank(wm, src_sid, 2); if (next) { window_manager_focus_window_with_raise(&next->application->psn, next->id, next->ref); } else { @@ -1233,6 +1227,13 @@ void window_manager_send_window_to_space(struct space_manager *sm, struct window _SLPSSetFrontProcessWithOptions(&g_process_manager.finder_psn, 0, kCPSNoWindows); } } + + space_manager_move_window_to_space(dst_sid, window); + + if (window_manager_should_manage_window(window) && !window->is_minimized) { + struct view *view = space_manager_tile_window_on_space(sm, window, dst_sid); + window_manager_add_managed_window(wm, window, view); + } } enum window_op_error window_manager_apply_grid(struct space_manager *sm, struct window_manager *wm, struct window *window, unsigned r, unsigned c, unsigned x, unsigned y, unsigned w, unsigned h)