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 ColumnLimit: 0
SpaceBeforeParens: ControlStatements SpaceBeforeParens: ControlStatements
SortIncludes: false 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) { static void copy_statusline(struct statusline_head *from, struct statusline_head *to) {
struct status_block *current; struct status_block *current;
TAILQ_FOREACH(current, from, blocks) { TAILQ_FOREACH (current, from, blocks) {
struct status_block *new_block = smalloc(sizeof(struct status_block)); struct status_block *new_block = smalloc(sizeof(struct status_block));
memcpy(new_block, current, sizeof(struct status_block)); memcpy(new_block, current, sizeof(struct status_block));
TAILQ_INSERT_TAIL(to, new_block, blocks); TAILQ_INSERT_TAIL(to, new_block, blocks);
@ -330,7 +330,7 @@ static int stdin_end_array(void *context) {
DLOG("dumping statusline:\n"); DLOG("dumping statusline:\n");
struct status_block *current; 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("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("short_text = %s\n", (current->short_text == NULL ? NULL : i3string_as_utf8(current->short_text)));
DLOG("color = %s\n", current->color); DLOG("color = %s\n", current->color);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -128,7 +128,7 @@ CFGFUN(enter_mode, const char *pango_markup, const char *modename) {
} }
struct Mode *mode; struct Mode *mode;
SLIST_FOREACH(mode, &modes, modes) { SLIST_FOREACH (mode, &modes, modes) {
if (strcmp(mode->name, modename) == 0) { if (strcmp(mode->name, modename) == 0) {
ELOG("The binding mode with name \"%s\" is defined at least twice.\n", modename); 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) { if (workspace) {
FREE(current_workspace); FREE(current_workspace);
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) { TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
if (strcasecmp(assignment->name, workspace) == 0) { if (strcasecmp(assignment->name, workspace) == 0) {
ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n", ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
workspace); workspace);
@ -542,7 +542,7 @@ static void bar_configure_binding(const char *button, const char *release, const
const bool release_bool = release != NULL; const bool release_bool = release != NULL;
struct Barbinding *current; 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) { if (current->input_code == input_code && current->release == release_bool) {
ELOG("command for button %s was already specified, ignoring.\n", button); ELOG("command for button %s was already specified, ignoring.\n", button);
return; 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) { static void upsert_variable(struct variables_head *variables, char *key, char *value) {
struct Variable *current; struct Variable *current;
SLIST_FOREACH(current, variables, variables) { SLIST_FOREACH (current, variables, variables) {
if (strcmp(current->key, key) != 0) { if (strcmp(current->key, key) != 0) {
continue; continue;
} }
@ -838,7 +838,7 @@ static void upsert_variable(struct variables_head *variables, char *key, char *v
new->value = sstrdup(value); new->value = sstrdup(value);
/* ensure that the correct variable is matched in case of one being /* ensure that the correct variable is matched in case of one being
* the prefix of another */ * the prefix of another */
SLIST_FOREACH(test, variables, variables) { SLIST_FOREACH (test, variables, variables) {
if (strlen(new->key) >= strlen(test->key)) if (strlen(new->key) >= strlen(test->key))
break; break;
loc = test; 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 * variables (otherwise we will count them twice, which is bad when
* 'extra' is negative) */ * 'extra' is negative) */
char *bufcopy = sstrdup(buf); char *bufcopy = sstrdup(buf);
SLIST_FOREACH(current, &variables, variables) { SLIST_FOREACH (current, &variables, variables) {
int extra = (strlen(current->value) - strlen(current->key)); int extra = (strlen(current->value) - strlen(current->key));
char *next; char *next;
for (next = bufcopy; for (next = bufcopy;
@ -1033,11 +1033,12 @@ bool parse_file(const char *f, bool use_nagbar) {
destwalk = new; destwalk = new;
while (walk < (buf + stbuf.st_size)) { while (walk < (buf + stbuf.st_size)) {
/* Find the next variable */ /* Find the next variable */
SLIST_FOREACH(current, &variables, variables) SLIST_FOREACH (current, &variables, variables) {
current->next_match = strcasestr(walk, current->key); current->next_match = strcasestr(walk, current->key);
}
nearest = NULL; nearest = NULL;
int distance = stbuf.st_size; int distance = stbuf.st_size;
SLIST_FOREACH(current, &variables, variables) { SLIST_FOREACH (current, &variables, variables) {
if (current->next_match == NULL) if (current->next_match == NULL)
continue; continue;
if ((current->next_match - walk) < distance) { if ((current->next_match - walk) < distance) {

View File

@ -12,8 +12,8 @@
xcb_window_t ewmh_window; xcb_window_t ewmh_window;
#define FOREACH_NONINTERNAL \ #define FOREACH_NONINTERNAL \
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) \ TAILQ_FOREACH (output, &(croot->nodes_head), nodes) \
TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) \ TAILQ_FOREACH (ws, &(output_get_content(output)->nodes_head), nodes) \
if (!con_is_internal(ws)) if (!con_is_internal(ws))
/* /*
@ -125,13 +125,13 @@ static void ewmh_update_wm_desktop_recursively(Con *con, const uint32_t desktop)
Con *child; Con *child;
/* Recursively call this to descend through the entire subtree. */ /* 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); 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 is a workspace, we also need to go through the floating windows on it. */
if (con->type == CT_WORKSPACE) { 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); ewmh_update_wm_desktop_recursively(child, desktop);
} }
} }
@ -183,9 +183,9 @@ void ewmh_update_wm_desktop(void) {
uint32_t desktop = 0; uint32_t desktop = 0;
Con *output; Con *output;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) { TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
Con *workspace; 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); ewmh_update_wm_desktop_recursively(workspace, desktop);
if (!con_is_internal(workspace)) { 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) { static Output *get_screen_at(unsigned int x, unsigned int y) {
Output *output; Output *output;
TAILQ_FOREACH(output, &outputs, outputs) TAILQ_FOREACH (output, &outputs, outputs) {
if (output->rect.x == x && output->rect.y == y) if (output->rect.x == x && output->rect.y == y) {
return output; return output;
}
}
return NULL; return NULL;
} }

View File

@ -24,7 +24,7 @@ static Rect total_outputs_dimensions(void) {
Output *output; Output *output;
/* Use Rect to encapsulate dimensions, ignoring x/y */ /* Use Rect to encapsulate dimensions, ignoring x/y */
Rect outputs_dimensions = {0, 0, 0, 0}; 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.height += output->rect.height;
outputs_dimensions.width += output->rect.width; 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) { static void floating_set_hint_atom(Con *con, bool floating) {
if (!con_is_leaf(con)) { if (!con_is_leaf(con)) {
Con *child; Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) { TAILQ_FOREACH (child, &(con->nodes_head), nodes) {
floating_set_hint_atom(child, floating); 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})) { if (rect_equals(nc->rect, (Rect){0, 0, 0, 0})) {
DLOG("Geometry not set, combining children\n"); DLOG("Geometry not set, combining children\n");
Con *child; 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); DLOG("child geometry: %d x %d\n", child->geometry.width, child->geometry.height);
nc->rect.width += child->geometry.width; nc->rect.width += child->geometry.width;
nc->rect.height = max(nc->rect.height, child->geometry.height); 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); event = SLIST_NEXT(event, ignore_events);
} }
SLIST_FOREACH(event, &ignore_events, ignore_events) { SLIST_FOREACH (event, &ignore_events, ignore_events) {
if (event->sequence != sequence) if (event->sequence != sequence)
continue; 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); layout_t layout = (enter_child ? con->parent->layout : con->layout);
if (layout == L_DEFAULT) { if (layout == L_DEFAULT) {
Con *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)) { if (rect_contains(child->deco_rect, event->event_x, event->event_y)) {
LOG("using child %p / %s instead!\n", child, child->name); LOG("using child %p / %s instead!\n", child, child->name);
con = child; con = child;
break; break;
} }
} }
}
if (config.disable_focus_follows_mouse) if (config.disable_focus_follows_mouse)
return; return;
@ -216,7 +217,7 @@ static void handle_motion_notify(xcb_motion_notify_event_t *event) {
/* see over which rect the user is */ /* see over which rect the user is */
Con *current; 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)) if (!rect_contains(current->deco_rect, event->event_x, event->event_y))
continue; 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) { void ipc_send_event(const char *event, uint32_t message_type, const char *payload) {
ipc_client *current; ipc_client *current;
TAILQ_FOREACH(current, &all_clients, clients) { TAILQ_FOREACH (current, &all_clients, clients) {
for (int i = 0; i < current->num_events; i++) { for (int i = 0; i < current->num_events; i++) {
if (strcasecmp(current->events[i], event) == 0) { if (strcasecmp(current->events[i], event) == 0) {
ipc_send_client_message(current, strlen(payload), message_type, (uint8_t *)payload); 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); y(array_open);
mark_t *mark; mark_t *mark;
TAILQ_FOREACH(mark, &(con->marks_head), marks) { TAILQ_FOREACH (mark, &(con->marks_head), marks) {
ystr(mark->name); ystr(mark->name);
} }
@ -595,7 +595,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
y(array_open); y(array_open);
Con *node; Con *node;
if (con->type != CT_DOCKAREA || !inplace_restart) { 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); 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"); ystr("floating_nodes");
y(array_open); 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); dump_node(gen, node, inplace_restart);
} }
y(array_close); y(array_close);
ystr("focus"); ystr("focus");
y(array_open); y(array_open);
TAILQ_FOREACH(node, &(con->focus_head), focused) { TAILQ_FOREACH (node, &(con->focus_head), focused) {
y(integer, (uintptr_t)node); y(integer, (uintptr_t)node);
} }
y(array_close); y(array_close);
@ -640,7 +640,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
ystr("swallows"); ystr("swallows");
y(array_open); y(array_open);
Match *match; 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 /* We will generate a new restart_mode match specification after this
* loop, so skip this one. */ * loop, so skip this one. */
if (match->restart_mode) if (match->restart_mode)
@ -703,7 +703,7 @@ static void dump_bar_bindings(yajl_gen gen, Barconfig *config) {
y(array_open); y(array_open);
struct Barbinding *current; struct Barbinding *current;
TAILQ_FOREACH(current, &(config->bar_bindings), bindings) { TAILQ_FOREACH (current, &(config->bar_bindings), bindings) {
y(map_open); y(map_open);
ystr("input_code"); ystr("input_code");
@ -752,7 +752,7 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
y(array_open); y(array_open);
struct tray_output_t *tray_output; 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)); ystr(canonicalize_output_name(tray_output->output));
} }
@ -898,11 +898,11 @@ IPC_HANDLER(get_workspaces) {
Con *focused_ws = con_get_workspace(focused); Con *focused_ws = con_get_workspace(focused);
Con *output; Con *output;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) { TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
if (con_is_internal(output)) if (con_is_internal(output))
continue; continue;
Con *ws; 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); assert(ws->type == CT_WORKSPACE);
y(map_open); y(map_open);
@ -963,7 +963,7 @@ IPC_HANDLER(get_outputs) {
y(array_open); y(array_open);
Output *output; Output *output;
TAILQ_FOREACH(output, &outputs, outputs) { TAILQ_FOREACH (output, &outputs, outputs) {
y(map_open); y(map_open);
ystr("name"); ystr("name");
@ -1017,9 +1017,9 @@ IPC_HANDLER(get_marks) {
y(array_open); y(array_open);
Con *con; Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) { TAILQ_FOREACH (con, &all_cons, all_cons) {
mark_t *mark; mark_t *mark;
TAILQ_FOREACH(mark, &(con->marks_head), marks) { TAILQ_FOREACH (mark, &(con->marks_head), marks) {
ystr(mark->name); ystr(mark->name);
} }
} }
@ -1079,7 +1079,7 @@ IPC_HANDLER(get_bar_config) {
if (message_size == 0) { if (message_size == 0) {
y(array_open); y(array_open);
Barconfig *current; Barconfig *current;
TAILQ_FOREACH(current, &barconfigs, configs) { TAILQ_FOREACH (current, &barconfigs, configs) {
ystr(current->id); ystr(current->id);
} }
y(array_close); y(array_close);
@ -1099,7 +1099,7 @@ IPC_HANDLER(get_bar_config) {
sasprintf(&bar_id, "%.*s", message_size, message); sasprintf(&bar_id, "%.*s", message_size, message);
LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id); LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
Barconfig *current, *config = NULL; Barconfig *current, *config = NULL;
TAILQ_FOREACH(current, &barconfigs, configs) { TAILQ_FOREACH (current, &barconfigs, configs) {
if (strcmp(current->id, bar_id) != 0) if (strcmp(current->id, bar_id) != 0)
continue; continue;
@ -1138,7 +1138,7 @@ IPC_HANDLER(get_binding_modes) {
y(array_open); y(array_open);
struct Mode *mode; struct Mode *mode;
SLIST_FOREACH(mode, &modes, modes) { SLIST_FOREACH (mode, &modes, modes) {
ystr(mode->name); ystr(mode->name);
} }
y(array_close); 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})) { if (rect_equals(json_node->rect, (Rect){0, 0, 0, 0})) {
DLOG("Geometry not set, combining children\n"); DLOG("Geometry not set, combining children\n");
Con *child; 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); DLOG("child geometry: %d x %d\n", child->geometry.width, child->geometry.height);
json_node->rect.width += child->geometry.width; json_node->rect.width += child->geometry.width;
json_node->rect.height = max(json_node->rect.height, child->geometry.height); 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) { if (parsing_focus) {
/* Clear the list of focus mappings */ /* Clear the list of focus mappings */
struct focus_mapping *mapping; 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); LOG("focus (reverse) %d\n", mapping->old_id);
Con *con; 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) if (con->old_id != mapping->old_id)
continue; continue;
LOG("got it! %p\n", con); LOG("got it! %p\n", con);

View File

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

View File

@ -83,7 +83,7 @@ void restore_geometry(void) {
DLOG("Restoring geometry\n"); DLOG("Restoring geometry\n");
Con *con; Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) TAILQ_FOREACH (con, &all_cons, all_cons) {
if (con->window) { if (con->window) {
DLOG("Re-adding X11 border of %d px\n", con->border_width); DLOG("Re-adding X11 border of %d px\n", con->border_width);
con->window_rect.width += (2 * 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, xcb_reparent_window(conn, con->window->id, root,
con->rect.x, con->rect.y); con->rect.x, con->rect.y);
} }
}
/* Strictly speaking, this line doesnt really belong here, but since we /* Strictly speaking, this line doesnt really belong here, but since we
* are syncing, lets un-register as a window manager first */ * 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; return false;
} }
/* if we find a window that is newer than this one, bail */ /* 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) && if ((con->window != NULL) &&
_i3_timercmp(con->window->urgent, window->urgent, >)) { _i3_timercmp(con->window->urgent, window->urgent, >)) {
return false; return false;
@ -154,7 +154,7 @@ bool match_matches_window(Match *match, i3Window *window) {
return false; return false;
} }
/* if we find a window that is older than this one (and not 0), bail */ /* 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) && if ((con->window != NULL) &&
(con->window->urgent.tv_sec != 0) && (con->window->urgent.tv_sec != 0) &&
_i3_timercmp(con->window->urgent, window->urgent, <)) { _i3_timercmp(con->window->urgent, window->urgent, <)) {
@ -201,7 +201,7 @@ bool match_matches_window(Match *match, i3Window *window) {
bool matched = false; bool matched = false;
mark_t *mark; mark_t *mark;
TAILQ_FOREACH(mark, &(con->marks_head), marks) { TAILQ_FOREACH (mark, &(con->marks_head), marks) {
if (regex_matches(match->mark, mark->name)) { if (regex_matches(match->mark, mark->name)) {
matched = true; matched = true;
break; break;

View File

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

View File

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

View File

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

View File

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

View File

@ -112,7 +112,7 @@ bool scratchpad_show(Con *con) {
* unfocused scratchpad on the current workspace and focus it */ * unfocused scratchpad on the current workspace and focus it */
Con *walk_con; Con *walk_con;
Con *focused_ws = con_get_workspace(focused); 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)) && if (!con && (floating = con_inside_floating(walk_con)) &&
floating->scratchpad_state != SCRATCHPAD_NONE && floating->scratchpad_state != SCRATCHPAD_NONE &&
floating != con_inside_floating(focused)) { 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 * visible scratchpad window on another workspace. In this case we move it
* to the current workspace. */ * to the current workspace. */
focused_ws = con_get_workspace(focused); 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); Con *walk_ws = con_get_workspace(walk_con);
if (!con && walk_ws && if (!con && walk_ws &&
!con_is_internal(walk_ws) && focused_ws != walk_ws && !con_is_internal(walk_ws) && focused_ws != walk_ws &&
@ -253,7 +253,7 @@ void scratchpad_fix_resolution(void) {
Con *output; Con *output;
int new_width = -1, int new_width = -1,
new_height = -1; new_height = -1;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) { TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
if (output == __i3_output) if (output == __i3_output)
continue; continue;
DLOG("output %s's resolution: (%d, %d) %d x %d\n", 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"); DLOG("Fixing coordinates of scratchpad windows\n");
Con *con; 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); 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) { static void sighandler_create_dialogs(void) {
Output *output; Output *output;
TAILQ_FOREACH(output, &outputs, outputs) { TAILQ_FOREACH (output, &outputs, outputs) {
if (!output->active) { if (!output->active) {
continue; continue;
} }
@ -230,7 +230,7 @@ static void sighandler_destroy_dialogs(void) {
static void sighandler_handle_expose(void) { static void sighandler_handle_expose(void) {
dialog_t *current; dialog_t *current;
TAILQ_FOREACH(current, &dialogs, dialogs) { TAILQ_FOREACH (current, &dialogs, dialogs) {
sighandler_draw_dialog(current); 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); DLOG("Timeout for startup sequence %s\n", id);
struct Startup_Sequence *current, *sequence = NULL; struct Startup_Sequence *current, *sequence = NULL;
TAILQ_FOREACH(current, &startup_sequences, sequences) { TAILQ_FOREACH (current, &startup_sequences, sequences) {
if (strcmp(current->id, id) != 0) if (strcmp(current->id, id) != 0)
continue; continue;
@ -220,7 +220,7 @@ void startup_monitor_event(SnMonitorEvent *event, void *userdata) {
/* Get the corresponding internal startup sequence */ /* Get the corresponding internal startup sequence */
const char *id = sn_startup_sequence_get_id(snsequence); const char *id = sn_startup_sequence_get_id(snsequence);
struct Startup_Sequence *current, *sequence = NULL; struct Startup_Sequence *current, *sequence = NULL;
TAILQ_FOREACH(current, &startup_sequences, sequences) { TAILQ_FOREACH (current, &startup_sequences, sequences) {
if (strcmp(current->id, id) != 0) if (strcmp(current->id, id) != 0)
continue; 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) { void startup_sequence_rename_workspace(const char *old_name, const char *new_name) {
struct Startup_Sequence *current; struct Startup_Sequence *current;
TAILQ_FOREACH(current, &startup_sequences, sequences) { TAILQ_FOREACH (current, &startup_sequences, sequences) {
if (strcmp(current->workspace, old_name) != 0) if (strcmp(current->workspace, old_name) != 0)
continue; continue;
DLOG("Renaming workspace \"%s\" to \"%s\" in startup sequence %s.\n", 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), sasprintf(&startup_id, "%.*s", xcb_get_property_value_length(startup_id_reply),
(char *)xcb_get_property_value(startup_id_reply)); (char *)xcb_get_property_value(startup_id_reply));
struct Startup_Sequence *current, *sequence = NULL; 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) if (strcmp(current->id, startup_id) != 0)
continue; continue;

View File

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

46
src/x.c
View File

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