Skip to content

Commit

Permalink
rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Jun 28, 2020
1 parent e35e43d commit c8bde9e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 50 deletions.
22 changes: 11 additions & 11 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ static void window_did_receive_focus(struct window_manager *wm, struct mouse_sta
if (node->window_count <= 1) return;

for (int i = 0; i < node->window_count; ++i) {
if (node->window_id[i] != window->id) continue;
if (node->window_list[i] != window->id) continue;

memmove(node->window_id + 1, node->window_id, sizeof(uint32_t) * i);
node->window_id[0] = window->id;
memmove(node->window_list + 1, node->window_list, sizeof(uint32_t) * i);
node->window_list[0] = window->id;

break;
}
Expand Down Expand Up @@ -731,30 +731,30 @@ static EVENT_CALLBACK(EVENT_HANDLER_MOUSE_UP)
dst_view->insertion_point = g_mouse_state.window->id;
}

uint32_t tmp_window_id[64];
uint32_t tmp_window_list[64];
uint32_t tmp_window_count;

memcpy(tmp_window_id, a_node->window_id, sizeof(uint32_t) * a_node->window_count);
memcpy(tmp_window_list, a_node->window_list, sizeof(uint32_t) * a_node->window_count);
tmp_window_count = a_node->window_count;

memcpy(a_node->window_id, b_node->window_id, sizeof(uint32_t) * b_node->window_count);
memcpy(a_node->window_list, b_node->window_list, sizeof(uint32_t) * b_node->window_count);
a_node->window_count = b_node->window_count;

memcpy(b_node->window_id, tmp_window_id, sizeof(uint32_t) * tmp_window_count);
memcpy(b_node->window_list, tmp_window_list, sizeof(uint32_t) * tmp_window_count);
b_node->window_count = tmp_window_count;

a_node->zoom = NULL;
b_node->zoom = NULL;

if (src_view->sid != dst_view->sid) {
for (int i = 0; i < a_node->window_count; ++i) {
window_manager_remove_managed_window(&g_window_manager, a_node->window_id[i]);
window_manager_add_managed_window(&g_window_manager, window_manager_find_window(&g_window_manager, a_node->window_id[i]), src_view);
window_manager_remove_managed_window(&g_window_manager, a_node->window_list[i]);
window_manager_add_managed_window(&g_window_manager, window_manager_find_window(&g_window_manager, a_node->window_list[i]), src_view);
}

for (int i = 0; i < b_node->window_count; ++i) {
window_manager_remove_managed_window(&g_window_manager, b_node->window_id[i]);
window_manager_add_managed_window(&g_window_manager, window_manager_find_window(&g_window_manager, b_node->window_id[i]), dst_view);
window_manager_remove_managed_window(&g_window_manager, b_node->window_list[i]);
window_manager_add_managed_window(&g_window_manager, window_manager_find_window(&g_window_manager, b_node->window_list[i]), dst_view);
}
}

Expand Down
36 changes: 18 additions & 18 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ void insert_feedback_show(struct window_node *node)
CGPathAddLineToPoint(outline, NULL, x4, y4);

