Skip to content

Commit

Permalink
#2394 fix issue causing sticky scratchpad windows to not work as expe…
Browse files Browse the repository at this point in the history
…cted
  • Loading branch information
koekeishiya committed Aug 17, 2024
1 parent 136f25f commit a4062be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]
### Changed
- Fix issue causing sticky scratchpad windows to not work as expected [#2394](https://github.com/koekeishiya/yabai/issues/2394)
- Fix window query scratchpad property flag [#2391](https://github.com/koekeishiya/yabai/issues/2391)
- When a new window is added to a stack it is placed after the currently focused window (instead of the end) [#2387](https://github.com/koekeishiya/yabai/issues/2387)

Expand Down
12 changes: 7 additions & 5 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2364,9 +2364,11 @@ bool window_manager_toggle_scratchpad_window(struct window_manager *wm, struct w
uint64_t sid = space_manager_active_space();
if (!sid) return false;

uint8_t visible = 0;
uint64_t wid_sid = window_space(window->id);
SLSWindowIsOrderedIn(g_connection, window->id, &visible);
// TODO(koekeishiya): Both functions use the same underlying API and could be combined in a single function to reduce redundant work.
bool visible_space = window_space(window->id) == sid || window_is_sticky(window->id);

uint8_t ordered_in = 0;
SLSWindowIsOrderedIn(g_connection, window->id, &ordered_in);

switch (forced_mode) {
case 0: goto mode_0;
Expand All @@ -2376,7 +2378,7 @@ bool window_manager_toggle_scratchpad_window(struct window_manager *wm, struct w
}

mode_0:;
if (sid == wid_sid && visible) {
if (visible_space && ordered_in) {
mode_1:;
struct window *next = window_manager_find_window_on_space_by_rank_filtering_window(wm, sid, 1, window->id);
if (next) {
Expand All @@ -2385,7 +2387,7 @@ mode_1:;
_SLPSSetFrontProcessWithOptions(&g_process_manager.finder_psn, 0, kCPSNoWindows);
}
scripting_addition_order_window(window->id, 0, 0);
} else if (sid == wid_sid && !visible) {
} else if (visible_space && !ordered_in) {
mode_2:;
scripting_addition_order_window(window->id, 1, 0);
window_manager_focus_window_with_raise(&window->application->psn, window->id, window->ref);
Expand Down

0 comments on commit a4062be

Please sign in to comment.