Skip to content

Commit

Permalink
#1311 properly set window order when adding to the top of a stack
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Sep 22, 2022
1 parent 107744b commit a4d3374
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Make window zoom more flexible, allow parent-zoomed window to enter fullscreen and vice versa [#1429](https://github.com/koekeishiya/yabai/issues/1429)
- Fix border size issue when moving a window to a different display on macOS Big Sur [#1229](https://github.com/koekeishiya/yabai/issues/1229)
- Check Dock.app isFinishedLaunching property before attempting to inject scripting addition [#749](https://github.com/koekeishiya/yabai/issues/749)
- Properly update window ordering when a window is added to the top of a stack [#1311](https://github.com/koekeishiya/yabai/issues/1311)

### Removed
- Removed support for macOS High Sierra, Mojave, and Catalina.
Expand Down
2 changes: 1 addition & 1 deletion src/osax/common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SA_COMMON_H
#define SA_COMMON_H

#define OSAX_VERSION "2.0.11"
#define OSAX_VERSION "2.0.12"

#define OSAX_ATTRIB_DOCK_SPACES 0x01
#define OSAX_ATTRIB_DPPM 0x02
Expand Down
19 changes: 19 additions & 0 deletions src/osax/payload.m
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,22 @@ static void do_window_swap_proxy(char *message)
CFRelease(transaction);
}

static void do_window_order(char *message)
{
uint32_t a_wid;
unpack(message, a_wid);
if (!a_wid) return;

int order;
unpack(message, order);

uint32_t b_wid;
unpack(message, b_wid);
if (!b_wid) return;

CGSOrderWindow(_connection, a_wid, order, b_wid);
}

static void do_handshake(int sockfd)
{
uint32_t attrib = 0;
Expand Down Expand Up @@ -875,6 +891,9 @@ static void handle_message(int sockfd, char *message)
case 0x0E: {
do_window_swap_proxy(message);
} break;
case 0x0F: {
do_window_order(message);
} break;

}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sa.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bool scripting_addition_set_sticky(uint32_t wid, bool sticky);
bool scripting_addition_set_shadow(uint32_t wid, bool shadow);
bool scripting_addition_focus_window(uint32_t wid);
bool scripting_addition_scale_window(uint32_t wid, float x, float y, float w, float h);
bool scripting_addition_swap_window_order(uint32_t a_wid, uint32_t b_wid);
bool scripting_addition_swap_window_proxy(uint32_t a_wid, uint32_t b_wid, float opacity, int order);
bool scripting_addition_order_window(uint32_t a_wid, int order, uint32_t b_wid);

#endif
14 changes: 14 additions & 0 deletions src/sa.m
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,17 @@ bool scripting_addition_swap_window_proxy(uint32_t a_wid, uint32_t b_wid, float

return scripting_addition_send_bytes(bytes, length);
}

bool scripting_addition_order_window(uint32_t a_wid, int order, uint32_t b_wid)
{
char bytes[0x100];

char length = 2;
pack(bytes, a_wid, length);
pack(bytes, order, length);
pack(bytes, b_wid, length);
bytes[1] = 0x0F;
bytes[0] = length-1;

return scripting_addition_send_bytes(bytes, length);
}
5 changes: 3 additions & 2 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,9 @@ struct window_node *view_remove_window_node(struct view *view, struct window *wi

void view_stack_window_node(struct view *view, struct window_node *node, struct window *window)
{
node->window_list[node->window_count] = window->id;
node->window_order[node->window_count] = window->id;
node->window_list[node->window_count] = window->id;
memmove(node->window_order + 1, node->window_order, sizeof(uint32_t) * node->window_count);
node->window_order[0] = window->id;
++node->window_count;
}

Expand Down
1 change: 1 addition & 0 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,7 @@ enum window_op_error window_manager_stack_window(struct space_manager *sm, struc

view_stack_window_node(a_view, a_node, b);
window_manager_add_managed_window(wm, b, a_view);
scripting_addition_order_window(b->id, 1, a_node->window_order[1]);

if (a_node->zoom) {
window_manager_animate_window((struct window_capture) { b, a_node->zoom->area.x, a_node->zoom->area.y, a_node->zoom->area.w, a_node->zoom->area.h });
Expand Down

0 comments on commit a4d3374

Please sign in to comment.