Skip to content

Commit

Permalink
#813 properly manage windows that are moved to the first space when a…
Browse files Browse the repository at this point in the history
… space with active windows is destroyed
  • Loading branch information
koekeishiya committed Aug 24, 2021
1 parent 6dad258 commit 51a6b74
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- New config *window_origin_display* to specify which display a window should become managed at upon creation [#951](https://github.com/koekeishiya/yabai/issues/951)

### Changed
- Detect and manage windows that are moved into the first space of a display when a space with active windows on it is destroyed [#813](https://github.com/koekeishiya/yabai/issues/813)
- The command *space --balance* now takes an optional axis as its argument [#985](https://github.com/koekeishiya/yabai/issues/985)
- Malformed windows that are managed through rules should be eligible for window alpha, focus follows mouse, and window borders [#788](https://github.com/koekeishiya/yabai/issues/788)
- Improve behaviour of *focus_follows_mouse autoraise*, preventing a window from being raised if it would occlude some other window. autoraise is temporarily disabled while a menu is opened. [#407](https://github.com/koekeishiya/yabai/issues/407)
Expand Down
31 changes: 29 additions & 2 deletions src/space_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,23 @@ enum space_op_error space_manager_focus_space(uint64_t sid)
return SPACE_OP_ERROR_SUCCESS;
}

static inline uint64_t space_manager_find_first_user_space(uint32_t did)
{
int count;
uint64_t *space_list = display_space_list(did, &count);
if (!space_list) return 0;

for (int i = 0; i < count; ++i) {
uint64_t sid = space_list[i];

if (space_is_user(sid)) {
return sid;
}
}

return 0;
}

static inline bool space_manager_is_space_last_user_space(uint64_t sid)
{
bool result = true;
Expand Down Expand Up @@ -790,10 +807,20 @@ enum space_op_error space_manager_destroy_space(uint64_t sid)
if (!space_is_user(sid)) return SPACE_OP_ERROR_INVALID_TYPE;
if (space_manager_is_space_last_user_space(sid)) return SPACE_OP_ERROR_INVALID_SRC;

bool is_animating = display_manager_display_is_animating(space_display_id(sid));
uint32_t did = space_display_id(sid);
uint64_t first_sid = space_manager_find_first_user_space(did);

bool is_animating = display_manager_display_is_animating(did);
if (is_animating) return SPACE_OP_ERROR_DISPLAY_IS_ANIMATING;

return scripting_addition_destroy_space(sid) ? SPACE_OP_ERROR_SUCCESS : SPACE_OP_ERROR_SCRIPTING_ADDITION;
bool success = scripting_addition_destroy_space(sid);
if (!success) return SPACE_OP_ERROR_SCRIPTING_ADDITION;

if (first_sid) {
window_manager_validate_and_check_for_windows_on_space(&g_space_manager, &g_window_manager, first_sid);
}

return SPACE_OP_ERROR_SUCCESS;
}

enum space_op_error space_manager_add_space(uint64_t sid)
Expand Down

0 comments on commit 51a6b74

Please sign in to comment.