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:
parent
e3f120c0b6
commit
1f0c628cde
|
@ -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]
|
||||||
|
|
15
src/con.c
15
src/con.c
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1033,8 +1033,9 @@ 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) {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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 doesn’t really belong here, but since we
|
/* Strictly speaking, this line doesn’t really belong here, but since we
|
||||||
* are syncing, let’s un-register as a window manager first */
|
* are syncing, let’s un-register as a window manager first */
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -313,8 +314,9 @@ static void render_output(Con *con) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,15 +431,17 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Renders the tree, that is rendering all outputs using render_con() and
|
* Renders the tree, that is rendering all outputs using render_con() and
|
||||||
|
|
|
@ -388,9 +388,10 @@ 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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callback to reset the urgent flag of the given con to false. May be started by
|
* Callback to reset the urgent flag of the given con to false. May be started by
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
24
src/x.c
24
src/x.c
|
@ -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);
|
||||||
|
@ -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);
|
||||||
|
@ -1116,12 +1120,14 @@ 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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns true if the given container is currently attached to its parent.
|
* Returns true if the given container is currently attached to its parent.
|
||||||
|
@ -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(). */
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue