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:
52
src/randr.c
52
src/randr.c
@ -32,9 +32,11 @@ static bool has_randr_1_5 = false;
|
||||
*/
|
||||
static Output *get_output_by_id(xcb_randr_output_t id) {
|
||||
Output *output;
|
||||
TAILQ_FOREACH(output, &outputs, outputs)
|
||||
if (output->id == id)
|
||||
return output;
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (output->id == id) {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -47,7 +49,7 @@ static Output *get_output_by_id(xcb_randr_output_t id) {
|
||||
Output *get_output_by_name(const char *name, const bool require_active) {
|
||||
Output *output;
|
||||
bool get_primary = (strcasecmp("primary", name) == 0);
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (output->primary && get_primary) {
|
||||
return output;
|
||||
}
|
||||
@ -55,7 +57,7 @@ Output *get_output_by_name(const char *name, const bool require_active) {
|
||||
continue;
|
||||
}
|
||||
struct output_name *output_name;
|
||||
SLIST_FOREACH(output_name, &output->names_head, names) {
|
||||
SLIST_FOREACH (output_name, &output->names_head, names) {
|
||||
if (strcasecmp(output_name->name, name) == 0) {
|
||||
return output;
|
||||
}
|
||||
@ -72,7 +74,7 @@ Output *get_output_by_name(const char *name, const bool require_active) {
|
||||
Output *get_first_output(void) {
|
||||
Output *output, *result = NULL;
|
||||
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (output->active) {
|
||||
if (output->primary) {
|
||||
return output;
|
||||
@ -97,7 +99,7 @@ Output *get_first_output(void) {
|
||||
static bool any_randr_output_active(void) {
|
||||
Output *output;
|
||||
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (output != root_output && !output->to_be_disabled && output->active)
|
||||
return true;
|
||||
}
|
||||
@ -112,7 +114,7 @@ static bool any_randr_output_active(void) {
|
||||
*/
|
||||
Output *get_output_containing(unsigned int x, unsigned int y) {
|
||||
Output *output;
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (!output->active)
|
||||
continue;
|
||||
DLOG("comparing x=%d y=%d with x=%d and y=%d width %d height %d\n",
|
||||
@ -146,7 +148,7 @@ Output *get_output_from_rect(Rect rect) {
|
||||
*/
|
||||
Output *get_output_with_dimensions(Rect rect) {
|
||||
Output *output;
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (!output->active)
|
||||
continue;
|
||||
DLOG("comparing x=%d y=%d %dx%d with x=%d and y=%d %dx%d\n",
|
||||
@ -173,7 +175,7 @@ Output *output_containing_rect(Rect rect) {
|
||||
int rx = rect.x + rect.width, by = rect.y + rect.height;
|
||||
long max_area = 0;
|
||||
Output *result = NULL;
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (!output->active)
|
||||
continue;
|
||||
int lx_o = (int)output->rect.x, uy_o = (int)output->rect.y;
|
||||
@ -241,7 +243,7 @@ Output *get_output_next(direction_t direction, Output *current, output_close_far
|
||||
*other;
|
||||
Output *output,
|
||||
*best = NULL;
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (!output->active)
|
||||
continue;
|
||||
|
||||
@ -331,7 +333,7 @@ void output_init_con(Output *output) {
|
||||
|
||||
/* Search for a Con with that name directly below the root node. There
|
||||
* might be one from a restored layout. */
|
||||
TAILQ_FOREACH(current, &(croot->nodes_head), nodes) {
|
||||
TAILQ_FOREACH (current, &(croot->nodes_head), nodes) {
|
||||
if (strcmp(current->name, output_primary_name(output)) != 0)
|
||||
continue;
|
||||
|
||||
@ -437,7 +439,7 @@ void init_ws_for_output(Output *output) {
|
||||
|
||||
/* go through all assignments and move the existing workspaces to this output */
|
||||
struct Workspace_Assignment *assignment;
|
||||
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
||||
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
|
||||
if (!output_triggers_assignment(output, assignment)) {
|
||||
continue;
|
||||
}
|
||||
@ -482,7 +484,7 @@ void init_ws_for_output(Output *output) {
|
||||
}
|
||||
|
||||
/* otherwise, we create the first assigned ws for this output */
|
||||
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
||||
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
|
||||
if (!output_triggers_assignment(output, assignment)) {
|
||||
continue;
|
||||
}
|
||||
@ -526,8 +528,8 @@ static void output_change_mode(xcb_connection_t *conn, Output *output) {
|
||||
|
||||
/* Fix the position of all floating windows on this output.
|
||||
* The 'rect' of each workspace will be updated in src/render.c. */
|
||||
TAILQ_FOREACH(workspace, &(content->nodes_head), nodes) {
|
||||
TAILQ_FOREACH(child, &(workspace->floating_head), floating_windows) {
|
||||
TAILQ_FOREACH (workspace, &(content->nodes_head), nodes) {
|
||||
TAILQ_FOREACH (child, &(workspace->floating_head), floating_windows) {
|
||||
floating_fix_coordinates(child, &(workspace->rect), &(output->con->rect));
|
||||
}
|
||||
}
|
||||
@ -536,7 +538,7 @@ static void output_change_mode(xcb_connection_t *conn, Output *output) {
|
||||
* the workspaces and their children depending on output resolution. This is
|
||||
* only done for workspaces with maximum one child. */
|
||||
if (config.default_orientation == NO_ORIENTATION) {
|
||||
TAILQ_FOREACH(workspace, &(content->nodes_head), nodes) {
|
||||
TAILQ_FOREACH (workspace, &(content->nodes_head), nodes) {
|
||||
/* Workspaces with more than one child are left untouched because
|
||||
* we do not want to change an existing layout. */
|
||||
if (con_num_children(workspace) > 1)
|
||||
@ -582,7 +584,7 @@ static bool randr_query_outputs_15(void) {
|
||||
/* Mark all outputs as to_be_disabled, since xcb_randr_get_monitors() will
|
||||
* only return active outputs. */
|
||||
Output *output;
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (output != root_output) {
|
||||
output->to_be_disabled = true;
|
||||
}
|
||||
@ -850,7 +852,7 @@ void randr_query_outputs(void) {
|
||||
|
||||
/* Check for clones, disable the clones and reduce the mode to the
|
||||
* lowest common mode */
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (!output->active || output->to_be_disabled)
|
||||
continue;
|
||||
DLOG("output %p / %s, position (%d, %d), checking for clones\n",
|
||||
@ -891,7 +893,7 @@ void randr_query_outputs(void) {
|
||||
* necessary because in the next step, a clone might get disabled. Example:
|
||||
* LVDS1 active, VGA1 gets activated as a clone of LVDS1 (has no con).
|
||||
* LVDS1 gets disabled. */
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (output->active && output->con == NULL) {
|
||||
DLOG("Need to initialize a Con for output %s\n", output_primary_name(output));
|
||||
output_init_con(output);
|
||||
@ -901,7 +903,7 @@ void randr_query_outputs(void) {
|
||||
|
||||
/* Handle outputs which have a new mode or are disabled now (either
|
||||
* because the user disabled them or because they are clones) */
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (output->to_be_disabled) {
|
||||
randr_disable_output(output);
|
||||
}
|
||||
@ -913,7 +915,7 @@ void randr_query_outputs(void) {
|
||||
}
|
||||
|
||||
/* Just go through each active output and assign one workspace */
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (!output->active)
|
||||
continue;
|
||||
Con *content = output_get_content(output->con);
|
||||
@ -924,7 +926,7 @@ void randr_query_outputs(void) {
|
||||
}
|
||||
|
||||
/* Focus the primary screen, if possible */
|
||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||
TAILQ_FOREACH (output, &outputs, outputs) {
|
||||
if (!output->primary || !output->con)
|
||||
continue;
|
||||
|
||||
@ -980,7 +982,7 @@ void randr_disable_output(Output *output) {
|
||||
con_attach(current, first_content, false);
|
||||
DLOG("Fixing the coordinates of floating containers\n");
|
||||
Con *floating_con;
|
||||
TAILQ_FOREACH(floating_con, &(current->floating_head), floating_windows) {
|
||||
TAILQ_FOREACH (floating_con, &(current->floating_head), floating_windows) {
|
||||
floating_fix_coordinates(floating_con, &(output->con->rect), &(first->con->rect));
|
||||
}
|
||||
}
|
||||
@ -994,7 +996,7 @@ void randr_disable_output(Output *output) {
|
||||
|
||||
/* 3: move the dock clients to the first output */
|
||||
Con *child;
|
||||
TAILQ_FOREACH(child, &(output->con->nodes_head), nodes) {
|
||||
TAILQ_FOREACH (child, &(output->con->nodes_head), nodes) {
|
||||
if (child->type != CT_DOCKAREA)
|
||||
continue;
|
||||
DLOG("Handling dock con %p\n", child);
|
||||
|
Reference in New Issue
Block a user