SLSDisableUpdate(g_connection);
SLSOrderWindow(g_connection, node->feedback_window.id, 0, node->window_id[0]);
SLSOrderWindow(g_connection, node->feedback_window.id, 0, node->window_list[0]);
SLSSetWindowShape(g_connection, node->feedback_window.id, 0.0f, 0.0f, frame_region);
CGContextClearRect(node->feedback_window.context, frame);
CGContextFillRect(node->feedback_window.context, fill);
CGContextAddPath(node->feedback_window.context, outline);
CGContextStrokePath(node->feedback_window.context);
CGContextFlush(node->feedback_window.context);
SLSOrderWindow(g_connection, node->feedback_window.id, 1, node->window_id[0]);
SLSOrderWindow(g_connection, node->feedback_window.id, 1, node->window_list[0]);
SLSReenableUpdate(g_connection);
CGPathRelease(outline);
CFRelease(frame_region);
Expand Down Expand Up @@ -246,14 +246,14 @@ static void window_node_split(struct view *view, struct window_node *node, struc
memset(right, 0, sizeof(struct window_node));

if (window_node_get_child(node) == CHILD_SECOND) {
memcpy(left->window_id, node->window_id, sizeof(uint32_t) * node->window_count);
memcpy(left->window_list, node->window_list, sizeof(uint32_t) * node->window_count);
left->window_count = node->window_count;
right->window_id[0] = window->id;
right->window_list[0] = window->id;
right->window_count = 1;
} else {
memcpy(right->window_id, node->window_id, sizeof(uint32_t) * node->window_count);
memcpy(right->window_list, node->window_list, sizeof(uint32_t) * node->window_count);
right->window_count = node->window_count;
left->window_id[0] = window->id;
left->window_list[0] = window->id;
left->window_count = 1;
}

Expand Down Expand Up @@ -288,7 +288,7 @@ static void window_node_destroy(struct window_node *node)
if (node->right) window_node_destroy(node->right);

for (int i = 0; i < node->window_count; ++i) {
window_manager_remove_managed_window(&g_window_manager, node->window_id[i]);
window_manager_remove_managed_window(&g_window_manager, node->window_list[i]);
}

insert_feedback_destroy(node);
Expand All @@ -309,7 +309,7 @@ void window_node_flush(struct window_node *node)
{
if (window_node_is_occupied(node)) {
for (int i = 0; i < node->window_count; ++i) {
struct window *window = window_manager_find_window(&g_window_manager, node->window_id[i]);
struct window *window = window_manager_find_window(&g_window_manager, node->window_list[i]);
if (window) {
if (node->zoom) {
window_manager_set_window_frame(window, node->zoom->area.x, node->zoom->area.y, node->zoom->area.w, node->zoom->area.h);
Expand All @@ -329,7 +329,7 @@ void window_node_flush(struct window_node *node)
bool window_node_contains_window(struct window_node *node, uint32_t window_id)
{
for (int i = 0; i < node->window_count; ++i) {
if (node->window_id[i] == window_id) return true;
if (node->window_list[i] == window_id) return true;
}

return false;
Expand Down Expand Up @@ -522,9 +522,9 @@ void view_remove_window_node(struct view *view, struct window *window)

if (node->window_count > 1) {
for (int i = 0; i < node->window_count; ++i) {
if (node->window_id[i] != window->id) continue;
if (node->window_list[i] != window->id) continue;

memmove(node->window_id + i, node->window_id + i + 1, sizeof(uint32_t) * (node->window_count - i - 1));
memmove(node->window_list + i, node->window_list + i + 1, sizeof(uint32_t) * (node->window_count - i - 1));
--node->window_count;

break;
Expand All @@ -549,7 +549,7 @@ void view_remove_window_node(struct view *view, struct window *window)
: parent->right;


memcpy(parent->window_id, child->window_id, sizeof(uint32_t) * child->window_count);
memcpy(parent->window_list, child->window_list, sizeof(uint32_t) * child->window_count);
parent->window_count = child->window_count;

parent->left = NULL;
Expand Down Expand Up @@ -596,14 +596,14 @@ void view_stack_window_node(struct view *view, struct window_node *node, struct
window_manager_set_window_frame(window, node->area.x, node->area.y, node->area.w, node->area.h);
}

node->window_id[node->window_count++] = window->id;
node->window_list[node->window_count++] = window->id;
}

void view_add_window_node(struct view *view, struct window *window)
{
if (!window_node_is_occupied(view->root) &&
window_node_is_leaf(view->root)) {
view->root->window_id[0] = window->id;
view->root->window_list[0] = window->id;
view->root->window_count = 1;
} else {
struct window_node *leaf = NULL;
Expand Down Expand Up @@ -644,7 +644,7 @@ uint32_t *view_find_window_list(struct view *view)
struct window_node *node = window_node_find_first_leaf(view->root);
while (node) {
for (int i = 0; i < node->window_count; ++i) {
buf_push(window_list, node->window_id[i]);
buf_push(window_list, node->window_list[i]);
}
node = window_node_find_next_leaf(node);
}
Expand Down Expand Up @@ -728,8 +728,8 @@ void view_serialize(FILE *rsp, struct view *view)
space_is_visible(view->sid),
view->sid == g_space_manager.current_space_id,
space_is_fullscreen(view->sid),
first_leaf ? first_leaf->window_id[0] : 0,
last_leaf ? last_leaf->window_id[0] : 0);
first_leaf ? first_leaf->window_list[0] : 0,
last_leaf ? last_leaf->window_list[0] : 0);
}

void view_update(struct view *view)
Expand Down Expand Up @@ -785,7 +785,7 @@ void view_clear(struct view *view)
if (view->root->right) window_node_destroy(view->root->right);

for (int i = 0; i < view->root->window_count; ++i) {
window_manager_remove_managed_window(&g_window_manager, view->root->window_id[i]);
window_manager_remove_managed_window(&g_window_manager, view->root->window_list[i]);
}

insert_feedback_destroy(view->root);
Expand Down
2 changes: 1 addition & 1 deletion src/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct window_node
struct window_node *left;
struct window_node *right;
struct window_node *zoom;
uint32_t window_id[64];
uint32_t window_list[64];
uint32_t window_count;
float ratio;
enum window_node_split split;
Expand Down
40 changes: 20 additions & 20 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ struct window *window_manager_find_closest_managed_window_in_direction(struct wi
struct window_node *closest = view_find_window_node_in_direction(view, node, direction);
if (!closest) return NULL;

return window_manager_find_window(wm, closest->window_id[0]);
return window_manager_find_window(wm, closest->window_list[0]);
}

struct window *window_manager_find_prev_managed_window(struct space_manager *sm, struct window_manager *wm, struct window *window)
Expand All @@ -652,7 +652,7 @@ struct window *window_manager_find_prev_managed_window(struct space_manager *sm,
struct window_node *prev = window_node_find_prev_leaf(node);
if (!prev) return NULL;

return window_manager_find_window(wm, prev->window_id[0]);
return window_manager_find_window(wm, prev->window_list[0]);
}

struct window *window_manager_find_next_managed_window(struct space_manager *sm, struct window_manager *wm, struct window *window)
Expand All @@ -666,7 +666,7 @@ struct window *window_manager_find_next_managed_window(struct space_manager *sm,
struct window_node *next = window_node_find_next_leaf(node);
if (!next) return NULL;

return window_manager_find_window(wm, next->window_id[0]);
return window_manager_find_window(wm, next->window_list[0]);
}

struct window *window_manager_find_first_managed_window(struct space_manager *sm, struct window_manager *wm)
Expand All @@ -677,7 +677,7 @@ struct window *window_manager_find_first_managed_window(struct space_manager *sm
struct window_node *first = window_node_find_first_leaf(view->root);
if (!first) return NULL;

return window_manager_find_window(wm, first->window_id[0]);
return window_manager_find_window(wm, first->window_list[0]);
}

struct window *window_manager_find_last_managed_window(struct space_manager *sm, struct window_manager *wm)
Expand All @@ -688,7 +688,7 @@ struct window *window_manager_find_last_managed_window(struct space_manager *sm,
struct window_node *last = window_node_find_last_leaf(view->root);
if (!last) return NULL;

return window_manager_find_window(wm, last->window_id[0]);
return window_manager_find_window(wm, last->window_list[0]);
}

struct window *window_manager_find_recent_managed_window(struct space_manager *sm, struct window_manager *wm)
Expand All @@ -713,7 +713,7 @@ struct window *window_manager_find_largest_managed_window(struct space_manager *
for (struct window_node *node = window_node_find_first_leaf(view->root); node != NULL; node = window_node_find_next_leaf(node)) {
uint32_t area = node->area.w * node->area.h;
if (area > best_area) {
best_id = node->window_id[0];
best_id = node->window_list[0];
best_area = area;
}
}
Expand All @@ -732,7 +732,7 @@ struct window *window_manager_find_smallest_managed_window(struct space_manager
for (struct window_node *node = window_node_find_first_leaf(view->root); node != NULL; node = window_node_find_next_leaf(node)) {
uint32_t area = node->area.w * node->area.h;
if (area <= best_area) {
best_id = node->window_id[0];
best_id = node->window_list[0];
best_area = area;
}
}
Expand Down Expand Up @@ -1038,7 +1038,7 @@ enum window_op_error window_manager_set_window_insertion(struct space_manager *s
}

node->insert_dir = direction;
view->insertion_point = node->window_id[0];
view->insertion_point = node->window_list[0];
insert_feedback_show(node);

return WINDOW_OP_ERROR_SUCCESS;
Expand Down Expand Up @@ -1102,16 +1102,16 @@ enum window_op_error window_manager_warp_window(struct space_manager *sm, struct
a_view->insertion_point = b->id;
}

uint32_t tmp_window_id[64];
uint32_t tmp_window_list[64];
uint32_t tmp_window_count;

memcpy(tmp_window_id, a_node->window_id, sizeof(uint32_t) * a_node->window_count);
memcpy(tmp_window_list, a_node->window_list, sizeof(uint32_t) * a_node->window_count);
tmp_window_count = a_node->window_count;

memcpy(a_node->window_id, b_node->window_id, sizeof(uint32_t) * b_node->window_count);
memcpy(a_node->window_list, b_node->window_list, sizeof(uint32_t) * b_node->window_count);
a_node->window_count = b_node->window_count;

memcpy(b_node->window_id, tmp_window_id, sizeof(uint32_t) * tmp_window_count);
memcpy(b_node->window_list, tmp_window_list, sizeof(uint32_t) * tmp_window_count);
b_node->window_count = tmp_window_count;

a_node->zoom = NULL;
Expand Down Expand Up @@ -1169,32 +1169,32 @@ enum window_op_error window_manager_swap_window(struct space_manager *sm, struct
b_view->insertion_point = a->id;
}

uint32_t tmp_window_id[64];
uint32_t tmp_window_list[64];
uint32_t tmp_window_count;

memcpy(tmp_window_id, a_node->window_id, sizeof(uint32_t) * a_node->window_count);
memcpy(tmp_window_list, a_node->window_list, sizeof(uint32_t) * a_node->window_count);
tmp_window_count = a_node->window_count;

memcpy(a_node->window_id, b_node->window_id, sizeof(uint32_t) * b_node->window_count);
memcpy(a_node->window_list, b_node->window_list, sizeof(uint32_t) * b_node->window_count);
a_node->window_count = b_node->window_count;

memcpy(b_node->window_id, tmp_window_id, sizeof(uint32_t) * tmp_window_count);
memcpy(b_node->window_list, tmp_window_list, sizeof(uint32_t) * tmp_window_count);
b_node->window_count = tmp_window_count;

a_node->zoom = NULL;
b_node->zoom = NULL;

if (a_view->sid != b_view->sid) {
for (int i = 0; i < a_node->window_count; ++i) {
struct window *window = window_manager_find_window(wm, a_node->window_id[i]);
window_manager_remove_managed_window(wm, a_node->window_id[i]);
struct window *window = window_manager_find_window(wm, a_node->window_list[i]);
window_manager_remove_managed_window(wm, a_node->window_list[i]);
window_manager_add_managed_window(wm, window, a_view);
space_manager_move_window_to_space(a_view->sid, window);
}

for (int i = 0; i < b_node->window_count; ++i) {
struct window *window = window_manager_find_window(wm, b_node->window_id[i]);
window_manager_remove_managed_window(wm, b_node->window_id[i]);
struct window *window = window_manager_find_window(wm, b_node->window_list[i]);
window_manager_remove_managed_window(wm, b_node->window_list[i]);
window_manager_add_managed_window(wm, window, b_view);
space_manager_move_window_to_space(b_view->sid, window);
}
Expand Down

0 comments on commit c8bde9e

Please sign in to comment.