Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Jun 11, 2020
1 parent b74fe2a commit f16f07b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
9 changes: 3 additions & 6 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,7 @@ static EVENT_CALLBACK(EVENT_HANDLER_SPACE_CHANGED)
if (view_is_invalid(view)) view_update(view);
if (view_is_dirty(view)) view_flush(view);

window_manager_validate_windows_on_space(&g_space_manager, &g_window_manager, g_space_manager.current_space_id);
window_manager_check_for_windows_on_space(&g_space_manager, &g_window_manager, g_space_manager.current_space_id);
window_manager_validate_and_check_for_windows_on_space(&g_space_manager, &g_window_manager, g_space_manager.current_space_id);
}

return EVENT_SUCCESS;
Expand Down Expand Up @@ -693,8 +692,7 @@ static EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_CHANGED)
if (view_is_invalid(view)) view_update(view);
if (view_is_dirty(view)) view_flush(view);

window_manager_validate_windows_on_space(&g_space_manager, &g_window_manager, g_space_manager.current_space_id);
window_manager_check_for_windows_on_space(&g_space_manager, &g_window_manager, g_space_manager.current_space_id);
window_manager_validate_and_check_for_windows_on_space(&g_space_manager, &g_window_manager, g_space_manager.current_space_id);
}

return EVENT_SUCCESS;
Expand Down Expand Up @@ -1144,8 +1142,7 @@ static EVENT_CALLBACK(EVENT_HANDLER_MISSION_CONTROL_EXIT)
space_manager_mark_spaces_invalid(&g_space_manager);

if (space_is_user(g_space_manager.current_space_id)) {
window_manager_validate_windows_on_space(&g_space_manager, &g_window_manager, g_space_manager.current_space_id);
window_manager_check_for_windows_on_space(&g_space_manager, &g_window_manager, g_space_manager.current_space_id);
window_manager_validate_and_check_for_windows_on_space(&g_space_manager, &g_window_manager, g_space_manager.current_space_id);
}

