Skip to content

Commit

Permalink
574 fix inconsistencies when mixing sticky and float properties
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Jun 13, 2020
1 parent df189a0 commit ee4ea0d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 58 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Prevent *mouse_action move* from placing the y-coordinate of a window outside valid display boundaries [#570](https://github.com/koekeishiya/yabai/issues/570)
- Properly allow the user to float windows that are forced to tile using window rules (manage=on) [#571](https://github.com/koekeishiya/yabai/issues/571)
- Improve visual feedback effect of the *window --insert* message selection [#572](https://github.com/koekeishiya/yabai/issues/572)
- Fix inconsistencies when mixing floating and sticky properties on a window [#574](https://github.com/koekeishiya/yabai/issues/574)

## [3.1.2] - 2020-06-09
### Changed
Expand Down
4 changes: 2 additions & 2 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,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);
window_manager_make_window_topmost(&g_window_manager, window, false);
border_enter_fullscreen(window);

struct view *view = window_manager_find_managed_window(&g_window_manager, window);
Expand Down Expand Up @@ -475,7 +475,7 @@ static EVENT_CALLBACK(EVENT_HANDLER_WINDOW_RESIZED)
}

border_exit_fullscreen(window);
window_manager_make_floating(&g_window_manager, window, window->is_floating);
window_manager_make_window_topmost(&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;
Expand Down
4 changes: 2 additions & 2 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1614,11 +1614,11 @@ static void handle_domain_window(FILE *rsp, struct token domain, char *message)
} else if (token_equals(command, COMMAND_WINDOW_TOGGLE)) {
struct token value = get_token(&message);
if (token_equals(value, ARGUMENT_WINDOW_TOGGLE_FLOAT)) {
window_manager_toggle_window_float(&g_space_manager, &g_window_manager, acting_window);
window_manager_make_window_floating(&g_space_manager, &g_window_manager, acting_window, !acting_window->is_floating);
} else if (token_equals(value, ARGUMENT_WINDOW_TOGGLE_ON_TOP)) {
window_manager_toggle_window_topmost(acting_window);
} else if (token_equals(value, ARGUMENT_WINDOW_TOGGLE_STICKY)) {
window_manager_toggle_window_sticky(&g_space_manager, &g_window_manager, acting_window);
window_manager_make_window_sticky(&g_space_manager, &g_window_manager, acting_window, !acting_window->is_sticky);
} else if (token_equals(value, ARGUMENT_WINDOW_TOGGLE_SHADOW)) {
window_manager_toggle_window_shadow(&g_space_manager, &g_window_manager, acting_window);
} else if (token_equals(value, ARGUMENT_WINDOW_TOGGLE_SPLIT)) {
Expand Down
10 changes: 5 additions & 5 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,17 @@ uint64_t *window_space_list(struct window *window, int *count)

void window_serialize(FILE *rsp, struct window *window)
{
char *role = NULL;
char *subrole = NULL;
char *title = window_title(window);
char *escaped_title = string_escape(title);
CGRect frame = window_frame(window);
char *role = NULL;
char *subrole = NULL;
bool sticky = window_is_sticky(window);
uint64_t sid = window_space(window);
int space = space_manager_mission_control_index(sid);
int display = display_arrangement(space_display_id(sid));
bool is_topmost = window_is_topmost(window);
bool is_minimized = window_is_minimized(window);
bool visible = !is_minimized && (sticky || space_is_visible(sid));
bool visible = !is_minimized && (window->is_sticky || space_is_visible(sid));
bool border = window->border.id ? 1 : 0;
float opacity = window_opacity(window);

Expand Down Expand Up @@ -188,7 +187,7 @@ void window_serialize(FILE *rsp, struct window *window)
window->id == g_window_manager.focused_window_id,
split,
window->is_floating,
sticky,
window->is_sticky,
is_minimized,
is_topmost,
opacity,
Expand Down Expand Up @@ -437,6 +436,7 @@ struct window *window_create(struct application *application, AXUIElementRef win
SLSGetWindowOwner(g_connection, window->id, &window->connection);
window->is_minimized = window_is_minimized(window);
window->is_fullscreen = window_is_fullscreen(window) || space_is_fullscreen(window_space(window));
window->is_sticky = window_is_sticky(window);
window->id_ptr = malloc(sizeof(uint32_t *));
*window->id_ptr = &window->id;
window->has_shadow = true;
Expand Down
1 change: 1 addition & 0 deletions src/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct window
bool is_fullscreen;
bool is_minimized;
bool is_floating;
bool is_sticky;
float opacity;
bool rule_manage;
bool rule_fullscreen;
Expand Down
73 changes: 28 additions & 45 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,16 @@ void window_manager_apply_rule_to_window(struct space_manager *sm, struct window

if (rule->manage == RULE_PROP_ON) {
window->rule_manage = true;
window->is_floating = false;
window_manager_make_floating(wm, window, false);
if ((window_manager_should_manage_window(window)) && (!window_manager_find_managed_window(wm, window))) {
struct view *view = space_manager_tile_window_on_space(sm, window, space_manager_active_space());
window_manager_add_managed_window(wm, window, view);
}
window_manager_make_window_floating(sm, wm, window, false);
} else if (rule->manage == RULE_PROP_OFF) {
window->rule_manage = false;
struct view *view = window_manager_find_managed_window(wm, window);
if (view) {
space_manager_untile_window(sm, view, window);
window_manager_remove_managed_window(wm, window->id);
window_manager_purify_window(wm, window);
}
window_manager_make_floating(wm, window, true);
window->is_floating = true;
window_manager_make_window_floating(sm, wm, window, true);
}

if (rule->sticky == RULE_PROP_ON) {
window_manager_make_sticky(window->id, true);
window_manager_make_window_sticky(sm, wm, window, true);
} else if (rule->sticky == RULE_PROP_OFF) {
window_manager_make_sticky(window->id, false);
window_manager_make_window_sticky(sm, wm, window, false);
}

if (rule->layer) {
Expand Down Expand Up @@ -616,15 +604,15 @@ void window_manager_set_window_layer(struct window *window, int layer)
window_manager_set_layer_for_children(window->connection, window->id, sid, layer);
}

void window_manager_make_floating(struct window_manager *wm, struct window *window, bool floating)
void window_manager_make_window_topmost(struct window_manager *wm, struct window *window, bool topmost)
{
if (!wm->enable_window_topmost) return;

int layer = floating ? LAYER_ABOVE : LAYER_NORMAL;
int layer = topmost ? LAYER_ABOVE : LAYER_NORMAL;
window_manager_set_window_layer(window, layer);
}

void window_manager_make_sticky(uint32_t wid, bool sticky)
void window_manager_set_sticky(uint32_t wid, bool sticky)
{
int sockfd;
char message[MAXLEN];
Expand Down Expand Up @@ -1047,7 +1035,7 @@ struct window *window_manager_create_and_add_window(struct space_manager *sm, st

if (!window_observe(window)) {
debug("%s: could not observe %s %d\n", __FUNCTION__, window->application->name, window->id);
window_manager_make_floating(wm, window, true);
window_manager_make_window_topmost(wm, window, true);
window_manager_remove_lost_focused_event(wm, window->id);
window_unobserve(window);
window_destroy(window);
Expand All @@ -1072,7 +1060,7 @@ struct window *window_manager_create_and_add_window(struct space_manager *sm, st
(!window_can_move(window)) ||
(window_is_sticky(window)) ||
(!window_can_resize(window) && window_is_undersized(window))) {
window_manager_make_floating(wm, window, true);
window_manager_make_window_topmost(wm, window, true);
window->is_floating = true;
}
}
Expand Down Expand Up @@ -1362,43 +1350,38 @@ void window_manager_toggle_window_topmost(struct window *window)
window_manager_set_window_layer(window, is_topmost ? LAYER_NORMAL : LAYER_ABOVE);
}

void window_manager_toggle_window_float(struct space_manager *sm, struct window_manager *wm, struct window *window)
void window_manager_make_window_floating(struct space_manager *sm, struct window_manager *wm, struct window *window, bool should_float)
{
if (window->is_floating) {
window->is_floating = false;
window_manager_make_floating(wm, window, false);
if (window_manager_should_manage_window(window)) {
struct view *view = space_manager_tile_window_on_space(sm, window, space_manager_active_space());
window_manager_add_managed_window(wm, window, view);
}
} else {
if (should_float) {
struct view *view = window_manager_find_managed_window(wm, window);
if (view) {
space_manager_untile_window(sm, view, window);
window_manager_remove_managed_window(wm, window->id);
window_manager_purify_window(wm, window);
}
window_manager_make_floating(wm, window, true);
window_manager_make_window_topmost(wm, window, true);
window->is_floating = true;
} else {
window->is_sticky = false;
window->is_floating = false;
window_manager_set_sticky(window->id, false);
window_manager_make_window_topmost(wm, window, false);
if ((window_manager_should_manage_window(window)) && (!window_manager_find_managed_window(wm, window))) {
struct view *view = space_manager_tile_window_on_space(sm, window, space_manager_active_space());
window_manager_add_managed_window(wm, window, view);
}
}
}

void window_manager_toggle_window_sticky(struct space_manager *sm, struct window_manager *wm, struct window *window)
void window_manager_make_window_sticky(struct space_manager *sm, struct window_manager *wm, struct window *window, bool should_sticky)
{
if (window_is_sticky(window)) {
window_manager_make_sticky(window->id, false);
if (window_manager_should_manage_window(window)) {
struct view *view = space_manager_tile_window_on_space(sm, window, space_manager_active_space());
window_manager_add_managed_window(wm, window, view);
}
if (should_sticky) {
window_manager_make_window_floating(sm, wm, window, true);
window_manager_set_sticky(window->id, true);
window->is_sticky = true;
} else {
struct view *view = window_manager_find_managed_window(wm, window);
if (view) {
space_manager_untile_window(sm, view, window);
window_manager_remove_managed_window(wm, window->id);
window_manager_purify_window(wm, window);
}
window_manager_make_sticky(window->id, true);
window_manager_set_sticky(window->id, false);
window->is_sticky = false;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ struct window *window_manager_create_and_add_window(struct space_manager *sm, st
void window_manager_add_application_windows(struct space_manager *sm, struct window_manager *wm, struct application *application);
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);
void window_manager_purify_window(struct window_manager *wm, struct window *window);
void window_manager_make_floating(struct window_manager *wm, struct window *window, bool floating);
void window_manager_make_sticky(uint32_t wid, bool sticky);
void window_manager_make_window_floating(struct space_manager *sm, struct window_manager *wm, struct window *window, bool should_float);
void window_manager_make_window_sticky(struct space_manager *sm, struct window_manager *wm, struct window *window, bool sticky);
void window_manager_make_window_topmost(struct window_manager *wm, struct window *window, bool floating);
void window_manager_set_sticky(uint32_t wid, bool sticky);
void window_manager_set_layer(uint32_t wid, int layer);
void window_manager_set_window_layer(struct window *window, int layer);
void window_manager_toggle_window_topmost(struct window *window);
void window_manager_toggle_window_float(struct space_manager *sm, struct window_manager *wm, struct window *window);
void window_manager_toggle_window_sticky(struct space_manager *sm, struct window_manager *wm, struct window *window);
void window_manager_toggle_window_shadow(struct space_manager *sm, struct window_manager *wm, struct window *window);
void window_manager_toggle_window_parent(struct space_manager *sm, struct window_manager *wm, struct window *window);
void window_manager_toggle_window_fullscreen(struct space_manager *sm, struct window_manager *wm, struct window *window);
Expand Down

0 comments on commit ee4ea0d

Please sign in to comment.