clang-format-3.5 **/*.h **/*.c

This should be the last commit that formats a big bunch of files. From
here on, whenever I merge patches, I’ll run clang-format like described
in the title.
This commit is contained in:
Michael Stapelberg
2014-06-19 11:20:32 +02:00
parent 4211274fcd
commit 4c06e7a573
64 changed files with 1317 additions and 1252 deletions

View File

@ -15,9 +15,9 @@
typedef struct rect_t rect;
struct ev_loop* main_loop;
char *statusline;
char *statusline_buffer;
struct ev_loop *main_loop;
char *statusline;
char *statusline_buffer;
struct rect_t {
int x;

View File

@ -18,27 +18,30 @@ typedef enum {
} position_t;
/* Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
typedef enum { M_DOCK = 0, M_HIDE = 1, M_INVISIBLE = 2 } bar_display_mode_t;
typedef enum { M_DOCK = 0,
M_HIDE = 1,
M_INVISIBLE = 2 } bar_display_mode_t;
typedef struct config_t {
int modifier;
position_t position;
int verbose;
int modifier;
position_t position;
int verbose;
struct xcb_color_strings_t colors;
bool disable_binding_mode_indicator;
bool disable_ws;
bool strip_ws_numbers;
char *bar_id;
char *command;
char *fontname;
char *tray_output;
int num_outputs;
char **outputs;
bool disable_binding_mode_indicator;
bool disable_ws;
bool strip_ws_numbers;
char *bar_id;
char *command;
char *fontname;
char *tray_output;
int num_outputs;
char **outputs;
bar_display_mode_t hide_on_modifier;
/* The current hidden_state of the bar, which indicates whether it is hidden or shown */
enum { S_HIDE = 0, S_SHOW = 1 } hidden_state;
enum { S_HIDE = 0,
S_SHOW = 1 } hidden_state;
} config_t;
config_t config;

View File

@ -29,7 +29,7 @@ void destroy_connection(void);
* type must be a valid I3_IPC_MESSAGE_TYPE (see i3/ipc.h for further information)
*
*/
int i3_send_msg(uint32_t type, const char* payload);
int i3_send_msg(uint32_t type, const char *payload);
/*
* Subscribe to all the i3-events, we need

View File

@ -16,7 +16,7 @@
typedef struct i3_output i3_output;
SLIST_HEAD(outputs_head, i3_output);
struct outputs_head *outputs;
struct outputs_head* outputs;
/*
* Start parsing the received json-string
@ -37,18 +37,18 @@ void init_outputs(void);
i3_output* get_output_by_name(char* name);
struct i3_output {
char* name; /* Name of the output */
bool active; /* If the output is active */
bool primary; /* If it is the primary output */
int ws; /* The number of the currently visible ws */
rect rect; /* The rect (relative to the root-win) */
char* name; /* Name of the output */
bool active; /* If the output is active */
bool primary; /* If it is the primary output */
int ws; /* The number of the currently visible ws */
rect rect; /* The rect (relative to the root-win) */
xcb_window_t bar; /* The id of the bar of the output */
xcb_pixmap_t buffer; /* An extra pixmap for double-buffering */
xcb_gcontext_t bargc; /* The graphical context of the bar */
xcb_window_t bar; /* The id of the bar of the output */
xcb_pixmap_t buffer; /* An extra pixmap for double-buffering */
xcb_gcontext_t bargc; /* The graphical context of the bar */
struct ws_head *workspaces; /* The workspaces on this output */
struct tc_head *trayclients; /* The tray clients on this output */
struct ws_head* workspaces; /* The workspaces on this output */
struct tc_head* trayclients; /* The tray clients on this output */
SLIST_ENTRY(i3_output) slist; /* Pointer for the SLIST-Macro */
};

View File

