From c7c4abb4adf193e016bb1acc6af731a4758d6ebe Mon Sep 17 00:00:00 2001 From: koekeishiya Date: Thu, 11 Jun 2020 11:43:07 +0200 Subject: [PATCH] #567 properly cache focused window id upon detection at first space activation --- CHANGELOG.md | 1 + src/event.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4f19c29..d3fadc4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed - Re-construct application switched and window created events in the correct order when the window is moved through a rule upon creation [#564](https://github.com/koekeishiya/yabai/issues/564) - Improve interaction between *window_topmost* and windows that enter native-fullscreen mode [#566](https://github.com/koekeishiya/yabai/issues/566) +- Properly set focused window id cache upon window detection at first space activation [#567](https://github.com/koekeishiya/yabai/issues/567) ## [3.1.2] - 2020-06-09 ### Changed diff --git a/src/event.c b/src/event.c index 83b02054..5ff38ea6 100644 --- a/src/event.c +++ b/src/event.c @@ -505,6 +505,7 @@ static EVENT_CALLBACK(EVENT_HANDLER_WINDOW_RESIZED) window->is_fullscreen = is_fullscreen; if (!was_fullscreen && is_fullscreen) { + window_manager_make_floating(&g_window_manager, window, false); border_enter_fullscreen(window); struct view *view = window_manager_find_managed_window(&g_window_manager, window); if (view) { @@ -512,7 +513,6 @@ static EVENT_CALLBACK(EVENT_HANDLER_WINDOW_RESIZED) window_manager_remove_managed_window(&g_window_manager, window->id); window_manager_purify_window(&g_window_manager, window); } - window_manager_make_floating(&g_window_manager, window, false); } else if (was_fullscreen && !is_fullscreen) { uint32_t did = window_display_id(window); @@ -531,8 +531,8 @@ static EVENT_CALLBACK(EVENT_HANDLER_WINDOW_RESIZED) struct view *view = space_manager_tile_window_on_space(&g_space_manager, window, window_space(window)); window_manager_add_managed_window(&g_window_manager, window, view); } - window_manager_make_floating(&g_window_manager, window, window->is_floating); border_exit_fullscreen(window); + window_manager_make_floating(&g_window_manager, window, window->is_floating); } else if (was_fullscreen == is_fullscreen) { if (g_mouse_state.current_action == MOUSE_MODE_MOVE && g_mouse_state.window == window) { g_mouse_state.window_frame.size = window_ax_frame(g_mouse_state.window).size; @@ -637,10 +637,17 @@ static EVENT_CALLBACK(EVENT_HANDLER_SPACE_CHANGED) window_manager_set_window_opacity(&g_window_manager, focused_window, g_window_manager.active_window_opacity); border_activate(focused_window); - if (g_mouse_state.ffm_window_id != focused_window->id) { - window_manager_center_mouse(&g_window_manager, focused_window); + if (g_window_manager.focused_window_id != focused_window->id) { + if (g_mouse_state.ffm_window_id != focused_window->id) { + window_manager_center_mouse(&g_window_manager, focused_window); + } + + g_window_manager.last_window_id = g_window_manager.focused_window_id; } + g_window_manager.focused_window_id = focused_window->id; + g_window_manager.focused_window_psn = focused_window->application->psn; + g_mouse_state.ffm_window_id = 0; window_manager_remove_lost_focused_event(&g_window_manager, focused_window->id); } @@ -679,10 +686,17 @@ static EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_CHANGED) window_manager_set_window_opacity(&g_window_manager, focused_window, g_window_manager.active_window_opacity); border_activate(focused_window); - if (g_mouse_state.ffm_window_id != focused_window->id) { - window_manager_center_mouse(&g_window_manager, focused_window); + if (g_window_manager.focused_window_id != focused_window->id) { + if (g_mouse_state.ffm_window_id != focused_window->id) { + window_manager_center_mouse(&g_window_manager, focused_window); + } + + g_window_manager.last_window_id = g_window_manager.focused_window_id; } + g_window_manager.focused_window_id = focused_window->id; + g_window_manager.focused_window_psn = focused_window->application->psn; + g_mouse_state.ffm_window_id = 0; window_manager_remove_lost_focused_event(&g_window_manager, focused_window->id); }