clang-format: bring back ForeachMacros (#3948)

* clang-format: bring back ForeachMacros

ForeachMacros was disabled in 4211274fcd
due to the breakage of include/queue.h. The currently used version,
clang-format-6.0 doesn't break it.

* Add curly braces

Co-authored-by: Orestis Floros <orestisflo@gmail.com>
This commit is contained in:
xzfc
2020-02-19 10:31:09 +00:00
committed by GitHub
parent e3f120c0b6
commit 1f0c628cde
37 changed files with 363 additions and 329 deletions

View File

@ -29,7 +29,7 @@ static char **binding_workspace_names = NULL;
*/
Con *get_existing_workspace_by_name(const char *name) {
Con *output, *workspace = NULL;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
GREP_FIRST(workspace, output_get_content(output), !strcasecmp(child->name, name));
}
@ -43,7 +43,7 @@ Con *get_existing_workspace_by_name(const char *name) {
*/
Con *get_existing_workspace_by_num(int num) {
Con *output, *workspace = NULL;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
GREP_FIRST(workspace, output_get_content(output), child->num == num);
}
@ -84,7 +84,7 @@ static void _workspace_apply_default_orientation(Con *ws) {
static Con *get_assigned_output(const char *name, long parsed_num) {
Con *output = NULL;
struct Workspace_Assignment *assignment;
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
if (name && strcmp(assignment->name, name) == 0) {
DLOG("Found workspace name assignment to output \"%s\"\n", assignment->output);
Output *assigned_by_name = get_output_by_name(assignment->output, true);
@ -187,7 +187,7 @@ void extract_workspace_names_from_bindings(void) {
}
FREE(binding_workspace_names);
}
TAILQ_FOREACH(bind, bindings, bindings) {
TAILQ_FOREACH (bind, bindings, bindings) {
DLOG("binding with command %s\n", bind->command);
if (strlen(bind->command) < strlen("workspace ") ||
strncasecmp(bind->command, "workspace", strlen("workspace")) != 0)
@ -321,7 +321,7 @@ bool workspace_is_visible(Con *ws) {
static Con *_get_sticky(Con *con, const char *sticky_group, Con *exclude) {
Con *current;
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
if (current != exclude &&
current->sticky_group != NULL &&
current->window != NULL &&
@ -333,7 +333,7 @@ static Con *_get_sticky(Con *con, const char *sticky_group, Con *exclude) {
return recurse;
}
TAILQ_FOREACH(current, &(con->floating_head), floating_windows) {
TAILQ_FOREACH (current, &(con->floating_head), floating_windows) {
if (current != exclude &&
current->sticky_group != NULL &&
current->window != NULL &&
@ -360,7 +360,7 @@ static void workspace_reassign_sticky(Con *con) {
/* 1: go through all containers */
/* handle all children and floating windows of this node */
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
if (current->sticky_group == NULL) {
workspace_reassign_sticky(current);
continue;
@ -388,8 +388,9 @@ static void workspace_reassign_sticky(Con *con) {
LOG("re-assigned window from src %p to dest %p\n", src, current);
}
TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
workspace_reassign_sticky(current);
TAILQ_FOREACH (current, &(con->floating_head), floating_windows) {
workspace_reassign_sticky(current);
}
}
/*
@ -427,7 +428,7 @@ void workspace_show(Con *workspace) {
/* disable fullscreen for the other workspaces and get the workspace we are
* currently on. */
TAILQ_FOREACH(current, &(workspace->parent->nodes_head), nodes) {
TAILQ_FOREACH (current, &(workspace->parent->nodes_head), nodes) {
if (current->fullscreen_mode == CF_OUTPUT)
old = current;
current->fullscreen_mode = CF_NONE;
@ -570,11 +571,11 @@ Con *workspace_next(void) {
if ((next = TAILQ_NEXT(current, nodes)) != NULL)
return next;
bool found_current = false;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
/* Skip outputs starting with __, they are internal. */
if (con_is_internal(output))
continue;
NODES_FOREACH(output_get_content(output)) {
NODES_FOREACH (output_get_content(output)) {
if (child->type != CT_WORKSPACE)
continue;
if (!first)
@ -591,11 +592,11 @@ Con *workspace_next(void) {
}
} else {
/* If currently a numbered workspace, find next numbered workspace. */
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
/* Skip outputs starting with __, they are internal. */
if (con_is_internal(output))
continue;
NODES_FOREACH(output_get_content(output)) {
NODES_FOREACH (output_get_content(output)) {
if (child->type != CT_WORKSPACE)
continue;
if (!first || (child->num != -1 && child->num < first->num))
@ -635,11 +636,11 @@ Con *workspace_prev(void) {
prev = NULL;
if (!prev) {
bool found_current = false;
TAILQ_FOREACH_REVERSE(output, &(croot->nodes_head), nodes_head, nodes) {
TAILQ_FOREACH_REVERSE (output, &(croot->nodes_head), nodes_head, nodes) {
/* Skip outputs starting with __, they are internal. */
if (con_is_internal(output))
continue;
NODES_FOREACH_REVERSE(output_get_content(output)) {
NODES_FOREACH_REVERSE (output_get_content(output)) {
if (child->type != CT_WORKSPACE)
continue;
if (!last)
@ -657,11 +658,11 @@ Con *workspace_prev(void) {
}
} else {
/* If numbered workspace, find previous numbered workspace. */
TAILQ_FOREACH_REVERSE(output, &(croot->nodes_head), nodes_head, nodes) {
TAILQ_FOREACH_REVERSE (output, &(croot->nodes_head), nodes_head, nodes) {
/* Skip outputs starting with __, they are internal. */
if (con_is_internal(output))
continue;
NODES_FOREACH_REVERSE(output_get_content(output)) {
NODES_FOREACH_REVERSE (output_get_content(output)) {
if (child->type != CT_WORKSPACE)
continue;
if (!last || (child->num != -1 && last->num < child->num))
@ -699,7 +700,7 @@ Con *workspace_next_on_output(void) {
next = TAILQ_NEXT(current, nodes);
} else {
/* If currently a numbered workspace, find next numbered workspace. */
NODES_FOREACH(output_get_content(output)) {
NODES_FOREACH (output_get_content(output)) {
if (child->type != CT_WORKSPACE)
continue;
if (child->num == -1)
@ -715,7 +716,7 @@ Con *workspace_next_on_output(void) {
/* Find next named workspace. */
if (!next) {
bool found_current = false;
NODES_FOREACH(output_get_content(output)) {
NODES_FOREACH (output_get_content(output)) {
if (child->type != CT_WORKSPACE)
continue;
if (child == current) {
@ -729,7 +730,7 @@ Con *workspace_next_on_output(void) {
/* Find first workspace. */
if (!next) {
NODES_FOREACH(output_get_content(output)) {
NODES_FOREACH (output_get_content(output)) {
if (child->type != CT_WORKSPACE)
continue;
if (!next || (child->num != -1 && child->num < next->num))
@ -757,7 +758,7 @@ Con *workspace_prev_on_output(void) {
prev = NULL;
} else {
/* If numbered workspace, find previous numbered workspace. */
NODES_FOREACH_REVERSE(output_get_content(output)) {
NODES_FOREACH_REVERSE (output_get_content(output)) {
if (child->type != CT_WORKSPACE || child->num == -1)
continue;
/* Need to check child against current and previous because we
@ -771,7 +772,7 @@ Con *workspace_prev_on_output(void) {
/* Find previous named workspace. */
if (!prev) {
bool found_current = false;
NODES_FOREACH_REVERSE(output_get_content(output)) {
NODES_FOREACH_REVERSE (output_get_content(output)) {
if (child->type != CT_WORKSPACE)
continue;
if (child == current) {
@ -785,7 +786,7 @@ Con *workspace_prev_on_output(void) {
/* Find last workspace. */
if (!prev) {
NODES_FOREACH_REVERSE(output_get_content(output)) {
NODES_FOREACH_REVERSE (output_get_content(output)) {
if (child->type != CT_WORKSPACE)
continue;
if (!prev || child->num > prev->num)
@ -828,13 +829,17 @@ Con *workspace_back_and_forth_get(void) {
static bool get_urgency_flag(Con *con) {
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
if (child->urgent || get_urgency_flag(child))
return true;
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (child->urgent || get_urgency_flag(child)) {
return true;
}
}
TAILQ_FOREACH(child, &(con->floating_head), floating_windows)
if (child->urgent || get_urgency_flag(child))
return true;
TAILQ_FOREACH (child, &(con->floating_head), floating_windows) {
if (child->urgent || get_urgency_flag(child)) {
return true;
}
}
return false;
}
@ -991,7 +996,7 @@ void workspace_move_to_output(Con *ws, Output *output) {
/* check if we can find a workspace assigned to this output */
bool used_assignment = false;
struct Workspace_Assignment *assignment;
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
bool attached;
int num;
if (!output_triggers_assignment(current_output, assignment)) {
@ -1034,7 +1039,7 @@ void workspace_move_to_output(Con *ws, Output *output) {
/* fix the coordinates of the floating containers */
Con *floating_con;
TAILQ_FOREACH(floating_con, &(ws->floating_head), floating_windows) {
TAILQ_FOREACH (floating_con, &(ws->floating_head), floating_windows) {
floating_fix_coordinates(floating_con, &(old_content->rect), &(content->rect));
}
@ -1053,7 +1058,7 @@ void workspace_move_to_output(Con *ws, Output *output) {
* order/number of other workspaces on the output. Instead, we loop through
* the available workspaces and only work with previously_visible_ws if we
* still find it. */
TAILQ_FOREACH(ws, &(content->nodes_head), nodes) {
TAILQ_FOREACH (ws, &(content->nodes_head), nodes) {
if (ws != previously_visible_ws) {
continue;
}