@ -14,9 +14,9 @@ typedef struct trayclient trayclient;
TAILQ_HEAD(tc_head, trayclient);
struct trayclient {
xcb_window_t win; /* The window ID of the tray client */
bool mapped; /* Whether this window is mapped */
int xe_version; /* The XEMBED version supported by the client */
xcb_window_t win; /* The window ID of the tray client */
bool mapped; /* Whether this window is mapped */
int xe_version; /* The XEMBED version supported by the client */
TAILQ_ENTRY(trayclient) tailq; /* Pointer for the TAILQ-Macro */
TAILQ_ENTRY(trayclient) tailq; /* Pointer for the TAILQ-Macro */
};

View File

@ -11,55 +11,60 @@
/* Get the maximum/minimum of x and y */
#undef MAX
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#undef MIN
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define STARTS_WITH(string, len, needle) ((len >= strlen(needle)) && strncasecmp(string, needle, strlen(needle)) == 0)
/* Securely free p */
#define FREE(p) do { \
if (p != NULL) { \
free(p); \
p = NULL; \
} \
} while (0)
#define FREE(p) \
do { \
if (p != NULL) { \
free(p); \
p = NULL; \
} \
} while (0)
/* Securely fee single-linked list */
#define FREE_SLIST(l, type) do { \
type *walk = SLIST_FIRST(l); \
while (!SLIST_EMPTY(l)) { \
SLIST_REMOVE_HEAD(l, slist); \
FREE(walk); \
walk = SLIST_FIRST(l); \
} \
} while (0)
#define FREE_SLIST(l, type) \
do { \
type *walk = SLIST_FIRST(l); \
while (!SLIST_EMPTY(l)) { \
SLIST_REMOVE_HEAD(l, slist); \
FREE(walk); \
walk = SLIST_FIRST(l); \
} \
} while (0)
/* Securely fee tail-queues */
#define FREE_TAILQ(l, type) do { \
type *walk = TAILQ_FIRST(l); \
while (!TAILQ_EMPTY(l)) { \
TAILQ_REMOVE(l, TAILQ_FIRST(l), tailq); \
FREE(walk); \
walk = TAILQ_FIRST(l); \
} \
} while (0)
#define FREE_TAILQ(l, type) \
do { \
type *walk = TAILQ_FIRST(l); \
while (!TAILQ_EMPTY(l)) { \
TAILQ_REMOVE(l, TAILQ_FIRST(l), tailq); \
FREE(walk); \
walk = TAILQ_FIRST(l); \
} \
} while (0)
#if defined(DLOG)
#undef DLOG
#endif
/* Use cool logging-macros */
#define DLOG(fmt, ...) do { \
if (config.verbose) { \
printf("[%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} \
} while(0)
#define DLOG(fmt, ...) \
do { \
if (config.verbose) { \
printf("[%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} \
} while (0)
/* We will include libi3.h which define its own version of ELOG.
* We want *our* version, so we undef the libi3 one. */
#if defined(ELOG)
#undef ELOG
#endif
#define ELOG(fmt, ...) do { \
fprintf(stderr, "[%s:%d] ERROR: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} while(0)
#define ELOG(fmt, ...) \
do { \
fprintf(stderr, "[%s:%d] ERROR: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} while (0)

View File

@ -30,15 +30,15 @@ void parse_workspaces_json(char *json);
void free_workspaces(void);
struct i3_ws {
int num; /* The internal number of the ws */
char *canonical_name; /* The true name of the ws according to the ipc */
i3String *name; /* The name of the ws that is displayed on the bar */
int name_width; /* The rendered width of the name */
bool visible; /* If the ws is currently visible on an output */
bool focused; /* If the ws is currently focused */
bool urgent; /* If the urgent-hint of the ws is set */
rect rect; /* The rect of the ws (not used (yet)) */
struct i3_output *output; /* The current output of the ws */
int num; /* The internal number of the ws */
char *canonical_name; /* The true name of the ws according to the ipc */
i3String *name; /* The name of the ws that is displayed on the bar */
int name_width; /* The rendered width of the name */
bool visible; /* If the ws is currently visible on an output */
bool focused; /* If the ws is currently focused */
bool urgent; /* If the urgent-hint of the ws is set */
rect rect; /* The rect of the ws (not used (yet)) */
struct i3_output *output; /* The current output of the ws */
TAILQ_ENTRY(i3_ws) tailq; /* Pointer for the TAILQ-Macro */
TAILQ_ENTRY(i3_ws) tailq; /* Pointer for the TAILQ-Macro */
};

View File

@ -18,11 +18,11 @@
#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
#define _NET_SYSTEM_TRAY_ORIENTATION_VERT 1
#define SYSTEM_TRAY_REQUEST_DOCK 0
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
#define XEMBED_MAPPED (1 << 0)
#define XEMBED_EMBEDDED_NOTIFY 0
#define SYSTEM_TRAY_REQUEST_DOCK 0
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
#define XEMBED_MAPPED (1 << 0)
#define XEMBED_EMBEDDED_NOTIFY 0
struct xcb_color_strings_t {
char *bar_fg;

View File

@ -243,7 +243,7 @@ static int stdin_end_map(void *context) {
static int stdin_end_array(void *context) {
DLOG("dumping statusline:\n");
struct status_block *current;
TAILQ_FOREACH (current, &statusline_head, blocks) {
TAILQ_FOREACH(current, &statusline_head, blocks) {
DLOG("full_text = %s\n", i3string_as_utf8(current->full_text));
DLOG("color = %s\n", current->color);
}

View File

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

View File

@ -296,7 +296,7 @@ i3_output *get_output_by_name(char *name) {
if (name == NULL) {
return NULL;
}
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (!strcmp(walk->name, name)) {
break;
}

View File

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

View File

@ -128,7 +128,7 @@ void refresh_statusline(void) {
statusline_width = 0;
/* Predict the text width of all blocks (in pixels). */
TAILQ_FOREACH (block, &statusline_head, blocks) {
TAILQ_FOREACH(block, &statusline_head, blocks) {
if (i3string_get_num_bytes(block->full_text) == 0)
continue;
@ -173,7 +173,7 @@ void refresh_statusline(void) {
/* Draw the text of each block. */
uint32_t x = 0;
TAILQ_FOREACH (block, &statusline_head, blocks) {
TAILQ_FOREACH(block, &statusline_head, blocks) {
if (i3string_get_num_bytes(block->full_text) == 0)
continue;
@ -206,7 +206,7 @@ void hide_bars(void) {
}
i3_output *walk;
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (!walk->active) {
continue;
}
@ -231,7 +231,7 @@ void unhide_bars(void) {
cont_child();
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (walk->bar == XCB_NONE) {
continue;
}
@ -303,7 +303,7 @@ void handle_button(xcb_button_press_event_t *event) {
/* Determine, which bar was clicked */
i3_output *walk;
xcb_window_t bar = event->event;
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (walk->bar == bar) {
break;
}
@ -315,7 +315,7 @@ void handle_button(xcb_button_press_event_t *event) {
}
/* TODO: Move this to extern get_ws_for_output() */
TAILQ_FOREACH (cur_ws, walk->workspaces, tailq) {
TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
if (cur_ws->visible) {
break;
}
@ -338,7 +338,7 @@ void handle_button(xcb_button_press_event_t *event) {
/* First calculate width of tray area */
trayclient *trayclient;
int tray_width = 0;
TAILQ_FOREACH_REVERSE (trayclient, walk->trayclients, tc_head, tailq) {
TAILQ_FOREACH_REVERSE(trayclient, walk->trayclients, tc_head, tailq) {
if (!trayclient->mapped)
continue;
tray_width += (font.height + logical_px(2));
@ -351,7 +351,7 @@ void handle_button(xcb_button_press_event_t *event) {
if (x >= 0) {
struct status_block *block;
TAILQ_FOREACH (block, &statusline_head, blocks) {
TAILQ_FOREACH(block, &statusline_head, blocks) {
last_block_x = block_x;
block_x += block->width + block->x_offset + block->x_append;
@ -387,7 +387,7 @@ void handle_button(xcb_button_press_event_t *event) {
break;
case 1:
/* Check if this event regards a workspace button */
TAILQ_FOREACH (cur_ws, walk->workspaces, tailq) {
TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
DLOG("x = %d\n", x);
if (x >= 0 && x < cur_ws->name_width + logical_px(10)) {
break;
@ -398,7 +398,7 @@ void handle_button(xcb_button_press_event_t *event) {
/* Otherwise, focus our currently visible workspace if it is not
* already focused */
if (cur_ws == NULL) {
TAILQ_FOREACH (cur_ws, walk->workspaces, tailq) {
TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
if (cur_ws->visible && !cur_ws->focused)
break;
}
@ -455,12 +455,12 @@ void handle_button(xcb_button_press_event_t *event) {
static void configure_trayclients(void) {
trayclient *trayclient;
i3_output *output;
SLIST_FOREACH (output, outputs, slist) {
SLIST_FOREACH(output, outputs, slist) {
if (!output->active)
continue;
int clients = 0;
TAILQ_FOREACH_REVERSE (trayclient, output->trayclients, tc_head, tailq) {
TAILQ_FOREACH_REVERSE(trayclient, output->trayclients, tc_head, tailq) {
if (!trayclient->mapped)
continue;
clients++;
@ -544,7 +544,7 @@ static void handle_client_message(xcb_client_message_event_t *event) {
DLOG("X window %08x requested docking\n", client);
i3_output *walk, *output = NULL;
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (!walk->active)
continue;
if (config.tray_output) {
@ -562,7 +562,7 @@ static void handle_client_message(xcb_client_message_event_t *event) {
if (output == NULL &&
config.tray_output &&
strcasecmp("primary", config.tray_output) == 0) {
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (!walk->active)
continue;
DLOG("Falling back to output %s because no primary output is configured\n", walk->name);
@ -650,12 +650,12 @@ static void handle_destroy_notify(xcb_destroy_notify_event_t *event) {
DLOG("DestroyNotify for window = %08x, event = %08x\n", event->window, event->event);
i3_output *walk;
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (!walk->active)
continue;
DLOG("checking output %s\n", walk->name);
trayclient *trayclient;
TAILQ_FOREACH (trayclient, walk->trayclients, tailq) {
TAILQ_FOREACH(trayclient, walk->trayclients, tailq) {
if (trayclient->win != event->window)
continue;
@ -679,12 +679,12 @@ static void handle_map_notify(xcb_map_notify_event_t *event) {
DLOG("MapNotify for window = %08x, event = %08x\n", event->window, event->event);
i3_output *walk;
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (!walk->active)
continue;
DLOG("checking output %s\n", walk->name);
trayclient *trayclient;
TAILQ_FOREACH (trayclient, walk->trayclients, tailq) {
TAILQ_FOREACH(trayclient, walk->trayclients, tailq) {
if (trayclient->win != event->window)
continue;
@ -707,12 +707,12 @@ static void handle_unmap_notify(xcb_unmap_notify_event_t *event) {
DLOG("UnmapNotify for window = %08x, event = %08x\n", event->window, event->event);
i3_output *walk;
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (!walk->active)
continue;
DLOG("checking output %s\n", walk->name);
trayclient *trayclient;
TAILQ_FOREACH (trayclient, walk->trayclients, tailq) {
TAILQ_FOREACH(trayclient, walk->trayclients, tailq) {
if (trayclient->win != event->window)
continue;
@ -739,11 +739,11 @@ static void handle_property_notify(xcb_property_notify_event_t *event) {
DLOG("xembed_info updated\n");
trayclient *trayclient = NULL, *walk;
i3_output *o_walk;
SLIST_FOREACH (o_walk, outputs, slist) {
SLIST_FOREACH(o_walk, outputs, slist) {
if (!o_walk->active)
continue;
TAILQ_FOREACH (walk, o_walk->trayclients, tailq) {
TAILQ_FOREACH(walk, o_walk->trayclients, tailq) {
if (walk->win != event->window)
continue;
trayclient = walk;
@ -802,12 +802,12 @@ static void handle_configure_request(xcb_configure_request_event_t *event) {
trayclient *trayclient;
i3_output *output;
SLIST_FOREACH (output, outputs, slist) {
SLIST_FOREACH(output, outputs, slist) {
if (!output->active)
continue;
int clients = 0;
TAILQ_FOREACH_REVERSE (trayclient, output->trayclients, tc_head, tailq) {
TAILQ_FOREACH_REVERSE(trayclient, output->trayclients, tc_head, tailq) {
if (!trayclient->mapped)
continue;
clients++;
@ -1280,7 +1280,7 @@ void init_tray_colors(void) {
void clean_xcb(void) {
i3_output *o_walk;
free_workspaces();
SLIST_FOREACH (o_walk, outputs, slist) {
SLIST_FOREACH(o_walk, outputs, slist) {
destroy_window(o_walk);
FREE(o_walk->trayclients);
FREE(o_walk->workspaces);
@ -1434,7 +1434,7 @@ void reconfig_windows(bool redraw_bars) {
static bool tray_configured = false;
i3_output *walk;
SLIST_FOREACH (walk, outputs, slist) {
SLIST_FOREACH(walk, outputs, slist) {
if (!walk->active) {
/* If an output is not active, we destroy its bar */
/* FIXME: Maybe we rather want to unmap? */
@ -1596,7 +1596,7 @@ void reconfig_windows(bool redraw_bars) {
* VGA-1 but output == [HDMI-1]).
*/
i3_output *output;
SLIST_FOREACH (output, outputs, slist) {
SLIST_FOREACH(output, outputs, slist) {
if (strcasecmp(output->name, tray_output) == 0 ||
(strcasecmp(tray_output, "primary") == 0 && output->primary)) {
init_tray();
@ -1685,7 +1685,7 @@ void draw_bars(bool unhide) {
refresh_statusline();
i3_output *outputs_walk;
SLIST_FOREACH (outputs_walk, outputs, slist) {
SLIST_FOREACH(outputs_walk, outputs, slist) {
if (!outputs_walk->active) {
DLOG("Output %s inactive, skipping...\n", outputs_walk->name);
continue;
@ -1715,7 +1715,7 @@ void draw_bars(bool unhide) {
* position */
trayclient *trayclient;
int traypx = 0;
TAILQ_FOREACH (trayclient, outputs_walk->trayclients, tailq) {
TAILQ_FOREACH(trayclient, outputs_walk->trayclients, tailq) {
if (!trayclient->mapped)
continue;
/* We assume the tray icons are quadratic (we use the font
@ -1737,7 +1737,7 @@ void draw_bars(bool unhide) {
if (!config.disable_ws) {
i3_ws *ws_walk;
TAILQ_FOREACH (ws_walk, outputs_walk->workspaces, tailq) {
TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
DLOG("Drawing Button for WS %s at x = %d, len = %d\n",
i3string_as_utf8(ws_walk->name), i, ws_walk->name_width);
uint32_t fg_color = colors.inactive_ws_fg;
@ -1853,7 +1853,7 @@ void draw_bars(bool unhide) {
*/
void redraw_bars(void) {
i3_output *outputs_walk;
SLIST_FOREACH (outputs_walk, outputs, slist) {
SLIST_FOREACH(outputs_walk, outputs, slist) {
if (!outputs_walk->active) {
continue;
}