return EVENT_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
if (space_is_user(sel_sid)) {
view->layout = VIEW_BSP;
view->custom_layout = true;
window_manager_check_for_windows_on_space(&g_space_manager, &g_window_manager, sel_sid);
window_manager_validate_and_check_for_windows_on_space(&g_space_manager, &g_window_manager, sel_sid);
} else {
daemon_fail(rsp, "cannot set layout for a macOS fullscreen space!\n");
}
Expand Down
4 changes: 2 additions & 2 deletions src/space_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void space_manager_set_layout_for_space(struct space_manager *sm, uint64_t sid,
view->layout = layout;

if (view->layout == VIEW_BSP) {
window_manager_check_for_windows_on_space(sm, &g_window_manager, sid);
window_manager_validate_and_check_for_windows_on_space(sm, &g_window_manager, sid);
} else if (view->layout == VIEW_FLOAT) {
view_clear(view);
}
Expand Down Expand Up @@ -274,7 +274,7 @@ void space_manager_set_layout_for_all_spaces(struct space_manager *sm, enum view
if (space_is_user(view->sid)) {
view->layout = layout;
if (view->layout == VIEW_BSP) {
window_manager_check_for_windows_on_space(sm, &g_window_manager, view->sid);
window_manager_validate_and_check_for_windows_on_space(sm, &g_window_manager, view->sid);
} else if (view->layout == VIEW_FLOAT) {
view_clear(view);
}
Expand Down
29 changes: 17 additions & 12 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1470,12 +1470,8 @@ void window_manager_toggle_window_pip(struct space_manager *sm, struct window_ma
socket_close(sockfd);
}

void window_manager_validate_windows_on_space(struct space_manager *sm, struct window_manager *wm, uint64_t sid)
static void window_manager_validate_windows_on_space(struct space_manager *sm, struct window_manager *wm, uint64_t sid, uint32_t *window_list, int window_count)
{
int window_count;
uint32_t *window_list = space_window_list(sid, &window_count, false);
if (!window_list) return;

struct view *view = space_manager_find_view(sm, sid);
uint32_t *view_window_list = view_find_window_list(view);

Expand All @@ -1500,15 +1496,10 @@ void window_manager_validate_windows_on_space(struct space_manager *sm, struct w
}

buf_free(view_window_list);
free(window_list);
}

void window_manager_check_for_windows_on_space(struct space_manager *sm, struct window_manager *wm, uint64_t sid)
static void window_manager_check_for_windows_on_space(struct space_manager *sm, struct window_manager *wm, uint64_t sid, uint32_t *window_list, int window_count)
{
int window_count;
uint32_t *window_list = space_window_list(sid, &window_count, false);
if (!window_list) return;

for (int i = 0; i < window_count; ++i) {
struct window *window = window_manager_find_window(wm, window_list[i]);
if (!window || !window_manager_should_manage_window(window)) continue;
Expand All @@ -1526,7 +1517,16 @@ void window_manager_check_for_windows_on_space(struct space_manager *sm, struct
window_manager_add_managed_window(wm, window, view);
}
}
}

void window_manager_validate_and_check_for_windows_on_space(struct space_manager *sm, struct window_manager *wm, uint64_t sid)
{
int window_count;
uint32_t *window_list = space_window_list(sid, &window_count, false);
if (!window_list) return;

window_manager_validate_windows_on_space(sm, wm, sid, window_list, window_count);
window_manager_check_for_windows_on_space(sm, wm, sid, window_list, window_count);
free(window_list);
}

Expand All @@ -1538,7 +1538,12 @@ void window_manager_handle_display_add_and_remove(struct space_manager *sm, stru

for (int i = 0; i < space_count; ++i) {
if (space_is_user(space_list[i])) {
window_manager_check_for_windows_on_space(sm, wm, space_list[i]);
int window_count;
uint32_t *window_list = space_window_list(space_list[i], &window_count, false);
if (window_list) {
window_manager_check_for_windows_on_space(sm, wm, space_list[i], window_list, window_count);
free(window_list);
}
break;
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ void window_manager_set_window_border_enabled(struct window_manager *wm, bool en
void window_manager_set_window_border_width(struct window_manager *wm, int width);
void window_manager_set_active_window_border_color(struct window_manager *wm, uint32_t color);
void window_manager_set_normal_window_border_color(struct window_manager *wm, uint32_t color);
void window_manager_add_to_window_group(uint32_t child_wid, uint32_t parent_wid);
void window_manager_remove_from_window_group(uint32_t child_wid, uint32_t parent_wid);
enum window_op_error window_manager_set_window_insertion(struct space_manager *sm, struct window_manager *wm, struct window *window, int direction);
enum window_op_error window_manager_warp_window(struct space_manager *sm, struct window_manager *wm, struct window *a, struct window *b);
enum window_op_error window_manager_swap_window(struct space_manager *sm, struct window_manager *wm, struct window *a, struct window *b);
Expand All @@ -170,12 +172,9 @@ void window_manager_toggle_window_fullscreen(struct space_manager *sm, struct wi
void window_manager_toggle_window_native_fullscreen(struct space_manager *sm, struct window_manager *wm, struct window *window);
void window_manager_toggle_window_expose(struct window_manager *wm, struct window *window);
void window_manager_toggle_window_pip(struct space_manager *sm, struct window_manager *wm, struct window *window);
void window_manager_validate_windows_on_space(struct space_manager *sm, struct window_manager *wm, uint64_t sid);
void window_manager_check_for_windows_on_space(struct space_manager *sm, struct window_manager *wm, uint64_t sid);
void window_manager_validate_and_check_for_windows_on_space(struct space_manager *sm, struct window_manager *wm, uint64_t sid);
void window_manager_handle_display_add_and_remove(struct space_manager *sm, struct window_manager *wm, uint32_t did);
void window_manager_begin(struct space_manager *sm, struct window_manager *window_manager);
void window_manager_init(struct window_manager *window_manager);
void window_manager_add_to_window_group(uint32_t child_wid, uint32_t parent_wid);
void window_manager_remove_from_window_group(uint32_t child_wid, uint32_t parent_wid);

#endif

0 comments on commit f16f07b

Please sign in to comment.