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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 363 additions and 329 deletions

View File

@ -9,3 +9,4 @@ PointerBindsToType: false
ColumnLimit: 0
SpaceBeforeParens: ControlStatements
SortIncludes: false
ForEachMacros: [ TAILQ_FOREACH, TAILQ_FOREACH_REVERSE, SLIST_FOREACH, CIRCLEQ_FOREACH, CIRCLEQ_FOREACH_REVERSE, NODES_FOREACH, NODES_FOREACH_REVERSE, FOREACH_NONINTERNAL]

View File

@ -90,7 +90,7 @@ static void clear_statusline(struct statusline_head *head, bool free_resources)
static void copy_statusline(struct statusline_head *from, struct statusline_head *to) {
struct status_block *current;
TAILQ_FOREACH(current, from, blocks) {
TAILQ_FOREACH (current, from, blocks) {
struct status_block *new_block = smalloc(sizeof(struct status_block));
memcpy(new_block, current, sizeof(struct status_block));
TAILQ_INSERT_TAIL(to, new_block, blocks);
@ -330,7 +330,7 @@ static int stdin_end_array(void *context) {
DLOG("dumping statusline:\n");
struct status_block *current;
TAILQ_FOREACH(current, &statusline_head, blocks) {
TAILQ_FOREACH (current, &statusline_head, blocks) {
DLOG("full_text = %s\n", i3string_as_utf8(current->full_text));
DLOG("short_text = %s\n", (current->short_text == NULL ? NULL : i3string_as_utf8(current->short_text)));
DLOG("color = %s\n", current->color);

View File

@ -72,7 +72,7 @@ static void got_output_reply(char *reply) {
reconfig_windows(false);
i3_output *o_walk;
SLIST_FOREACH(o_walk, outputs, slist) {
SLIST_FOREACH (o_walk, outputs, slist) {
kick_tray_clients(o_walk);
}

View File

@ -304,7 +304,7 @@ void free_outputs(void) {
if (outputs == NULL) {
return;
}
SLIST_FOREACH(outputs_walk, outputs, slist) {
SLIST_FOREACH (outputs_walk, outputs, slist) {
destroy_window(outputs_walk);
if (outputs_walk->trayclients != NULL && !TAILQ_EMPTY(outputs_walk->trayclients)) {
FREE_TAILQ(outputs_walk->trayclients, trayclient);
@ -323,7 +323,7 @@ i3_output *get_output_by_name(char *name) {
if (name == NULL) {
return NULL;
}
SLIST_FOREACH(walk, outputs, slist) {
SLIST_FOREACH (walk, outputs, slist) {
if (!strcmp(walk->name, name)) {
break;
}
@ -338,7 +338,7 @@ i3_output *get_output_by_name(char *name) {
*/
bool output_has_focus(i3_output *output) {
i3_ws *ws_walk;
TAILQ_FOREACH(ws_walk, output->workspaces, tailq) {
TAILQ_FOREACH (ws_walk, output->workspaces, tailq) {
if (ws_walk->focused) {
return true;
}

View File

@ -269,9 +269,9 @@ void free_workspaces(void) {
}
i3_ws *ws_walk;
SLIST_FOREACH(outputs_walk, outputs, slist) {
SLIST_FOREACH (outputs_walk, outputs, slist) {
if (outputs_walk->workspaces != NULL && !TAILQ_EMPTY(outputs_walk->workspaces)) {
TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
TAILQ_FOREACH (ws_walk, outputs_walk->workspaces, tailq) {
I3STRING_FREE(ws_walk->name);
FREE(ws_walk->canonical_name);
}

View File

@ -161,7 +161,7 @@ static uint32_t get_sep_offset(struct status_block *block) {
static int get_tray_width(struct tc_head *trayclients) {
trayclient *trayclient;
int tray_width = 0;
TAILQ_FOREACH_REVERSE(trayclient, trayclients, tc_head, tailq) {
TAILQ_FOREACH_REVERSE (trayclient, trayclients, tc_head, tailq) {
if (!trayclient->mapped)
continue;
tray_width += icon_size + logical_px(config.tray_padding);
@ -203,7 +203,7 @@ static uint32_t predict_statusline_length(bool use_short_text) {
uint32_t width = 0;
struct status_block *block;
TAILQ_FOREACH(block, &statusline_head, blocks) {
TAILQ_FOREACH (block, &statusline_head, blocks) {
i3String *text = block->full_text;
struct status_block_render_desc *render = &block->full_render;
if (use_short_text && block->short_text != NULL) {
@ -266,7 +266,7 @@ static void draw_statusline(i3_output *output, uint32_t clip_left, bool use_focu
uint32_t x = 0 - clip_left;
/* Draw the text of each block */
TAILQ_FOREACH(block, &statusline_head, blocks) {
TAILQ_FOREACH (block, &statusline_head, blocks) {
i3String *text = block->full_text;
struct status_block_render_desc *render = &block->full_render;
if (use_short_text && block->short_text != NULL) {
@ -343,7 +343,7 @@ static void hide_bars(void) {
}
i3_output *walk;
SLIST_FOREACH(walk, outputs, slist) {
SLIST_FOREACH (walk, outputs, slist) {
if (!walk->active) {
continue;
}
@ -368,7 +368,7 @@ static void unhide_bars(void) {
cont_child();
SLIST_FOREACH(walk, outputs, slist) {
SLIST_FOREACH (walk, outputs, slist) {
if (walk->bar.id == XCB_NONE) {
continue;
}
@ -448,7 +448,7 @@ void init_colors(const struct xcb_color_strings_t *new_colors) {
static bool execute_custom_command(xcb_keycode_t input_code, bool event_is_release) {
binding_t *binding;
TAILQ_FOREACH(binding, &(config.bindings), bindings) {
TAILQ_FOREACH (binding, &(config.bindings), bindings) {
if ((binding->input_code != input_code) || (binding->release != event_is_release))
continue;
@ -466,7 +466,7 @@ static void child_handle_button(xcb_button_press_event_t *event, i3_output *outp
/* x of the start of the current block relative to the statusline. */
uint32_t last_block_x = 0;
struct status_block *block;
TAILQ_FOREACH(block, &statusline_head, blocks) {
TAILQ_FOREACH (block, &statusline_head, blocks) {
i3String *text;
struct status_block_render_desc *render;
if (output->statusline_short_text && block->short_text != NULL) {
@ -521,7 +521,7 @@ static void handle_button(xcb_button_press_event_t *event) {
/* Determine, which bar was clicked */
i3_output *walk;
xcb_window_t bar = event->event;
SLIST_FOREACH(walk, outputs, slist) {
SLIST_FOREACH (walk, outputs, slist) {
if (walk->bar.id == bar) {
break;
}
@ -541,7 +541,7 @@ static void handle_button(xcb_button_press_event_t *event) {
int workspace_width = 0;
i3_ws *cur_ws = NULL, *clicked_ws = NULL, *ws_walk;
TAILQ_FOREACH(ws_walk, walk->workspaces, tailq) {
TAILQ_FOREACH (ws_walk, walk->workspaces, tailq) {
int w = predict_button_width(ws_walk->name_width);
if (x >= workspace_width && x <= workspace_width + w)
clicked_ws = ws_walk;
@ -614,7 +614,7 @@ static void handle_button(xcb_button_press_event_t *event) {
/* if no workspace was clicked, focus our currently visible
* workspace if it is not already focused */
if (cur_ws == NULL) {
TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
TAILQ_FOREACH (cur_ws, walk->workspaces, tailq) {
if (cur_ws->visible && !cur_ws->focused)
break;
}
@ -672,7 +672,7 @@ static void handle_visibility_notify(xcb_visibility_notify_event_t *event) {
int num_visible = 0;
i3_output *output;
SLIST_FOREACH(output, outputs, slist) {
SLIST_FOREACH (output, outputs, slist) {
if (!output->active) {
continue;
}
@ -729,14 +729,14 @@ static int reorder_trayclients_cmp(const void *_a, const void *_b) {
*/
static void configure_trayclients(void) {
i3_output *output;
SLIST_FOREACH(output, outputs, slist) {
SLIST_FOREACH (output, outputs, slist) {
if (!output->active) {
continue;
}
int count = 0;
trayclient *client;
TAILQ_FOREACH(client, output->trayclients, tailq) {
TAILQ_FOREACH (client, output->trayclients, tailq) {
if (client->mapped) {
count++;
}
@ -744,7 +744,7 @@ static void configure_trayclients(void) {
int idx = 0;
trayclient **trayclients = smalloc(count * sizeof(trayclient *));
TAILQ_FOREACH(client, output->trayclients, tailq) {
TAILQ_FOREACH (client, output->trayclients, tailq) {
if (client->mapped) {
trayclients[idx++] = client;
}
@ -769,13 +769,13 @@ static void configure_trayclients(void) {
static trayclient *trayclient_and_output_from_window(xcb_window_t win, i3_output **output) {
i3_output *o_walk;
SLIST_FOREACH(o_walk, outputs, slist) {
SLIST_FOREACH (o_walk, outputs, slist) {
if (!o_walk->active) {
continue;
}
trayclient *client;
TAILQ_FOREACH(client, o_walk->trayclients, tailq) {
TAILQ_FOREACH (client, o_walk->trayclients, tailq) {
if (client->win == win) {
if (output) {
*output = o_walk;
@ -1118,12 +1118,12 @@ static void handle_property_notify(xcb_property_notify_event_t *event) {
static void handle_configuration_change(xcb_window_t window) {
trayclient *trayclient;
i3_output *output;
SLIST_FOREACH(output, outputs, slist) {
SLIST_FOREACH (output, outputs, slist) {
if (!output->active)
continue;
int clients = 0;
TAILQ_FOREACH_REVERSE(trayclient, output->trayclients, tc_head, tailq) {
TAILQ_FOREACH_REVERSE (trayclient, output->trayclients, tc_head, tailq) {
if (!trayclient->mapped)
continue;
clients++;
@ -1733,7 +1733,7 @@ static i3_output *get_tray_output(void) {
i3_output *output = NULL;
if (TAILQ_EMPTY(&(config.tray_outputs))) {
/* No tray_output specified, use first active output. */
SLIST_FOREACH(output, outputs, slist) {
SLIST_FOREACH (output, outputs, slist) {
if (output->active) {
return output;
}
@ -1747,8 +1747,8 @@ static i3_output *get_tray_output(void) {
/* If one or more tray_output assignments were specified, we ensure that at
* least one of them is actually an output managed by this instance. */
tray_output_t *tray_output;
TAILQ_FOREACH(tray_output, &(config.tray_outputs), tray_outputs) {
SLIST_FOREACH(output, outputs, slist) {
TAILQ_FOREACH (tray_output, &(config.tray_outputs), tray_outputs) {
SLIST_FOREACH (output, outputs, slist) {
if (output->active &&
(strcasecmp(output->name, tray_output->output) == 0 ||
(strcasecmp(tray_output->output, "primary") == 0 && output->primary))) {
@ -1769,7 +1769,7 @@ void reconfig_windows(bool redraw_bars) {
uint32_t values[6];
i3_output *walk;
SLIST_FOREACH(walk, outputs, slist) {
SLIST_FOREACH (walk, outputs, slist) {
if (!walk->active) {
/* If an output is not active, we destroy its bar */
/* FIXME: Maybe we rather want to unmap? */
@ -2032,7 +2032,7 @@ void draw_bars(bool unhide) {
uint32_t short_statusline_width = predict_statusline_length(true);
i3_output *outputs_walk;
SLIST_FOREACH(outputs_walk, outputs, slist) {
SLIST_FOREACH (outputs_walk, outputs, slist) {
int workspace_width = 0;
if (!outputs_walk->active) {
@ -2051,7 +2051,7 @@ void draw_bars(bool unhide) {
if (!config.disable_ws) {
i3_ws *ws_walk;
TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
TAILQ_FOREACH (ws_walk, outputs_walk->workspaces, tailq) {
DLOG("Drawing button for WS %s at x = %d, len = %d\n",
i3string_as_utf8(ws_walk->name), workspace_width, ws_walk->name_width);
color_t fg_color = colors.inactive_ws_fg;
@ -2145,7 +2145,7 @@ void draw_bars(bool unhide) {
*/
void redraw_bars(void) {
i3_output *outputs_walk;
SLIST_FOREACH(outputs_walk, outputs, slist) {
SLIST_FOREACH (outputs_walk, outputs, slist) {
if (!outputs_walk->active) {
continue;
}

View File

@ -28,15 +28,15 @@
#define NODES_FOREACH(head) \
for (Con *child = (Con *)-1; (child == (Con *)-1) && ((child = 0), true);) \
TAILQ_FOREACH(child, &((head)->nodes_head), nodes)
TAILQ_FOREACH (child, &((head)->nodes_head), nodes)
#define NODES_FOREACH_REVERSE(head) \
for (Con *child = (Con *)-1; (child == (Con *)-1) && ((child = 0), true);) \
TAILQ_FOREACH_REVERSE(child, &((head)->nodes_head), nodes_head, nodes)
TAILQ_FOREACH_REVERSE (child, &((head)->nodes_head), nodes_head, nodes)
/* greps the ->nodes of the given head and returns the first node that matches the given condition */
#define GREP_FIRST(dest, head, condition) \
NODES_FOREACH(head) { \
NODES_FOREACH (head) { \
if (!(condition)) \
continue; \
\

View File

@ -48,7 +48,7 @@ uint32_t get_colorpixel(const char *hex) {
/* Lookup this colorpixel in the cache */
struct Colorpixel *colorpixel;
SLIST_FOREACH(colorpixel, &(colorpixels), colorpixels) {
SLIST_FOREACH (colorpixel, &(colorpixels), colorpixels) {
if (strcmp(colorpixel->hex, hex) == 0)
return colorpixel->pixel;
}

View File

@ -21,7 +21,7 @@ void run_assignments(i3Window *window) {
/* Check if any assignments match */
Assignment *current;
TAILQ_FOREACH(current, &assignments, assignments) {
TAILQ_FOREACH (current, &assignments, assignments) {
if (current->type != A_COMMAND || !match_matches_window(&(current->match), window))
continue;
@ -69,7 +69,7 @@ void run_assignments(i3Window *window) {
Assignment *assignment_for(i3Window *window, int type) {
Assignment *assignment;
TAILQ_FOREACH(assignment, &assignments, assignments) {
TAILQ_FOREACH (assignment, &assignments, assignments) {
if ((type != A_ANY && (assignment->type & type) == 0) ||
!match_matches_window(&(assignment->match), window))
continue;

View File

@ -31,7 +31,7 @@ static struct Mode *mode_from_name(const char *name, bool pango_markup) {
struct Mode *mode;
/* Try to find the mode in the list of modes and return it */
SLIST_FOREACH(mode, &modes, modes) {
SLIST_FOREACH (mode, &modes, modes) {
if (strcmp(mode->name, name) == 0) {
return mode;
}
@ -146,7 +146,7 @@ static void grab_keycode_for_binding(xcb_connection_t *conn, Binding *bind, uint
*/
void grab_all_keys(xcb_connection_t *conn) {
Binding *bind;
TAILQ_FOREACH(bind, bindings, bindings) {
TAILQ_FOREACH (bind, bindings, bindings) {
if (bind->input_type != B_KEYBOARD)
continue;
@ -160,7 +160,7 @@ void grab_all_keys(xcb_connection_t *conn) {
}
struct Binding_Keycode *binding_keycode;
TAILQ_FOREACH(binding_keycode, &(bind->keycodes_head), keycodes) {
TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
const int keycode = binding_keycode->keycode;
const int mods = (binding_keycode->modifiers & 0xFFFF);
DLOG("Binding %p Grabbing keycode %d with mods %d\n", bind, keycode, mods);
@ -179,7 +179,7 @@ void regrab_all_buttons(xcb_connection_t *conn) {
xcb_grab_server(conn);
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) {
TAILQ_FOREACH (con, &all_cons, all_cons) {
if (con->window == NULL)
continue;
@ -203,7 +203,7 @@ static Binding *get_binding(i3_event_state_mask_t state_filtered, bool is_releas
if (!is_release) {
/* On a press event, we first reset all B_UPON_KEYRELEASE_IGNORE_MODS
* bindings back to B_UPON_KEYRELEASE */
TAILQ_FOREACH(bind, bindings, bindings) {
TAILQ_FOREACH (bind, bindings, bindings) {
if (bind->input_type != input_type)
continue;
if (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS)
@ -213,7 +213,7 @@ static Binding *get_binding(i3_event_state_mask_t state_filtered, bool is_releas
const uint32_t xkb_group_state = (state_filtered & 0xFFFF0000);
const uint32_t modifiers_state = (state_filtered & 0x0000FFFF);
TAILQ_FOREACH(bind, bindings, bindings) {
TAILQ_FOREACH (bind, bindings, bindings) {
if (bind->input_type != input_type) {
continue;
}
@ -232,7 +232,7 @@ static Binding *get_binding(i3_event_state_mask_t state_filtered, bool is_releas
if (input_type == B_KEYBOARD && bind->symbol != NULL) {
xcb_keycode_t input_keycode = (xcb_keycode_t)input_code;
struct Binding_Keycode *binding_keycode;
TAILQ_FOREACH(binding_keycode, &(bind->keycodes_head), keycodes) {
TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
const uint32_t modifiers_mask = (binding_keycode->modifiers & 0x0000FFFF);
const bool mods_match = (modifiers_mask == modifiers_state);
DLOG("binding_keycode->modifiers = %d, modifiers_mask = %d, modifiers_state = %d, mods_match = %s\n",
@ -250,7 +250,7 @@ static Binding *get_binding(i3_event_state_mask_t state_filtered, bool is_releas
}
struct Binding_Keycode *binding_keycode;
TAILQ_FOREACH(binding_keycode, &(bind->keycodes_head), keycodes) {
TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
const uint32_t modifiers_mask = (binding_keycode->modifiers & 0x0000FFFF);
const bool mods_match = (modifiers_mask == modifiers_state);
DLOG("binding_keycode->modifiers = %d, modifiers_mask = %d, modifiers_state = %d, mods_match = %s\n",
@ -445,7 +445,7 @@ void translate_keysyms(void) {
}
Binding *bind;
TAILQ_FOREACH(bind, bindings, bindings) {
TAILQ_FOREACH (bind, bindings, bindings) {
if (bind->input_type == B_MOUSE) {
long button;
if (!parse_long(bind->symbol + (sizeof("button") - 1), &button, 10)) {
@ -571,7 +571,7 @@ void translate_keysyms(void) {
char *keycodes = sstrdup("");
int num_keycodes = 0;
struct Binding_Keycode *binding_keycode;
TAILQ_FOREACH(binding_keycode, &(bind->keycodes_head), keycodes) {
TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
char *tmp;
sasprintf(&tmp, "%s %d", keycodes, binding_keycode->keycode);
free(keycodes);
@ -580,7 +580,7 @@ void translate_keysyms(void) {
/* check for duplicate bindings */
Binding *check;
TAILQ_FOREACH(check, bindings, bindings) {
TAILQ_FOREACH (check, bindings, bindings) {
if (check == bind)
continue;
if (check->symbol != NULL)
@ -620,7 +620,7 @@ void switch_mode(const char *new_mode) {
DLOG("Switching to mode %s\n", new_mode);
SLIST_FOREACH(mode, &modes, modes) {
SLIST_FOREACH (mode, &modes, modes) {
if (strcmp(mode->name, new_mode) != 0)
continue;
@ -632,7 +632,7 @@ void switch_mode(const char *new_mode) {
/* Reset all B_UPON_KEYRELEASE_IGNORE_MODS bindings to avoid possibly
* activating one of them. */
Binding *bind;
TAILQ_FOREACH(bind, bindings, bindings) {
TAILQ_FOREACH (bind, bindings, bindings) {
if (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS)
bind->release = B_UPON_KEYRELEASE;
}
@ -666,12 +666,12 @@ static void reorder_bindings_of_mode(struct Mode *mode) {
/* Copy the bindings into an array, so that we can use qsort(3). */
int n = 0;
Binding *current;
TAILQ_FOREACH(current, mode->bindings, bindings) {
TAILQ_FOREACH (current, mode->bindings, bindings) {
n++;
}
Binding **tmp = scalloc(n, sizeof(Binding *));
n = 0;
TAILQ_FOREACH(current, mode->bindings, bindings) {
TAILQ_FOREACH (current, mode->bindings, bindings) {
tmp[n++] = current;
}
@ -706,7 +706,7 @@ static void reorder_bindings_of_mode(struct Mode *mode) {
*/
void reorder_bindings(void) {
struct Mode *mode;
SLIST_FOREACH(mode, &modes, modes) {
SLIST_FOREACH (mode, &modes, modes) {
const bool current_mode = (mode->bindings == bindings);
reorder_bindings_of_mode(mode);
if (current_mode)
@ -723,8 +723,8 @@ void reorder_bindings(void) {
*/
void check_for_duplicate_bindings(struct context *context) {
Binding *bind, *current;
TAILQ_FOREACH(current, bindings, bindings) {
TAILQ_FOREACH(bind, bindings, bindings) {
TAILQ_FOREACH (current, bindings, bindings) {
TAILQ_FOREACH (bind, bindings, bindings) {
/* Abort when we reach the current keybinding, only check the
* bindings before */
if (bind == current)
@ -777,7 +777,7 @@ static Binding *binding_copy(Binding *bind) {
ret->command = sstrdup(bind->command);
TAILQ_INIT(&(ret->keycodes_head));
struct Binding_Keycode *binding_keycode;
TAILQ_FOREACH(binding_keycode, &(bind->keycodes_head), keycodes) {
TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
struct Binding_Keycode *ret_binding_keycode = smalloc(sizeof(struct Binding_Keycode));
*ret_binding_keycode = *binding_keycode;
TAILQ_INSERT_TAIL(&(ret->keycodes_head), ret_binding_keycode, keycodes);
@ -995,7 +995,7 @@ int *bindings_get_buttons_to_grab(void) {
buffer[num++] = 3;
Binding *bind;
TAILQ_FOREACH(bind, bindings, bindings) {
TAILQ_FOREACH (bind, bindings, bindings) {
if (num + 1 == num_max)
break;

View File

@ -338,7 +338,7 @@ int handle_button_press(xcb_button_press_event_t *event) {
* click coordinates and focus the output's active workspace. */
if (event->event == root && event->response_type == XCB_BUTTON_PRESS) {
Con *output, *ws;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
if (con_is_internal(output) ||
!rect_contains(output->rect, event->event_x, event->event_y))
continue;
@ -361,7 +361,7 @@ int handle_button_press(xcb_button_press_event_t *event) {
/* Check if the click was on the decoration of a child */
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (!rect_contains(child->deco_rect, event->event_x, event->event_y))
continue;

View File

@ -160,7 +160,7 @@ void cmd_criteria_init(I3_CMD) {
}
TAILQ_INIT(&owindows);
/* copy all_cons */
TAILQ_FOREACH(con, &all_cons, all_cons) {
TAILQ_FOREACH (con, &all_cons, all_cons) {
ow = smalloc(sizeof(owindow));
ow->con = con;
TAILQ_INSERT_TAIL(&owindows, ow, owindows);
@ -210,7 +210,7 @@ void cmd_criteria_match_windows(I3_CMD) {
bool matched_by_mark = false;
mark_t *mark;
TAILQ_FOREACH(mark, &(current->con->marks_head), marks) {
TAILQ_FOREACH (mark, &(current->con->marks_head), marks) {
if (!regex_matches(current_match->mark, mark->name))
continue;
@ -245,7 +245,7 @@ void cmd_criteria_match_windows(I3_CMD) {
}
}
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
}
}
@ -261,7 +261,7 @@ void cmd_criteria_add(I3_CMD, const char *ctype, const char *cvalue) {
static void move_matches_to_workspace(Con *ws) {
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
con_move_to_workspace(current->con, ws, true, false, false);
}
@ -524,7 +524,7 @@ static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *dir
/* Ensure all the other children have a percentage set. */
Con *child;
TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) {
TAILQ_FOREACH (child, &(current->parent->nodes_head), nodes) {
LOG("child->percent = %f (child %p)\n", child->percent, child);
if (child->percent == 0.0)
child->percent = percentage;
@ -549,7 +549,7 @@ static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *dir
LOG("subtract_percent = %f\n", subtract_percent);
/* Ensure that the new percentages are positive. */
if (subtract_percent >= 0.0) {
TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) {
TAILQ_FOREACH (child, &(current->parent->nodes_head), nodes) {
if (child == current) {
continue;
}
@ -563,7 +563,7 @@ static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *dir
current->percent = new_current_percent;
LOG("current->percent after = %f\n", current->percent);
TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) {
TAILQ_FOREACH (child, &(current->parent->nodes_head), nodes) {
if (child == current)
continue;
child->percent -= subtract_percent;
@ -587,7 +587,7 @@ void cmd_resize(I3_CMD, const char *way, const char *direction, long resize_px,
HANDLE_EMPTY_MATCH;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
/* Don't handle dock windows (issue #1201) */
if (current->con->window && current->con->window->dock) {
DLOG("This is a dock window. Not resizing (con = %p)\n)", current->con);
@ -667,7 +667,7 @@ void cmd_resize_set(I3_CMD, long cwidth, const char *mode_width, long cheight, c
owindow *current;
bool success = true;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
Con *floating_con;
if ((floating_con = con_inside_floating(current->con))) {
Con *output = con_get_output(floating_con);
@ -735,7 +735,7 @@ void cmd_border(I3_CMD, const char *border_style_str, long border_width) {
HANDLE_EMPTY_MATCH;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
border_style_t border_style;
@ -1006,7 +1006,7 @@ void cmd_unmark(I3_CMD, const char *mark) {
con_unmark(NULL, mark);
} else {
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
con_unmark(current->con, mark);
}
}
@ -1038,7 +1038,7 @@ void cmd_move_con_to_output(I3_CMD, const char *name) {
owindow *current;
bool had_error = false;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
had_error |= !con_move_to_output_name(current->con, name, true);
@ -1059,7 +1059,7 @@ void cmd_move_con_to_mark(I3_CMD, const char *mark) {
bool result = true;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("moving matched window %p / %s to mark \"%s\"\n", current->con, current->con->name, mark);
result &= con_move_to_mark(current->con, mark);
}
@ -1079,7 +1079,7 @@ void cmd_floating(I3_CMD, const char *floating_mode) {
HANDLE_EMPTY_MATCH;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
if (strcmp(floating_mode, "toggle") == 0) {
DLOG("should toggle mode\n");
@ -1109,7 +1109,7 @@ void cmd_move_workspace_to_output(I3_CMD, const char *name) {
HANDLE_EMPTY_MATCH;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
Con *ws = con_get_workspace(current->con);
if (con_is_internal(ws)) {
continue;
@ -1138,7 +1138,7 @@ void cmd_split(I3_CMD, const char *direction) {
owindow *current;
LOG("splitting in direction %c\n", direction[0]);
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
if (con_is_docked(current->con)) {
ELOG("Cannot split a docked container, skipping.\n");
continue;
@ -1191,7 +1191,7 @@ void cmd_kill(I3_CMD, const char *kill_mode_str) {
HANDLE_EMPTY_MATCH;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
con_close(current->con, kill_mode);
}
@ -1211,7 +1211,7 @@ void cmd_exec(I3_CMD, const char *nosn, const char *command) {
int count = 0;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
count++;
}
@ -1221,7 +1221,7 @@ void cmd_exec(I3_CMD, const char *nosn, const char *command) {
count);
}
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("should execute %s, no_startup_id = %d\n", command, no_startup_id);
start_application(command, no_startup_id);
}
@ -1233,7 +1233,7 @@ void cmd_exec(I3_CMD, const char *nosn, const char *command) {
do { \
int count = 0; \
owindow *current; \
TAILQ_FOREACH(current, &owindows, owindows) { \
TAILQ_FOREACH (current, &owindows, owindows) { \
count++; \
} \
\
@ -1265,7 +1265,7 @@ void cmd_focus_direction(I3_CMD, const char *direction_str) {
}
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
Con *ws = con_get_workspace(current->con);
if (!ws || con_is_internal(ws)) {
continue;
@ -1292,7 +1292,7 @@ void cmd_focus_sibling(I3_CMD, const char *direction_str) {
const position_t direction = (STARTS_WITH(direction_str, "prev")) ? BEFORE : AFTER;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
Con *ws = con_get_workspace(current->con);
if (!ws || con_is_internal(ws)) {
continue;
@ -1327,7 +1327,7 @@ void cmd_focus_window_mode(I3_CMD, const char *window_mode) {
Con *ws = con_get_workspace(focused);
Con *current;
bool success = false;
TAILQ_FOREACH(current, &(ws->focus_head), focused) {
TAILQ_FOREACH (current, &(ws->focus_head), focused) {
if ((to_floating && current->type != CT_FLOATING_CON) ||
(!to_floating && current->type == CT_FLOATING_CON))
continue;
@ -1395,7 +1395,7 @@ void cmd_focus(I3_CMD) {
Con *__i3_scratch = workspace_get("__i3_scratch", NULL);
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
Con *ws = con_get_workspace(current->con);
/* If no workspace could be found, this was a dock window.
* Just skip it, you cannot focus dock windows. */
@ -1431,7 +1431,7 @@ void cmd_fullscreen(I3_CMD, const char *action, const char *fullscreen_mode) {
HANDLE_EMPTY_MATCH;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
if (strcmp(action, "toggle") == 0) {
con_toggle_fullscreen(current->con, mode);
@ -1456,7 +1456,7 @@ void cmd_sticky(I3_CMD, const char *action) {
HANDLE_EMPTY_MATCH;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
if (current->con->window == NULL) {
ELOG("only containers holding a window can be made sticky, skipping con = %p\n", current->con);
continue;
@ -1496,7 +1496,7 @@ void cmd_move_direction(I3_CMD, const char *direction_str, long move_px) {
Con *initially_focused = focused;
direction_t direction = parse_direction(direction_str);
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("moving in direction %s, px %ld\n", direction_str, move_px);
if (con_is_floating(current->con)) {
DLOG("floating move with %ld pixels\n", move_px);
@ -1550,7 +1550,7 @@ void cmd_layout(I3_CMD, const char *layout_str) {
DLOG("changing layout to %s (%d)\n", layout_str, layout);
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
if (con_is_docked(current->con)) {
ELOG("cannot change layout of a docked container, skipping it.\n");
continue;
@ -1581,7 +1581,7 @@ void cmd_layout_toggle(I3_CMD, const char *toggle_mode) {
if (match_is_empty(current_match))
con_toggle_layout(focused, toggle_mode);
else {
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
con_toggle_layout(current->con, toggle_mode);
}
@ -1715,7 +1715,7 @@ void cmd_move_window_to_position(I3_CMD, long x, long y) {
owindow *current;
HANDLE_EMPTY_MATCH;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
if (!con_is_floating(current->con)) {
ELOG("Cannot change position. The window/container is not floating\n");
@ -1752,7 +1752,7 @@ void cmd_move_window_to_center(I3_CMD, const char *method) {
HANDLE_EMPTY_MATCH;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
Con *floating_con = con_inside_floating(current->con);
if (floating_con == NULL) {
ELOG("con %p / %s is not floating, cannot move it to the center.\n",
@ -1795,7 +1795,7 @@ void cmd_move_window_to_mouse(I3_CMD) {
HANDLE_EMPTY_MATCH;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
Con *floating_con = con_inside_floating(current->con);
if (floating_con == NULL) {
DLOG("con %p / %s is not floating, cannot move it to the mouse position.\n",
@ -1821,7 +1821,7 @@ void cmd_move_scratchpad(I3_CMD) {
HANDLE_EMPTY_MATCH;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
scratchpad_move(current->con);
}
@ -1843,7 +1843,7 @@ void cmd_scratchpad_show(I3_CMD) {
if (match_is_empty(current_match)) {
result = scratchpad_show(NULL);
} else {
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
result |= scratchpad_show(current->con);
}
@ -1921,7 +1921,7 @@ void cmd_title_format(I3_CMD, const char *format) {
HANDLE_EMPTY_MATCH;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
TAILQ_FOREACH (current, &owindows, owindows) {
DLOG("setting title_format for %p / %s\n", current->con, current->con->name);
FREE(current->con->title_format);
@ -2011,7 +2011,7 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) {
/* Move the workspace to the correct output if it has an assignment */
struct Workspace_Assignment *assignment = NULL;
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
if (assignment->output == NULL)
continue;
if (strcmp(assignment->name, workspace->name) != 0 && (!name_is_digits(assignment->name) || ws_name_to_number(assignment->name) != workspace->num)) {
@ -2087,7 +2087,7 @@ static bool cmd_bar_mode(const char *bar_mode, const char *bar_id) {
bool changed_sth = false;
Barconfig *current = NULL;
TAILQ_FOREACH(current, &barconfigs, configs) {
TAILQ_FOREACH (current, &barconfigs, configs) {
if (bar_id && strcmp(current->id, bar_id) != 0)
continue;
@ -2130,7 +2130,7 @@ static bool cmd_bar_hidden_state(const char *bar_hidden_state, const char *bar_i
bool changed_sth = false;
Barconfig *current = NULL;
TAILQ_FOREACH(current, &barconfigs, configs) {
TAILQ_FOREACH (current, &barconfigs, configs) {
if (bar_id && strcmp(current->id, bar_id) != 0)
continue;

View File

@ -138,7 +138,7 @@ static void _con_attach(Con *con, Con *parent, Con *previous, bool ignore_focus)
} else {
if (!ignore_focus) {
/* Get the first tiling container in focus stack */
TAILQ_FOREACH(loop, &(parent->focus_head), focused) {
TAILQ_FOREACH (loop, &(parent->focus_head), focused) {
if (loop->type == CT_FLOATING_CON)
continue;
current = loop;
@ -404,7 +404,7 @@ bool con_is_sticky(Con *con) {
return true;
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (con_is_sticky(child))
return true;
}
@ -527,13 +527,13 @@ Con *con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode) {
TAILQ_REMOVE(&bfs_head, entry, entries);
free(entry);
TAILQ_FOREACH(child, &(current->nodes_head), nodes) {
TAILQ_FOREACH (child, &(current->nodes_head), nodes) {
entry = smalloc(sizeof(struct bfs_entry));
entry->con = child;
TAILQ_INSERT_TAIL(&bfs_head, entry, entries);
}
TAILQ_FOREACH(child, &(current->floating_head), floating_windows) {
TAILQ_FOREACH (child, &(current->floating_head), floating_windows) {
entry = smalloc(sizeof(struct bfs_entry));
entry->con = child;
TAILQ_INSERT_TAIL(&bfs_head, entry, entries);
@ -646,9 +646,11 @@ bool con_has_parent(Con *con, Con *parent) {
*/
Con *con_by_window_id(xcb_window_t window) {
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons)
if (con->window != NULL && con->window->id == window)
TAILQ_FOREACH (con, &all_cons, all_cons) {
if (con->window != NULL && con->window->id == window) {
return con;
}
}
return NULL;
}
@ -659,7 +661,7 @@ Con *con_by_window_id(xcb_window_t window) {
*/
Con *con_by_con_id(long target) {
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) {
TAILQ_FOREACH (con, &all_cons, all_cons) {
if (con == (Con *)target) {
return con;
}
@ -684,9 +686,11 @@ bool con_exists(Con *con) {
*/
Con *con_by_frame_id(xcb_window_t frame) {
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons)
if (con->frame.id == frame)
TAILQ_FOREACH (con, &all_cons, all_cons) {
if (con->frame.id == frame) {
return con;
}
}
return NULL;
}
@ -697,7 +701,7 @@ Con *con_by_frame_id(xcb_window_t frame) {
*/
Con *con_by_mark(const char *mark) {
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) {
TAILQ_FOREACH (con, &all_cons, all_cons) {
if (con_has_mark(con, mark))
return con;
}
@ -711,7 +715,7 @@ Con *con_by_mark(const char *mark) {
*/
bool con_has_mark(Con *con, const char *mark) {
mark_t *current;
TAILQ_FOREACH(current, &(con->marks_head), marks) {
TAILQ_FOREACH (current, &(con->marks_head), marks) {
if (strcmp(current->name, mark) == 0)
return true;
}
@ -774,7 +778,7 @@ void con_unmark(Con *con, const char *name) {
Con *current;
if (name == NULL) {
DLOG("Unmarking all containers.\n");
TAILQ_FOREACH(current, &all_cons, all_cons) {
TAILQ_FOREACH (current, &all_cons, all_cons) {
if (con != NULL && current != con)
continue;
@ -805,7 +809,7 @@ void con_unmark(Con *con, const char *name) {
current->mark_changed = true;
mark_t *mark;
TAILQ_FOREACH(mark, &(current->marks_head), marks) {
TAILQ_FOREACH (mark, &(current->marks_head), marks) {
if (strcmp(mark->name, name) != 0)
continue;
@ -830,8 +834,8 @@ Con *con_for_window(Con *con, i3Window *window, Match **store_match) {
//DLOG("searching con for window %p starting at con %p\n", window, con);
//DLOG("class == %s\n", window->class_class);
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH(match, &(child->swallow_head), matches) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (match, &(child->swallow_head), matches) {
if (!match_matches_window(match, window))
continue;
if (store_match != NULL)
@ -843,8 +847,8 @@ Con *con_for_window(Con *con, i3Window *window, Match **store_match) {
return result;
}
TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
TAILQ_FOREACH(match, &(child->swallow_head), matches) {
TAILQ_FOREACH (child, &(con->floating_head), floating_windows) {
TAILQ_FOREACH (match, &(child->swallow_head), matches) {
if (!match_matches_window(match, window))
continue;
if (store_match != NULL)
@ -863,7 +867,7 @@ static int num_focus_heads(Con *con) {
int focus_heads = 0;
Con *current;
TAILQ_FOREACH(current, &(con->focus_head), focused) {
TAILQ_FOREACH (current, &(con->focus_head), focused) {
focus_heads++;
}
@ -880,7 +884,7 @@ Con **get_focus_order(Con *con) {
Con **focus_order = smalloc(focus_heads * sizeof(Con *));
Con *current;
int idx = 0;
TAILQ_FOREACH(current, &(con->focus_head), focused) {
TAILQ_FOREACH (current, &(con->focus_head), focused) {
assert(idx < focus_heads);
focus_order[idx++] = current;
}
@ -923,8 +927,9 @@ int con_num_children(Con *con) {
Con *child;
int children = 0;
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
children++;
}
return children;
}
@ -940,7 +945,7 @@ int con_num_visible_children(Con *con) {
int children = 0;
Con *current = NULL;
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
/* Visible leaf nodes are a child. */
if (!con_is_hidden(current) && con_is_leaf(current))
children++;
@ -965,11 +970,11 @@ int con_num_windows(Con *con) {
int num = 0;
Con *current = NULL;
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
num += con_num_windows(current);
}
TAILQ_FOREACH(current, &(con->floating_head), floating_windows) {
TAILQ_FOREACH (current, &(con->floating_head), floating_windows) {
num += con_num_windows(current);
}
@ -990,7 +995,7 @@ void con_fix_percent(Con *con) {
// with a percentage set we have
double total = 0.0;
int children_with_percent = 0;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (child->percent > 0.0) {
total += child->percent;
++children_with_percent;
@ -1000,7 +1005,7 @@ void con_fix_percent(Con *con) {
// if there were children without a percentage set, set to a value that
// will make those children proportional to all others
if (children_with_percent != children) {
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (child->percent <= 0.0) {
if (children_with_percent == 0) {
total += (child->percent = 1.0);
@ -1014,11 +1019,11 @@ void con_fix_percent(Con *con) {
// if we got a zero, just distribute the space equally, otherwise
// distribute according to the proportions we got
if (total == 0.0) {
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
child->percent = 1.0 / children;
}
} else if (total != 1.0) {
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
child->percent /= total;
}
}
@ -1295,7 +1300,7 @@ static bool _con_move_to_con(Con *con, Con *target, bool behind_focused, bool fi
* delete it so child windows won't be created on the old workspace. */
if (!con_is_leaf(con)) {
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (!child->window)
continue;
startup_sequence_delete_by_window(child->window);
@ -1536,7 +1541,7 @@ Con *con_descend_tiling_focused(Con *con) {
return next;
do {
before = next;
TAILQ_FOREACH(child, &(next->focus_head), focused) {
TAILQ_FOREACH (child, &(next->focus_head), focused) {
if (child->type == CT_FLOATING_CON)
continue;
@ -1571,7 +1576,7 @@ Con *con_descend_direction(Con *con, direction_t direction) {
/* Wrong orientation. We use the last focused con. Within that con,
* we recurse to chose the left/right con or at least the last
* focused one. */
TAILQ_FOREACH(current, &(con->focus_head), focused) {
TAILQ_FOREACH (current, &(con->focus_head), focused) {
if (current->type != CT_FLOATING_CON) {
most = current;
break;
@ -1596,7 +1601,7 @@ Con *con_descend_direction(Con *con, direction_t direction) {
/* Wrong orientation. We use the last focused con. Within that con,
* we recurse to chose the top/bottom con or at least the last
* focused one. */
TAILQ_FOREACH(current, &(con->focus_head), focused) {
TAILQ_FOREACH (current, &(con->focus_head), focused) {
if (current->type != CT_FLOATING_CON) {
most = current;
break;
@ -2009,7 +2014,7 @@ Rect con_minimum_size(Con *con) {
if (con->layout == L_STACKED || con->layout == L_TABBED) {
uint32_t max_width = 0, max_height = 0, deco_height = 0;
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
Rect min = con_minimum_size(child);
deco_height += child->deco_rect.height;
max_width = max(max_width, min.width);
@ -2026,7 +2031,7 @@ Rect con_minimum_size(Con *con) {
if (con_is_split(con)) {
uint32_t width = 0, height = 0;
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
Rect min = con_minimum_size(child);
if (con->layout == L_SPLITH) {
width += min.width;
@ -2114,7 +2119,7 @@ bool con_has_urgent_child(Con *con) {
/* We are not interested in floating windows since they can only be
* attached to a workspace nodes_head instead of focus_head */
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (con_has_urgent_child(child))
return true;
}
@ -2236,7 +2241,7 @@ char *con_get_tree_representation(Con *con) {
/* 2) append representation of children */
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
char *child_txt = con_get_tree_representation(child);
char *tmp_buf;
@ -2454,7 +2459,7 @@ void con_merge_into(Con *old, Con *new) {
con_set_urgency(new, old->urgent);
mark_t *mark;
TAILQ_FOREACH(mark, &(old->marks_head), marks) {
TAILQ_FOREACH (mark, &(old->marks_head), marks) {
TAILQ_INSERT_TAIL(&(new->marks_head), mark, marks);
ipc_send_window_event("mark", new);
}

View File

@ -34,7 +34,7 @@ void ungrab_all_keys(xcb_connection_t *conn) {
*/
void update_barconfig(void) {
Barconfig *current;
TAILQ_FOREACH(current, &barconfigs, configs) {
TAILQ_FOREACH (current, &barconfigs, configs) {
ipc_send_barconfig_update_event(current);
}
}
@ -141,7 +141,7 @@ static void free_configuration(void) {
}
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) {
TAILQ_FOREACH (con, &all_cons, all_cons) {
/* Assignments changed, previously ran assignments are invalid. */
if (con->window) {
con->window->nr_assignments = 0;

View File

@ -128,7 +128,7 @@ CFGFUN(enter_mode, const char *pango_markup, const char *modename) {
}
struct Mode *mode;
SLIST_FOREACH(mode, &modes, modes) {
SLIST_FOREACH (mode, &modes, modes) {
if (strcmp(mode->name, modename) == 0) {
ELOG("The binding mode with name \"%s\" is defined at least twice.\n", modename);
}
@ -348,7 +348,7 @@ CFGFUN(workspace, const char *workspace, const char *output) {
if (workspace) {
FREE(current_workspace);
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
if (strcasecmp(assignment->name, workspace) == 0) {
ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
workspace);
@ -542,7 +542,7 @@ static void bar_configure_binding(const char *button, const char *release, const
const bool release_bool = release != NULL;
struct Barbinding *current;
TAILQ_FOREACH(current, &(current_bar->bar_bindings), bindings) {
TAILQ_FOREACH (current, &(current_bar->bar_bindings), bindings) {
if (current->input_code == input_code && current->release == release_bool) {
ELOG("command for button %s was already specified, ignoring.\n", button);
return;

View File

@ -820,7 +820,7 @@ void start_config_error_nagbar(const char *configpath, bool has_errors) {
*/
static void upsert_variable(struct variables_head *variables, char *key, char *value) {
struct Variable *current;
SLIST_FOREACH(current, variables, variables) {
SLIST_FOREACH (current, variables, variables) {
if (strcmp(current->key, key) != 0) {
continue;
}
@ -838,7 +838,7 @@ static void upsert_variable(struct variables_head *variables, char *key, char *v
new->value = sstrdup(value);
/* ensure that the correct variable is matched in case of one being
* the prefix of another */
SLIST_FOREACH(test, variables, variables) {
SLIST_FOREACH (test, variables, variables) {
if (strlen(new->key) >= strlen(test->key))
break;
loc = test;
@ -1013,7 +1013,7 @@ bool parse_file(const char *f, bool use_nagbar) {
* variables (otherwise we will count them twice, which is bad when
* 'extra' is negative) */
char *bufcopy = sstrdup(buf);
SLIST_FOREACH(current, &variables, variables) {
SLIST_FOREACH (current, &variables, variables) {
int extra = (strlen(current->value) - strlen(current->key));
char *next;
for (next = bufcopy;
@ -1033,11 +1033,12 @@ bool parse_file(const char *f, bool use_nagbar) {
destwalk = new;
while (walk < (buf + stbuf.st_size)) {
/* Find the next variable */
SLIST_FOREACH(current, &variables, variables)
SLIST_FOREACH (current, &variables, variables) {
current->next_match = strcasestr(walk, current->key);
}
nearest = NULL;
int distance = stbuf.st_size;
SLIST_FOREACH(current, &variables, variables) {
SLIST_FOREACH (current, &variables, variables) {
if (current->next_match == NULL)
continue;
if ((current->next_match - walk) < distance) {

View File

@ -12,8 +12,8 @@
xcb_window_t ewmh_window;
#define FOREACH_NONINTERNAL \
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) \
TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) \
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) \
TAILQ_FOREACH (ws, &(output_get_content(output)->nodes_head), nodes) \
if (!con_is_internal(ws))
/*
@ -125,13 +125,13 @@ static void ewmh_update_wm_desktop_recursively(Con *con, const uint32_t desktop)
Con *child;
/* Recursively call this to descend through the entire subtree. */
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
ewmh_update_wm_desktop_recursively(child, desktop);
}
/* If con is a workspace, we also need to go through the floating windows on it. */
if (con->type == CT_WORKSPACE) {
TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
TAILQ_FOREACH (child, &(con->floating_head), floating_windows) {
ewmh_update_wm_desktop_recursively(child, desktop);
}
}
@ -183,9 +183,9 @@ void ewmh_update_wm_desktop(void) {
uint32_t desktop = 0;
Con *output;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
Con *workspace;
TAILQ_FOREACH(workspace, &(output_get_content(output)->nodes_head), nodes) {
TAILQ_FOREACH (workspace, &(output_get_content(output)->nodes_head), nodes) {
ewmh_update_wm_desktop_recursively(workspace, desktop);
if (!con_is_internal(workspace)) {

View File

@ -18,9 +18,11 @@ static int num_screens;
*/
static Output *get_screen_at(unsigned int x, unsigned int y) {
Output *output;
TAILQ_FOREACH(output, &outputs, outputs)
if (output->rect.x == x && output->rect.y == y)
TAILQ_FOREACH (output, &outputs, outputs) {
if (output->rect.x == x && output->rect.y == y) {
return output;
}
}
return NULL;
}

View File

@ -24,7 +24,7 @@ static Rect total_outputs_dimensions(void) {
Output *output;
/* Use Rect to encapsulate dimensions, ignoring x/y */
Rect outputs_dimensions = {0, 0, 0, 0};
TAILQ_FOREACH(output, &outputs, outputs) {
TAILQ_FOREACH (output, &outputs, outputs) {
outputs_dimensions.height += output->rect.height;
outputs_dimensions.width += output->rect.width;
}
@ -39,7 +39,7 @@ static Rect total_outputs_dimensions(void) {
static void floating_set_hint_atom(Con *con, bool floating) {
if (!con_is_leaf(con)) {
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
floating_set_hint_atom(child, floating);
}
}
@ -328,7 +328,7 @@ void floating_enable(Con *con, bool automatic) {
if (rect_equals(nc->rect, (Rect){0, 0, 0, 0})) {
DLOG("Geometry not set, combining children\n");
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
DLOG("child geometry: %d x %d\n", child->geometry.width, child->geometry.height);
nc->rect.width += child->geometry.width;
nc->rect.height = max(nc->rect.height, child->geometry.height);

View File

@ -62,7 +62,7 @@ bool event_is_ignored(const int sequence, const int response_type) {
event = SLIST_NEXT(event, ignore_events);
}
SLIST_FOREACH(event, &ignore_events, ignore_events) {
SLIST_FOREACH (event, &ignore_events, ignore_events) {
if (event->sequence != sequence)
continue;
@ -160,13 +160,14 @@ static void handle_enter_notify(xcb_enter_notify_event_t *event) {
layout_t layout = (enter_child ? con->parent->layout : con->layout);
if (layout == L_DEFAULT) {
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (rect_contains(child->deco_rect, event->event_x, event->event_y)) {
LOG("using child %p / %s instead!\n", child, child->name);
con = child;
break;
}
}
}
if (config.disable_focus_follows_mouse)
return;
@ -216,7 +217,7 @@ static void handle_motion_notify(xcb_motion_notify_event_t *event) {
/* see over which rect the user is */
Con *current;
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
if (!rect_contains(current->deco_rect, event->event_x, event->event_y))
continue;

View File

@ -160,7 +160,7 @@ static void free_ipc_client(ipc_client *client, int exempt_fd) {
*/
void ipc_send_event(const char *event, uint32_t message_type, const char *payload) {
ipc_client *current;
TAILQ_FOREACH(current, &all_clients, clients) {
TAILQ_FOREACH (current, &all_clients, clients) {
for (int i = 0; i < current->num_events; i++) {
if (strcasecmp(current->events[i], event) == 0) {
ipc_send_client_message(current, strlen(payload), message_type, (uint8_t *)payload);
@ -415,7 +415,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
y(array_open);
mark_t *mark;
TAILQ_FOREACH(mark, &(con->marks_head), marks) {
TAILQ_FOREACH (mark, &(con->marks_head), marks) {
ystr(mark->name);
}
@ -595,7 +595,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
y(array_open);
Con *node;
if (con->type != CT_DOCKAREA || !inplace_restart) {
TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
TAILQ_FOREACH (node, &(con->nodes_head), nodes) {
dump_node(gen, node, inplace_restart);
}
}
@ -603,14 +603,14 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
ystr("floating_nodes");
y(array_open);
TAILQ_FOREACH(node, &(con->floating_head), floating_windows) {
TAILQ_FOREACH (node, &(con->floating_head), floating_windows) {
dump_node(gen, node, inplace_restart);
}
y(array_close);
ystr("focus");
y(array_open);
TAILQ_FOREACH(node, &(con->focus_head), focused) {
TAILQ_FOREACH (node, &(con->focus_head), focused) {
y(integer, (uintptr_t)node);
}
y(array_close);
@ -640,7 +640,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
ystr("swallows");
y(array_open);
Match *match;
TAILQ_FOREACH(match, &(con->swallow_head), matches) {
TAILQ_FOREACH (match, &(con->swallow_head), matches) {
/* We will generate a new restart_mode match specification after this
* loop, so skip this one. */
if (match->restart_mode)
@ -703,7 +703,7 @@ static void dump_bar_bindings(yajl_gen gen, Barconfig *config) {
y(array_open);
struct Barbinding *current;
TAILQ_FOREACH(current, &(config->bar_bindings), bindings) {
TAILQ_FOREACH (current, &(config->bar_bindings), bindings) {
y(map_open);
ystr("input_code");
@ -752,7 +752,7 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
y(array_open);
struct tray_output_t *tray_output;
TAILQ_FOREACH(tray_output, &(config->tray_outputs), tray_outputs) {
TAILQ_FOREACH (tray_output, &(config->tray_outputs), tray_outputs) {
ystr(canonicalize_output_name(tray_output->output));
}
@ -898,11 +898,11 @@ IPC_HANDLER(get_workspaces) {
Con *focused_ws = con_get_workspace(focused);
Con *output;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
if (con_is_internal(output))
continue;
Con *ws;
TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
TAILQ_FOREACH (ws, &(output_get_content(output)->nodes_head), nodes) {
assert(ws->type == CT_WORKSPACE);
y(map_open);
@ -963,7 +963,7 @@ IPC_HANDLER(get_outputs) {
y(array_open);
Output *output;
TAILQ_FOREACH(output, &outputs, outputs) {
TAILQ_FOREACH (output, &outputs, outputs) {
y(map_open);
ystr("name");
@ -1017,9 +1017,9 @@ IPC_HANDLER(get_marks) {
y(array_open);
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) {
TAILQ_FOREACH (con, &all_cons, all_cons) {
mark_t *mark;
TAILQ_FOREACH(mark, &(con->marks_head), marks) {
TAILQ_FOREACH (mark, &(con->marks_head), marks) {
ystr(mark->name);
}
}
@ -1079,7 +1079,7 @@ IPC_HANDLER(get_bar_config) {
if (message_size == 0) {
y(array_open);
Barconfig *current;
TAILQ_FOREACH(current, &barconfigs, configs) {
TAILQ_FOREACH (current, &barconfigs, configs) {
ystr(current->id);
}
y(array_close);
@ -1099,7 +1099,7 @@ IPC_HANDLER(get_bar_config) {
sasprintf(&bar_id, "%.*s", message_size, message);
LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
Barconfig *current, *config = NULL;
TAILQ_FOREACH(current, &barconfigs, configs) {
TAILQ_FOREACH (current, &barconfigs, configs) {
if (strcmp(current->id, bar_id) != 0)
continue;
@ -1138,7 +1138,7 @@ IPC_HANDLER(get_binding_modes) {
y(array_open);
struct Mode *mode;
SLIST_FOREACH(mode, &modes, modes) {
SLIST_FOREACH (mode, &modes, modes) {
ystr(mode->name);
}
y(array_close);

View File

@ -144,7 +144,7 @@ static int json_end_map(void *ctx) {
if (rect_equals(json_node->rect, (Rect){0, 0, 0, 0})) {
DLOG("Geometry not set, combining children\n");
Con *child;
TAILQ_FOREACH(child, &(json_node->nodes_head), nodes) {
TAILQ_FOREACH (child, &(json_node->nodes_head), nodes) {
DLOG("child geometry: %d x %d\n", child->geometry.width, child->geometry.height);
json_node->rect.width += child->geometry.width;
json_node->rect.height = max(json_node->rect.height, child->geometry.height);
@ -204,10 +204,10 @@ static int json_end_array(void *ctx) {
if (parsing_focus) {
/* Clear the list of focus mappings */
struct focus_mapping *mapping;
TAILQ_FOREACH_REVERSE(mapping, &focus_mappings, focus_mappings_head, focus_mappings) {
TAILQ_FOREACH_REVERSE (mapping, &focus_mappings, focus_mappings_head, focus_mappings) {
LOG("focus (reverse) %d\n", mapping->old_id);
Con *con;
TAILQ_FOREACH(con, &(json_node->focus_head), focused) {
TAILQ_FOREACH (con, &(json_node->focus_head), focused) {
if (con->old_id != mapping->old_id)
continue;
LOG("got it! %p\n", con);

View File

@ -785,9 +785,9 @@ int main(int argc, char *argv[]) {
* and restarting i3. See #2326. */
if (layout_path != NULL && randr_base > -1) {
Con *con;
TAILQ_FOREACH(con, &(croot->nodes_head), nodes) {
TAILQ_FOREACH (con, &(croot->nodes_head), nodes) {
Output *output;
TAILQ_FOREACH(output, &outputs, outputs) {
TAILQ_FOREACH (output, &outputs, outputs) {
if (output->active || strcmp(con->name, output_primary_name(output)) != 0)
continue;
@ -1010,7 +1010,7 @@ int main(int argc, char *argv[]) {
/* Start i3bar processes for all configured bars */
Barconfig *barconfig;
TAILQ_FOREACH(barconfig, &barconfigs, configs) {
TAILQ_FOREACH (barconfig, &barconfigs, configs) {
char *command = NULL;
sasprintf(&command, "%s %s --bar_id=%s --socket=\"%s\"",
barconfig->i3bar_command ? barconfig->i3bar_command : "exec i3bar",

View File

@ -83,7 +83,7 @@ void restore_geometry(void) {
DLOG("Restoring geometry\n");
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons)
TAILQ_FOREACH (con, &all_cons, all_cons) {
if (con->window) {
DLOG("Re-adding X11 border of %d px\n", con->border_width);
con->window_rect.width += (2 * con->border_width);
@ -93,6 +93,7 @@ void restore_geometry(void) {
xcb_reparent_window(conn, con->window->id, root,
con->rect.x, con->rect.y);
}
}
/* Strictly speaking, this line doesnt really belong here, but since we
* are syncing, lets un-register as a window manager first */

View File

@ -139,7 +139,7 @@ bool match_matches_window(Match *match, i3Window *window) {
return false;
}
/* if we find a window that is newer than this one, bail */
TAILQ_FOREACH(con, &all_cons, all_cons) {
TAILQ_FOREACH (con, &all_cons, all_cons) {
if ((con->window != NULL) &&
_i3_timercmp(con->window->urgent, window->urgent, >)) {
return false;
@ -154,7 +154,7 @@ bool match_matches_window(Match *match, i3Window *window) {
return false;
}
/* if we find a window that is older than this one (and not 0), bail */
TAILQ_FOREACH(con, &all_cons, all_cons) {
TAILQ_FOREACH (con, &all_cons, all_cons) {
if ((con->window != NULL) &&
(con->window->urgent.tv_sec != 0) &&
_i3_timercmp(con->window->urgent, window->urgent, <)) {
@ -201,7 +201,7 @@ bool match_matches_window(Match *match, i3Window *window) {
bool matched = false;
mark_t *mark;
TAILQ_FOREACH(mark, &(con->marks_head), marks) {
TAILQ_FOREACH (mark, &(con->marks_head), marks) {
if (regex_matches(match->mark, mark->name)) {
matched = true;
break;

View File

@ -91,7 +91,7 @@ void insert_con_into(Con *con, Con *target, position_t position) {
} else {
/* Look at the focus stack order of the children of the lowest common ancestor. */
Con *current;
TAILQ_FOREACH(current, &(lca->focus_head), focused) {
TAILQ_FOREACH (current, &(lca->focus_head), focused) {
if (current == con_ancestor || current == target_ancestor) {
break;
}

View File

@ -16,9 +16,11 @@
Con *output_get_content(Con *output) {
Con *child;
TAILQ_FOREACH(child, &(output->nodes_head), nodes)
if (child->type == CT_CON)
TAILQ_FOREACH (child, &(output->nodes_head), nodes) {
if (child->type == CT_CON) {
return child;
}
}
return NULL;
}
@ -74,7 +76,7 @@ Output *get_output_for_con(Con *con) {
*/
void output_push_sticky_windows(Con *old_focus) {
Con *output;
TAILQ_FOREACH(output, &(croot->focus_head), focused) {
TAILQ_FOREACH (output, &(croot->focus_head), focused) {
Con *workspace, *visible_ws = NULL;
GREP_FIRST(visible_ws, output_get_content(output), workspace_is_visible(child));

View File

@ -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)
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);

View File

@ -108,7 +108,7 @@ void render_con(Con *con) {
render_root(con, fullscreen);
} else {
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
assert(params.children > 0);
if (con->layout == L_SPLITH || con->layout == L_SPLITV) {
@ -130,8 +130,9 @@ void render_con(Con *con) {
/* in a stacking or tabbed container, we ensure the focused client is raised */
if (con->layout == L_STACKED || con->layout == L_TABBED) {
TAILQ_FOREACH_REVERSE(child, &(con->focus_head), focus_head, focused)
TAILQ_FOREACH_REVERSE (child, &(con->focus_head), focus_head, focused) {
x_raise_con(child);
}
if ((child = TAILQ_FIRST(&(con->focus_head)))) {
/* By rendering the stacked container again, we handle the case
* that we have a non-leaf-container inside the stack. In that
@ -164,7 +165,7 @@ static int *precalculate_sizes(Con *con, render_params *p) {
Con *child;
int i = 0, assigned = 0;
int total = con_rect_size_in_orientation(con);
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
double percentage = child->percent > 0.0 ? child->percent : 1.0 / p->children;
assigned += sizes[i++] = lround(percentage * total);
}
@ -185,7 +186,7 @@ static int *precalculate_sizes(Con *con, render_params *p) {
static void render_root(Con *con, Con *fullscreen) {
Con *output;
if (!fullscreen) {
TAILQ_FOREACH(output, &(con->nodes_head), nodes) {
TAILQ_FOREACH (output, &(con->nodes_head), nodes) {
render_con(output);
}
}
@ -195,7 +196,7 @@ static void render_root(Con *con, Con *fullscreen) {
* all times. This is important when the user places floating
* windows/containers so that they overlap on another output. */
DLOG("Rendering floating windows:\n");
TAILQ_FOREACH(output, &(con->nodes_head), nodes) {
TAILQ_FOREACH (output, &(con->nodes_head), nodes) {
if (con_is_internal(output))
continue;
/* Get the active workspace of that output */
@ -207,7 +208,7 @@ static void render_root(Con *con, Con *fullscreen) {
Con *workspace = TAILQ_FIRST(&(content->focus_head));
Con *fullscreen = con_get_fullscreen_covering_ws(workspace);
Con *child;
TAILQ_FOREACH(child, &(workspace->floating_head), floating_windows) {
TAILQ_FOREACH (child, &(workspace->floating_head), floating_windows) {
if (fullscreen != NULL) {
/* Dont render floating windows when there is a fullscreen
* window on that workspace. Necessary to make floating
@ -272,7 +273,7 @@ static void render_output(Con *con) {
/* Find the content container and ensure that there is exactly one. Also
* check for any non-CT_DOCKAREA clients. */
Con *content = NULL;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (child->type == CT_CON) {
if (content != NULL) {
DLOG("More than one CT_CON on output container\n");
@ -308,19 +309,20 @@ static void render_output(Con *con) {
/* First pass: determine the height of all CT_DOCKAREAs (the sum of their
* children) and figure out how many pixels we have left for the rest */
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (child->type != CT_DOCKAREA)
continue;
child->rect.height = 0;
TAILQ_FOREACH(dockchild, &(child->nodes_head), nodes)
TAILQ_FOREACH (dockchild, &(child->nodes_head), nodes) {
child->rect.height += dockchild->geometry.height;
}
height -= child->rect.height;
}
/* Second pass: Set the widths/heights */
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
if (child->type == CT_CON) {
child->rect.x = x;
child->rect.y = y;

View File

@ -140,7 +140,7 @@ static void update_placeholder_contents(placeholder_state *state) {
Match *swallows;
int n = 0;
TAILQ_FOREACH(swallows, &(state->con->swallow_head), matches) {
TAILQ_FOREACH (swallows, &(state->con->swallow_head), matches) {
char *serialized = NULL;
#define APPEND_REGEX(re_name) \
@ -234,10 +234,10 @@ static void open_placeholder_window(Con *con) {
}
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
open_placeholder_window(child);
}
TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
TAILQ_FOREACH (child, &(con->floating_head), floating_windows) {
open_placeholder_window(child);
}
}
@ -251,10 +251,10 @@ static void open_placeholder_window(Con *con) {
*/
void restore_open_placeholder_windows(Con *parent) {
Con *child;
TAILQ_FOREACH(child, &(parent->nodes_head), nodes) {
TAILQ_FOREACH (child, &(parent->nodes_head), nodes) {
open_placeholder_window(child);
}
TAILQ_FOREACH(child, &(parent->floating_head), floating_windows) {
TAILQ_FOREACH (child, &(parent->floating_head), floating_windows) {
open_placeholder_window(child);
}
@ -270,7 +270,7 @@ void restore_open_placeholder_windows(Con *parent) {
*/
bool restore_kill_placeholder(xcb_window_t placeholder) {
placeholder_state *state;
TAILQ_FOREACH(state, &state_head, state) {
TAILQ_FOREACH (state, &state_head, state) {
if (state->window != placeholder)
continue;
@ -288,7 +288,7 @@ bool restore_kill_placeholder(xcb_window_t placeholder) {
static void expose_event(xcb_expose_event_t *event) {
placeholder_state *state;
TAILQ_FOREACH(state, &state_head, state) {
TAILQ_FOREACH (state, &state_head, state) {
if (state->window != event->window)
continue;
@ -310,7 +310,7 @@ static void expose_event(xcb_expose_event_t *event) {
*/
static void configure_notify(xcb_configure_notify_event_t *event) {
placeholder_state *state;
TAILQ_FOREACH(state, &state_head, state) {
TAILQ_FOREACH (state, &state_head, state) {
if (state->window != event->window)
continue;

View File

@ -112,7 +112,7 @@ bool scratchpad_show(Con *con) {
* unfocused scratchpad on the current workspace and focus it */
Con *walk_con;
Con *focused_ws = con_get_workspace(focused);
TAILQ_FOREACH(walk_con, &(focused_ws->floating_head), floating_windows) {
TAILQ_FOREACH (walk_con, &(focused_ws->floating_head), floating_windows) {
if (!con && (floating = con_inside_floating(walk_con)) &&
floating->scratchpad_state != SCRATCHPAD_NONE &&
floating != con_inside_floating(focused)) {
@ -130,7 +130,7 @@ bool scratchpad_show(Con *con) {
* visible scratchpad window on another workspace. In this case we move it
* to the current workspace. */
focused_ws = con_get_workspace(focused);
TAILQ_FOREACH(walk_con, &all_cons, all_cons) {
TAILQ_FOREACH (walk_con, &all_cons, all_cons) {
Con *walk_ws = con_get_workspace(walk_con);
if (!con && walk_ws &&
!con_is_internal(walk_ws) && focused_ws != walk_ws &&
@ -253,7 +253,7 @@ void scratchpad_fix_resolution(void) {
Con *output;
int new_width = -1,
new_height = -1;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
if (output == __i3_output)
continue;
DLOG("output %s's resolution: (%d, %d) %d x %d\n",
@ -284,7 +284,7 @@ void scratchpad_fix_resolution(void) {
DLOG("Fixing coordinates of scratchpad windows\n");
Con *con;
TAILQ_FOREACH(con, &(__i3_scratch->floating_head), floating_windows) {
TAILQ_FOREACH (con, &(__i3_scratch->floating_head), floating_windows) {
floating_fix_coordinates(con, &old_rect, &new_rect);
}
}

View File

@ -155,7 +155,7 @@ static void sighandler_setup(void) {
static void sighandler_create_dialogs(void) {
Output *output;
TAILQ_FOREACH(output, &outputs, outputs) {
TAILQ_FOREACH (output, &outputs, outputs) {
if (!output->active) {
continue;
}
@ -230,7 +230,7 @@ static void sighandler_destroy_dialogs(void) {
static void sighandler_handle_expose(void) {
dialog_t *current;
TAILQ_FOREACH(current, &dialogs, dialogs) {
TAILQ_FOREACH (current, &dialogs, dialogs) {
sighandler_draw_dialog(current);
}

View File

@ -36,7 +36,7 @@ static void startup_timeout(EV_P_ ev_timer *w, int revents) {
DLOG("Timeout for startup sequence %s\n", id);
struct Startup_Sequence *current, *sequence = NULL;
TAILQ_FOREACH(current, &startup_sequences, sequences) {
TAILQ_FOREACH (current, &startup_sequences, sequences) {
if (strcmp(current->id, id) != 0)
continue;
@ -220,7 +220,7 @@ void startup_monitor_event(SnMonitorEvent *event, void *userdata) {
/* Get the corresponding internal startup sequence */
const char *id = sn_startup_sequence_get_id(snsequence);
struct Startup_Sequence *current, *sequence = NULL;
TAILQ_FOREACH(current, &startup_sequences, sequences) {
TAILQ_FOREACH (current, &startup_sequences, sequences) {
if (strcmp(current->id, id) != 0)
continue;
@ -264,7 +264,7 @@ void startup_monitor_event(SnMonitorEvent *event, void *userdata) {
*/
void startup_sequence_rename_workspace(const char *old_name, const char *new_name) {
struct Startup_Sequence *current;
TAILQ_FOREACH(current, &startup_sequences, sequences) {
TAILQ_FOREACH (current, &startup_sequences, sequences) {
if (strcmp(current->workspace, old_name) != 0)
continue;
DLOG("Renaming workspace \"%s\" to \"%s\" in startup sequence %s.\n",
@ -320,7 +320,7 @@ struct Startup_Sequence *startup_sequence_get(i3Window *cwindow,
sasprintf(&startup_id, "%.*s", xcb_get_property_value_length(startup_id_reply),
(char *)xcb_get_property_value(startup_id_reply));
struct Startup_Sequence *current, *sequence = NULL;
TAILQ_FOREACH(current, &startup_sequences, sequences) {
TAILQ_FOREACH (current, &startup_sequences, sequences) {
if (strcmp(current->id, startup_id) != 0)
continue;

View File

@ -431,14 +431,16 @@ static void mark_unmapped(Con *con) {
Con *current;
con->mapped = false;
TAILQ_FOREACH(current, &(con->nodes_head), nodes)
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
mark_unmapped(current);
}
if (con->type == CT_WORKSPACE) {
/* We need to call mark_unmapped on floating nodes as well since we can
* make containers floating. */
TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
TAILQ_FOREACH (current, &(con->floating_head), floating_windows) {
mark_unmapped(current);
}
}
}
/*

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)
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))
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))
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;
}

46
src/x.c
View File

@ -92,9 +92,11 @@ initial_mapping_head =
*/
static con_state *state_for_frame(xcb_window_t window) {
con_state *state;
CIRCLEQ_FOREACH(state, &state_head, state)
if (state->id == window)
CIRCLEQ_FOREACH (state, &state_head, state) {
if (state->id == window) {
return state;
}
}
/* TODO: better error handling? */
ELOG("No state found for window 0x%08x\n", window);
@ -624,7 +626,7 @@ void x_draw_decoration(Con *con) {
bool had_visible_mark = false;
mark_t *mark;
TAILQ_FOREACH(mark, &(con->marks_head), marks) {
TAILQ_FOREACH (mark, &(con->marks_head), marks) {
if (mark->name[0] == '_')
continue;
had_visible_mark = true;
@ -726,11 +728,13 @@ void x_deco_recurse(Con *con) {
con_state *state = state_for_frame(con->frame.id);
if (!leaf) {
TAILQ_FOREACH(current, &(con->nodes_head), nodes)
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
x_deco_recurse(current);
}
TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
TAILQ_FOREACH (current, &(con->floating_head), floating_windows) {
x_deco_recurse(current);
}
if (state->mapped) {
draw_util_copy_surface(&(con->frame_buffer), &(con->frame), 0, 0, 0, 0, con->rect.width, con->rect.height);
@ -858,7 +862,7 @@ void x_push_node(Con *con) {
/* Calculate the height of all window decorations which will be drawn on to
* this frame. */
uint32_t max_y = 0, max_height = 0;
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
Rect *dr = &(current->deco_rect);
if (dr->y >= max_y && dr->height >= max_height) {
max_y = dr->y;
@ -1070,7 +1074,7 @@ void x_push_node(Con *con) {
/* Handle all children and floating windows of this node. We recurse
* in focus order to display the focused client in a stack first when
* switching workspaces (reduces flickering). */
TAILQ_FOREACH(current, &(con->focus_head), focused) {
TAILQ_FOREACH (current, &(con->focus_head), focused) {
x_push_node(current);
}
}
@ -1116,11 +1120,13 @@ static void x_push_node_unmaps(Con *con) {
}
/* handle all children and floating windows of this node */
TAILQ_FOREACH(current, &(con->nodes_head), nodes)
TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
x_push_node_unmaps(current);
}
TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
TAILQ_FOREACH (current, &(con->floating_head), floating_windows) {
x_push_node_unmaps(current);
}
}
/*
@ -1133,7 +1139,7 @@ static bool is_con_attached(Con *con) {
return false;
Con *current;
TAILQ_FOREACH(current, &(con->parent->nodes_head), nodes) {
TAILQ_FOREACH (current, &(con->parent->nodes_head), nodes) {
if (current == con)
return true;
}
@ -1167,7 +1173,7 @@ void x_push_changes(Con *con) {
* ConfigureWindow requests and get them applied directly instead of having
* them become ConfigureRequests that i3 handles. */
uint32_t values[1] = {XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT};
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
if (state->mapped)
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
}
@ -1178,9 +1184,11 @@ void x_push_changes(Con *con) {
/* count first, necessary to (re)allocate memory for the bottom-to-top
* stack afterwards */
int cnt = 0;
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state)
if (con_has_managed_window(state->con))
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
if (con_has_managed_window(state->con)) {
cnt++;
}
}
/* The bottom-to-top window stack of all windows which are managed by i3.
* Used for x_get_window_stack(). */
@ -1195,7 +1203,7 @@ void x_push_changes(Con *con) {
xcb_window_t *walk = client_list_windows;
/* X11 correctly represents the stack if we push it from bottom to top */
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
if (con_has_managed_window(state->con))
memcpy(walk++, &(state->con->window->id), sizeof(xcb_window_t));
@ -1226,7 +1234,7 @@ void x_push_changes(Con *con) {
walk = client_list_windows;
/* reorder by initial mapping */
TAILQ_FOREACH(state, &initial_mapping_head, initial_mapping_order) {
TAILQ_FOREACH (state, &initial_mapping_head, initial_mapping_order) {
if (con_has_managed_window(state->con))
*walk++ = state->con->window->id;
}
@ -1261,7 +1269,7 @@ void x_push_changes(Con *con) {
//DLOG("Re-enabling EnterNotify\n");
values[0] = FRAME_EVENT_MASK;
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
if (state->mapped)
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
}
@ -1337,7 +1345,7 @@ void x_push_changes(Con *con) {
* unmapped, the second one appears under the cursor and therefore gets an
* EnterNotify event. */
values[0] = FRAME_EVENT_MASK & ~XCB_EVENT_MASK_ENTER_WINDOW;
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
if (!state->unmap_now)
continue;
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
@ -1347,7 +1355,7 @@ void x_push_changes(Con *con) {
x_push_node_unmaps(con);
/* save the current stack as old stack */
CIRCLEQ_FOREACH(state, &state_head, state) {
CIRCLEQ_FOREACH (state, &state_head, state) {
CIRCLEQ_REMOVE(&old_state_head, state, old_state);
CIRCLEQ_INSERT_TAIL(&old_state_head, state, old_state);
}
@ -1439,7 +1447,7 @@ void x_mask_event_mask(uint32_t mask) {
uint32_t values[] = {FRAME_EVENT_MASK & mask};
con_state *state;
CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
if (state->mapped)
xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
}

View File

@ -21,9 +21,11 @@ static int num_screens;
*/
static Output *get_screen_at(unsigned int x, unsigned int y) {
Output *output;
TAILQ_FOREACH(output, &outputs, outputs)
if (output->rect.x == x && output->rect.y == y)
TAILQ_FOREACH (output, &outputs, outputs) {
if (output->rect.x == x && output->rect.y == y) {
return output;
}
}
return NULL;
}