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

This has multiple effects:

1) The i3 codebase is now consistently formatted. clang-format uncovered
   plenty of places where inconsistent code made it into our code base.

2) When writing code, you don’t need to think or worry about our coding
   style. Write it in yours, then run clang-format-3.5

3) When submitting patches, we don’t need to argue about coding style.

The basic idea is that we don’t want to care about _how_ we write the
code, but _what_ it does :). The coding style that we use is defined in
the .clang-format config file and is based on the google style, but
adapted in such a way that the number of modifications to the i3 code
base is minimal.
This commit is contained in:
Michael Stapelberg 2014-06-15 19:07:02 +02:00
parent 4d937b7dbb
commit 9200094203
65 changed files with 2891 additions and 2924 deletions

View File

@ -53,19 +53,21 @@
#error "SYSCONFDIR not defined" #error "SYSCONFDIR not defined"
#endif #endif
#define FREE(pointer) do { \ #define FREE(pointer) \
do { \
if (pointer != NULL) { \ if (pointer != NULL) { \
free(pointer); \ free(pointer); \
pointer = NULL; \ pointer = NULL; \
} \ } \
} \ } while (0)
while (0)
#include "xcb.h" #include "xcb.h"
#include "libi3.h" #include "libi3.h"
enum { STEP_WELCOME, STEP_GENERATE } current_step = STEP_WELCOME; enum { STEP_WELCOME,
enum { MOD_Mod1, MOD_Mod4 } modifier = MOD_Mod4; STEP_GENERATE } current_step = STEP_WELCOME;
enum { MOD_Mod1,
MOD_Mod4 } modifier = MOD_Mod4;
static char *config_path; static char *config_path;
static uint32_t xcb_numlock_mask; static uint32_t xcb_numlock_mask;
@ -102,7 +104,6 @@ typedef struct tokenptr {
int n; int n;
} cmdp_token_ptr; } cmdp_token_ptr;
#include "GENERATED_config_tokens.h" #include "GENERATED_config_tokens.h"
static cmdp_state state; static cmdp_state state;
@ -182,7 +183,6 @@ static void push_long(const char *identifier, long num) {
"in the code, or a new command which contains more than " "in the code, or a new command which contains more than "
"10 identified tokens.\n"); "10 identified tokens.\n");
exit(1); exit(1);
} }
static const char *get_string(const char *identifier) { static const char *get_string(const char *identifier) {
@ -195,7 +195,6 @@ static const char *get_string(const char *identifier) {
return NULL; return NULL;
} }
static void clear_stack(void) { static void clear_stack(void) {
for (int c = 0; c < 10; c++) { for (int c = 0; c < 10; c++) {
if (stack[c].type == STACK_STR && stack[c].val.str != NULL) if (stack[c].type == STACK_STR && stack[c].val.str != NULL)
@ -228,7 +227,6 @@ static bool keysym_used_on_other_key(KeySym sym, xcb_keycode_t except_keycode) {
return false; return false;
} }
static char *next_state(const cmdp_token *token) { static char *next_state(const cmdp_token *token) {
cmdp_state _next_state = token->next_state; cmdp_state _next_state = token->next_state;
@ -286,7 +284,6 @@ static char *next_state(const cmdp_token *token) {
return NULL; return NULL;
} }
static char *rewrite_binding(const char *input) { static char *rewrite_binding(const char *input) {
state = INITIAL; state = INITIAL;
statelist_idx = 1; statelist_idx = 1;
@ -418,7 +415,6 @@ static char *rewrite_binding(const char *input) {
return NULL; return NULL;
} }
/* /*
* Having verboselog(), errorlog() and debuglog() is necessary when using libi3. * Having verboselog(), errorlog() and debuglog() is necessary when using libi3.
* *
@ -521,14 +517,16 @@ static int handle_expose() {
/* the not-selected modifier */ /* the not-selected modifier */
if (modifier == MOD_Mod4) if (modifier == MOD_Mod4)
txt(31, 5, "<Alt>"); txt(31, 5, "<Alt>");
else txt(31, 4, "<Win>"); else
txt(31, 4, "<Win>");
/* the selected modifier */ /* the selected modifier */
set_font(&bold_font); set_font(&bold_font);
set_font_colors(pixmap_gc, get_colorpixel("#FFFFFF"), get_colorpixel("#000000")); set_font_colors(pixmap_gc, get_colorpixel("#FFFFFF"), get_colorpixel("#000000"));
if (modifier == MOD_Mod4) if (modifier == MOD_Mod4)
txt(10, 4, "-> <Win>"); txt(10, 4, "-> <Win>");
else txt(10, 5, "-> <Alt>"); else
txt(10, 5, "-> <Alt>");
/* green */ /* green */
set_font(&font); set_font(&font);
@ -573,8 +571,8 @@ static int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press
strlen("i3: generate config"), strlen("i3: generate config"),
"i3: generate config"); "i3: generate config");
xcb_flush(conn); xcb_flush(conn);
} } else
else finish(); finish();
} }
/* cancel any time */ /* cancel any time */
@ -701,7 +699,8 @@ static void finish() {
if (strncmp(walk, "set $mod ", strlen("set $mod ")) == 0) { if (strncmp(walk, "set $mod ", strlen("set $mod ")) == 0) {
if (modifier == MOD_Mod1) if (modifier == MOD_Mod1)
fputs("set $mod Mod1\n", ks_config); fputs("set $mod Mod1\n", ks_config);
else fputs("set $mod Mod4\n", ks_config); else
fputs("set $mod Mod4\n", ks_config);
continue; continue;
} }
@ -750,8 +749,7 @@ int main(int argc, char *argv[]) {
{"prefix", required_argument, 0, 'p'}, {"prefix", required_argument, 0, 'p'},
{"font", required_argument, 0, 'f'}, {"font", required_argument, 0, 'f'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{0, 0, 0, 0} {0, 0, 0, 0}};
};
char *options_string = "s:vh"; char *options_string = "s:vh";
@ -842,8 +840,7 @@ int main(int argc, char *argv[]) {
(uint32_t[]) { (uint32_t[]) {
0, /* back pixel: black */ 0, /* back pixel: black */
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_BUTTON_PRESS XCB_EVENT_MASK_BUTTON_PRESS});
});
/* Map the window (make it visible) */ /* Map the window (make it visible) */
xcb_map_window(conn, win); xcb_map_window(conn, win);

View File

@ -70,8 +70,7 @@ int main(int argc, char *argv[]) {
{"verbose", no_argument, 0, 'V'}, {"verbose", no_argument, 0, 'V'},
{"follow", no_argument, 0, 'f'}, {"follow", no_argument, 0, 'f'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{0, 0, 0, 0} {0, 0, 0, 0}};
};
char *options_string = "s:vfVh"; char *options_string = "s:vfVh";

View File

@ -814,8 +814,7 @@ struct codepair {
{0x20ac, 0x20ac}, /* EuroSign € EURO SIGN */ {0x20ac, 0x20ac}, /* EuroSign € EURO SIGN */
}; };
long keysym2ucs(xcb_keysym_t keysym) long keysym2ucs(xcb_keysym_t keysym) {
{
int min = 0; int min = 0;
int max = sizeof(keysymtab) / sizeof(struct codepair) - 1; int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
int mid; int mid;

View File

@ -143,8 +143,7 @@ static int handle_expose(void *data, xcb_connection_t *conn, xcb_expose_event_t
draw_text(prompt, pixmap, pixmap_gc, 4, 4, 492); draw_text(prompt, pixmap, pixmap_gc, 4, 4, 492);
} }
/* … and the text */ /* … and the text */
if (input_position > 0) if (input_position > 0) {
{
i3String *input = i3string_from_ucs2(glyphs_ucs, input_position); i3String *input = i3string_from_ucs2(glyphs_ucs, input_position);
draw_text(input, pixmap, pixmap_gc, prompt_offset + 4, 4, 492); draw_text(input, pixmap, pixmap_gc, prompt_offset + 4, 4, 492);
i3string_free(input); i3string_free(input);
@ -326,8 +325,7 @@ int main(int argc, char *argv[]) {
{"format", required_argument, 0, 'F'}, {"format", required_argument, 0, 'F'},
{"font", required_argument, 0, 'f'}, {"font", required_argument, 0, 'f'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{0, 0, 0, 0} {0, 0, 0, 0}};
};
char *options_string = "s:p:P:f:l:F:vh"; char *options_string = "s:p:P:f:l:F:vh";
@ -415,8 +413,7 @@ int main(int argc, char *argv[]) {
(uint32_t[]) { (uint32_t[]) {
0, /* back pixel: black */ 0, /* back pixel: black */
1, /* override redirect: dont manage this window */ 1, /* override redirect: dont manage this window */
XCB_EVENT_MASK_EXPOSURE XCB_EVENT_MASK_EXPOSURE});
});
/* Map the window (make it visible) */ /* Map the window (make it visible) */
xcb_map_window(conn, win); xcb_map_window(conn, win);

View File

@ -85,7 +85,8 @@ static int reply_string_cb(void *params, const unsigned char *val, size_t len) {
last_reply.input = str; last_reply.input = str;
else if (strcmp(last_key, "errorposition") == 0) else if (strcmp(last_key, "errorposition") == 0)
last_reply.errorposition = str; last_reply.errorposition = str;
else free(str); else
free(str);
return 1; return 1;
} }
@ -102,7 +103,6 @@ static int reply_end_map_cb(void *params) {
return 1; return 1;
} }
static int reply_map_key_cb(void *params, const unsigned char *keyVal, size_t keyLen) { static int reply_map_key_cb(void *params, const unsigned char *keyVal, size_t keyLen) {
free(last_key); free(last_key);
last_key = scalloc(keyLen + 1); last_key = scalloc(keyLen + 1);
@ -131,8 +131,7 @@ int main(int argc, char *argv[]) {
{"version", no_argument, 0, 'v'}, {"version", no_argument, 0, 'v'},
{"quiet", no_argument, 0, 'q'}, {"quiet", no_argument, 0, 'q'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{0, 0, 0, 0} {0, 0, 0, 0}};
};
char *options_string = "s:t:vhq"; char *options_string = "s:t:vhq";

View File

@ -218,8 +218,7 @@ static int handle_expose(xcb_connection_t *conn, xcb_expose_event_t *event) {
{y - (line_width / 2), line_width / 2}, {y - (line_width / 2), line_width / 2},
{y - (line_width / 2), (rect.height - (line_width / 2)) - 2}, {y - (line_width / 2), (rect.height - (line_width / 2)) - 2},
{y - w - (2 * line_width), (rect.height - (line_width / 2)) - 2}, {y - w - (2 * line_width), (rect.height - (line_width / 2)) - 2},
{ y - w - (2 * line_width), line_width / 2 } {y - w - (2 * line_width), line_width / 2}};
};
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, pixmap, pixmap_gc, 5, points); xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, pixmap, pixmap_gc, 5, points);
values[0] = 1; values[0] = 1;
@ -251,8 +250,7 @@ static int handle_expose(xcb_connection_t *conn, xcb_expose_event_t *event) {
{y - (line_width / 2), (line_width / 2) + 2}, {y - (line_width / 2), (line_width / 2) + 2},
{y - (line_width / 2), (rect.height - 4 - (line_width / 2))}, {y - (line_width / 2), (rect.height - 4 - (line_width / 2))},
{y - w - (2 * line_width), (rect.height - 4 - (line_width / 2))}, {y - w - (2 * line_width), (rect.height - 4 - (line_width / 2))},
{ y - w - (2 * line_width), (line_width / 2) + 2 } {y - w - (2 * line_width), (line_width / 2) + 2}};
};
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, pixmap, pixmap_gc, 5, points2); xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, pixmap, pixmap_gc, 5, points2);
values[0] = color_text; values[0] = color_text;
@ -272,11 +270,9 @@ static int handle_expose(xcb_connection_t *conn, xcb_expose_event_t *event) {
xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_LINE_WIDTH, values); xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_LINE_WIDTH, values);
xcb_point_t bottom[] = { xcb_point_t bottom[] = {
{0, rect.height - 0}, {0, rect.height - 0},
{ rect.width, rect.height - 0 } {rect.width, rect.height - 0}};
};
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, pixmap, pixmap_gc, 2, bottom); xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, pixmap, pixmap_gc, 2, bottom);
/* Copy the contents of the pixmap to the real window */ /* Copy the contents of the pixmap to the real window */
xcb_copy_area(conn, pixmap, win, pixmap_gc, 0, 0, 0, 0, rect.width, rect.height); xcb_copy_area(conn, pixmap, win, pixmap_gc, 0, 0, 0, 0, rect.width, rect.height);
xcb_flush(conn); xcb_flush(conn);
@ -322,7 +318,8 @@ int main(int argc, char *argv[]) {
char *pattern = sstrdup("-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"); char *pattern = sstrdup("-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1");
int o, option_index = 0; int o, option_index = 0;
enum { TYPE_ERROR = 0, TYPE_WARNING = 1 } bar_type = TYPE_ERROR; enum { TYPE_ERROR = 0,
TYPE_WARNING = 1 } bar_type = TYPE_ERROR;
static struct option long_options[] = { static struct option long_options[] = {
{"version", no_argument, 0, 'v'}, {"version", no_argument, 0, 'v'},
@ -331,8 +328,7 @@ int main(int argc, char *argv[]) {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"message", required_argument, 0, 'm'}, {"message", required_argument, 0, 'm'},
{"type", required_argument, 0, 't'}, {"type", required_argument, 0, 't'},
{0, 0, 0, 0} {0, 0, 0, 0}};
};
char *options_string = "b:f:m:t:vh"; char *options_string = "b:f:m:t:vh";
@ -424,8 +420,7 @@ int main(int argc, char *argv[]) {
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_PRESS |
XCB_EVENT_MASK_BUTTON_RELEASE XCB_EVENT_MASK_BUTTON_RELEASE});
});
/* Map the window (make it visible) */ /* Map the window (make it visible) */
xcb_map_window(conn, win); xcb_map_window(conn, win);
@ -521,8 +516,7 @@ int main(int argc, char *argv[]) {
configure_notify->x, configure_notify->x,
configure_notify->y, configure_notify->y,
configure_notify->width, configure_notify->width,
configure_notify->height configure_notify->height};
};
/* Recreate the pixmap / gc */ /* Recreate the pixmap / gc */
xcb_free_pixmap(conn, pixmap); xcb_free_pixmap(conn, pixmap);

View File

@ -302,7 +302,8 @@ static void read_flat_input(char *buffer, int length) {
* time. */ * time. */
if (buffer[length - 1] == '\n' || buffer[length - 1] == '\r') if (buffer[length - 1] == '\n' || buffer[length - 1] == '\r')
buffer[length - 1] = '\0'; buffer[length - 1] = '\0';
else buffer[length] = '\0'; else
buffer[length] = '\0';
first->full_text = i3string_from_utf8(buffer); first->full_text = i3string_from_utf8(buffer);
} }

View File

@ -268,4 +268,3 @@ void free_colors(struct xcb_color_strings_t *colors) {
FREE_COLOR(focus_ws_border); FREE_COLOR(focus_ws_border);
#undef FREE_COLOR #undef FREE_COLOR
} }

View File

@ -103,8 +103,7 @@ int main(int argc, char **argv) {
{"bar_id", required_argument, 0, 'b'}, {"bar_id", required_argument, 0, 'b'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'}, {"version", no_argument, 0, 'v'},
{ NULL, 0, 0, 0} {NULL, 0, 0, 0}};
};
while ((opt = getopt_long(argc, argv, "b:s:hv", long_opt, &option_index)) != -1) { while ((opt = getopt_long(argc, argv, "b:s:hv", long_opt, &option_index)) != -1) {
switch (opt) { switch (opt) {

View File

@ -31,7 +31,6 @@ static int mode_string_cb(void *params_, const unsigned char *val, size_t len) {
struct mode_json_params *params = (struct mode_json_params *)params_; struct mode_json_params *params = (struct mode_json_params *)params_;
if (!strcmp(params->cur_key, "change")) { if (!strcmp(params->cur_key, "change")) {
/* Save the name */ /* Save the name */
params->mode->name = i3string_from_utf8_with_length((const char *)val, len); params->mode->name = i3string_from_utf8_with_length((const char *)val, len);
/* Save its rendered width */ /* Save its rendered width */

View File

@ -243,7 +243,8 @@ void unhide_bars(void) {
values[0] = walk->rect.x; values[0] = walk->rect.x;
if (config.position == POS_TOP) if (config.position == POS_TOP)
values[1] = walk->rect.y; values[1] = walk->rect.y;
else values[1] = walk->rect.y + walk->rect.h - bar_height; else
values[1] = walk->rect.y + walk->rect.h - bar_height;
values[2] = walk->rect.w; values[2] = walk->rect.w;
values[3] = bar_height; values[3] = bar_height;
values[4] = XCB_STACK_MODE_ABOVE; values[4] = XCB_STACK_MODE_ABOVE;
@ -1018,7 +1019,6 @@ char *init_xcb_early() {
root_screen->width_in_pixels, root_screen->width_in_pixels,
root_screen->height_in_pixels); root_screen->height_in_pixels);
/* The various Watchers to communicate with xcb */ /* The various Watchers to communicate with xcb */
xcb_io = smalloc(sizeof(ev_io)); xcb_io = smalloc(sizeof(ev_io));
xcb_prep = smalloc(sizeof(ev_prepare)); xcb_prep = smalloc(sizeof(ev_prepare));
@ -1152,7 +1152,6 @@ static void send_tray_clientmessage(void) {
(char *)buffer); (char *)buffer);
} }
/* /*
* Initializes tray support by requesting the appropriate _NET_SYSTEM_TRAY atom * Initializes tray support by requesting the appropriate _NET_SYSTEM_TRAY atom
* for the X11 display we are running on, then acquiring the selection for this * for the X11 display we are running on, then acquiring the selection for this
@ -1220,8 +1219,9 @@ void init_tray(void) {
} }
if (selreply->owner != selwin) { if (selreply->owner != selwin) {
ELOG("Could not set the %s selection. " \ ELOG("Could not set the %s selection. "
"Maybe another tray is already running?\n", atomname); "Maybe another tray is already running?\n",
atomname);
/* NOTE that this error is not fatal. We just cant provide tray /* NOTE that this error is not fatal. We just cant provide tray
* functionality */ * functionality */
free(selreply); free(selreply);
@ -1307,7 +1307,8 @@ void clean_xcb(void) {
*/ */
void get_atoms(void) { void get_atoms(void) {
xcb_intern_atom_reply_t *reply; xcb_intern_atom_reply_t *reply;
#define ATOM_DO(name) reply = xcb_intern_atom_reply(xcb_connection, atom_cookies[name], NULL); \ #define ATOM_DO(name) \
reply = xcb_intern_atom_reply(xcb_connection, atom_cookies[name], NULL); \
if (reply == NULL) { \ if (reply == NULL) { \
ELOG("Could not get atom %s\n", #name); \ ELOG("Could not get atom %s\n", #name); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
@ -1421,7 +1422,6 @@ void realloc_sl_buffer(void) {
xcb_request_failed(sl_ctx_cookie, "Could not allocate statusline-buffer-context")) { xcb_request_failed(sl_ctx_cookie, "Could not allocate statusline-buffer-context")) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
/* /*
@ -1794,7 +1794,6 @@ void draw_bars(bool unhide) {
draw_text(ws_walk->name, outputs_walk->buffer, outputs_walk->bargc, draw_text(ws_walk->name, outputs_walk->buffer, outputs_walk->bargc,
i + logical_px(5), 3 * logical_px(1), ws_walk->name_width); i + logical_px(5), 3 * logical_px(1), ws_walk->name_width);
i += logical_px(10) + ws_walk->name_width + logical_px(1); i += logical_px(10) + ws_walk->name_width + logical_px(1);
} }
} }

View File

@ -69,8 +69,7 @@ static bool load_pango_font(i3Font *font, const char *desc) {
LOG("Using Pango font %s, size %d\n", LOG("Using Pango font %s, size %d\n",
pango_font_description_get_family(font->specific.pango_desc), pango_font_description_get_family(font->specific.pango_desc),
pango_font_description_get_size(font->specific.pango_desc) / PANGO_SCALE pango_font_description_get_size(font->specific.pango_desc) / PANGO_SCALE);
);
/* We cache root_visual_type here, since you must call /* We cache root_visual_type here, since you must call
* load_pango_font before any other pango function * load_pango_font before any other pango function
@ -217,7 +216,8 @@ i3Font load_font(const char *pattern, const bool fallback) {
if ((error = xcb_request_check(conn, font_cookie)) != NULL) if ((error = xcb_request_check(conn, font_cookie)) != NULL)
errx(EXIT_FAILURE, "Could open neither requested font nor fallbacks " errx(EXIT_FAILURE, "Could open neither requested font nor fallbacks "
"(fixed or -misc-*): X11 error %d", error->error_code); "(fixed or -misc-*): X11 error %d",
error->error_code);
} }
} }
@ -386,8 +386,7 @@ void draw_text_ascii(const char *text, xcb_drawable_t drawable,
case FONT_TYPE_NONE: case FONT_TYPE_NONE:
/* Nothing to do */ /* Nothing to do */
return; return;
case FONT_TYPE_XCB: case FONT_TYPE_XCB: {
{
size_t text_len = strlen(text); size_t text_len = strlen(text);
if (text_len > 255) { if (text_len > 255) {
/* The text is too long to draw it directly to X */ /* The text is too long to draw it directly to X */

View File

@ -20,7 +20,6 @@ char *get_exe_path(const char *argv0) {
char *destpath = smalloc(destpath_size); char *destpath = smalloc(destpath_size);
char *tmp = smalloc(tmp_size); char *tmp = smalloc(tmp_size);
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
/* Linux and Debian/kFreeBSD provide /proc/self/exe */ /* Linux and Debian/kFreeBSD provide /proc/self/exe */
#if defined(__linux__) || defined(__FreeBSD_kernel__) #if defined(__linux__) || defined(__FreeBSD_kernel__)

View File

@ -30,8 +30,7 @@ int ipc_send_message(int sockfd, const uint32_t message_size,
/* We dont use I3_IPC_MAGIC because its a 0-terminated C string. */ /* We dont use I3_IPC_MAGIC because its a 0-terminated C string. */
.magic = {'i', '3', '-', 'i', 'p', 'c'}, .magic = {'i', '3', '-', 'i', 'p', 'c'},
.size = message_size, .size = message_size,
.type = message_type .type = message_type};
};
size_t sent_bytes = 0; size_t sent_bytes = 0;
int n = 0; int n = 0;

View File

@ -99,4 +99,3 @@ char *root_atom_contents(const char *atomname, xcb_connection_t *provided_conn,
free(prop_reply); free(prop_reply);
return content; return content;
} }

View File

@ -84,8 +84,7 @@ static void grab_keycode_for_binding(xcb_connection_t *conn, Binding *bind, uint
/* Grab the key in all combinations */ /* Grab the key in all combinations */
#define GRAB_KEY(modifier) \ #define GRAB_KEY(modifier) \
do { \ do { \
xcb_grab_key(conn, 0, root, modifier, keycode, \ xcb_grab_key(conn, 0, root, modifier, keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); \
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); \
} while (0) } while (0)
int mods = bind->mods; int mods = bind->mods;
if ((bind->mods & BIND_MODE_SWITCH) != 0) { if ((bind->mods & BIND_MODE_SWITCH) != 0) {
@ -99,7 +98,6 @@ static void grab_keycode_for_binding(xcb_connection_t *conn, Binding *bind, uint
GRAB_KEY(mods | xcb_numlock_mask | XCB_MOD_MASK_LOCK); GRAB_KEY(mods | xcb_numlock_mask | XCB_MOD_MASK_LOCK);
} }
/* /*
* Grab the bound keys (tell X to send us keypress events for those keycodes) * Grab the bound keys (tell X to send us keypress events for those keycodes)
* *
@ -192,11 +190,9 @@ static Binding *get_binding(uint16_t modifiers, bool is_release, uint16_t input_
* *
*/ */
Binding *get_binding_from_xcb_event(xcb_generic_event_t *event) { Binding *get_binding_from_xcb_event(xcb_generic_event_t *event) {
bool is_release = (event->response_type == XCB_KEY_RELEASE bool is_release = (event->response_type == XCB_KEY_RELEASE || event->response_type == XCB_BUTTON_RELEASE);
|| event->response_type == XCB_BUTTON_RELEASE);
input_type_t input_type = ((event->response_type == XCB_BUTTON_RELEASE input_type_t input_type = ((event->response_type == XCB_BUTTON_RELEASE || event->response_type == XCB_BUTTON_PRESS)
|| event->response_type == XCB_BUTTON_PRESS)
? B_MOUSE ? B_MOUSE
: B_KEYBOARD); : B_KEYBOARD);
@ -413,8 +409,7 @@ CommandResult *run_binding(Binding *bind) {
"-b", "-b",
"show errors", "show errors",
pageraction, pageraction,
NULL NULL};
};
start_nagbar(&command_error_nagbar_pid, argv); start_nagbar(&command_error_nagbar_pid, argv);
free(pageraction); free(pageraction);
} }

View File

@ -18,7 +18,9 @@
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
typedef enum { CLICK_BORDER = 0, CLICK_DECORATION = 1, CLICK_INSIDE = 2 } click_destination_t; typedef enum { CLICK_BORDER = 0,
CLICK_DECORATION = 1,
CLICK_INSIDE = 2 } click_destination_t;
/* /*
* Finds the correct pair of first/second cons between the resize will take * Finds the correct pair of first/second cons between the resize will take

View File

@ -18,7 +18,8 @@
// Macros to make the YAJL API a bit easier to use. // Macros to make the YAJL API a bit easier to use.
#define y(x, ...) (cmd_output->json_gen != NULL ? yajl_gen_##x(cmd_output->json_gen, ##__VA_ARGS__) : 0) #define y(x, ...) (cmd_output->json_gen != NULL ? yajl_gen_##x(cmd_output->json_gen, ##__VA_ARGS__) : 0)
#define ystr(str) (cmd_output->json_gen != NULL ? yajl_gen_string(cmd_output->json_gen, (unsigned char *)str, strlen(str)) : 0) #define ystr(str) (cmd_output->json_gen != NULL ? yajl_gen_string(cmd_output->json_gen, (unsigned char *)str, strlen(str)) : 0)
#define ysuccess(success) do { \ #define ysuccess(success) \
do { \
if (cmd_output->json_gen != NULL) { \ if (cmd_output->json_gen != NULL) { \
y(map_open); \ y(map_open); \
ystr("success"); \ ystr("success"); \
@ -26,7 +27,8 @@
y(map_close); \ y(map_close); \
} \ } \
} while (0) } while (0)
#define yerror(message) do { \ #define yerror(message) \
do { \
if (cmd_output->json_gen != NULL) { \ if (cmd_output->json_gen != NULL) { \
y(map_open); \ y(map_open); \
ystr("success"); \ ystr("success"); \
@ -42,7 +44,8 @@
* criteria but which did not match any windows. This macro has to be called in * criteria but which did not match any windows. This macro has to be called in
* every command. * every command.
*/ */
#define HANDLE_EMPTY_MATCH do { \ #define HANDLE_EMPTY_MATCH \
do { \
if (match_is_empty(current_match)) { \ if (match_is_empty(current_match)) { \
owindow *ow = smalloc(sizeof(owindow)); \ owindow *ow = smalloc(sizeof(owindow)); \
ow->con = focused; \ ow->con = focused; \
@ -51,7 +54,6 @@
} \ } \
} while (0) } while (0)
/* /*
* Returns true if a is definitely greater than b (using the given epsilon) * Returns true if a is definitely greater than b (using the given epsilon)
* *
@ -76,7 +78,8 @@ static Output *get_output_from_string(Output *current_output, const char *output
output = get_output_next_wrap(D_UP, current_output); output = get_output_next_wrap(D_UP, current_output);
else if (strcasecmp(output_str, "down") == 0) else if (strcasecmp(output_str, "down") == 0)
output = get_output_next_wrap(D_DOWN, current_output); output = get_output_next_wrap(D_DOWN, current_output);
else output = get_output_by_name(output_str); else
output = get_output_by_name(output_str);
return output; return output;
} }
@ -502,8 +505,7 @@ void cmd_move_con_to_workspace_name(I3_CMD, char *name) {
ELOG("No windows match your criteria, cannot move.\n"); ELOG("No windows match your criteria, cannot move.\n");
ysuccess(false); ysuccess(false);
return; return;
} } else if (match_is_empty(current_match) && focused->type == CT_WORKSPACE &&
else if (match_is_empty(current_match) && focused->type == CT_WORKSPACE &&
!con_has_children(focused)) { !con_has_children(focused)) {
ysuccess(false); ysuccess(false);
return; return;
@ -1398,7 +1400,8 @@ void cmd_focus_window_mode(I3_CMD, char *window_mode) {
current = TAILQ_FIRST(&(ws->focus_head)); current = TAILQ_FIRST(&(ws->focus_head));
if (current != NULL && current->type == CT_FLOATING_CON) if (current != NULL && current->type == CT_FLOATING_CON)
window_mode = "tiling"; window_mode = "tiling";
else window_mode = "floating"; else
window_mode = "floating";
} }
TAILQ_FOREACH (current, &(ws->focus_head), focused) { TAILQ_FOREACH (current, &(ws->focus_head), focused) {
if ((strcmp(window_mode, "floating") == 0 && current->type != CT_FLOATING_CON) || if ((strcmp(window_mode, "floating") == 0 && current->type != CT_FLOATING_CON) ||
@ -1435,7 +1438,8 @@ void cmd_focus_level(I3_CMD, char *level) {
} }
/* Focusing a child should always be allowed. */ /* Focusing a child should always be allowed. */
else success = level_down(); else
success = level_down();
cmd_output->needs_tree_render = success; cmd_output->needs_tree_render = success;
// XXX: default reply for now, make this a better reply // XXX: default reply for now, make this a better reply
@ -1510,7 +1514,8 @@ void cmd_focus(I3_CMD) {
if (count > 1) if (count > 1)
LOG("WARNING: Your criteria for the focus command matches %d containers, " LOG("WARNING: Your criteria for the focus command matches %d containers, "
"while only exactly one container can be focused at a time.\n", count); "while only exactly one container can be focused at a time.\n",
count);
cmd_output->needs_tree_render = true; cmd_output->needs_tree_render = true;
// XXX: default reply for now, make this a better reply // XXX: default reply for now, make this a better reply
@ -1563,10 +1568,7 @@ void cmd_move_direction(I3_CMD, char *direction, char *move_px) {
} }
floating_reposition(focused->parent, newrect); floating_reposition(focused->parent, newrect);
} else { } else {
tree_move((strcmp(direction, "right") == 0 ? D_RIGHT : tree_move((strcmp(direction, "right") == 0 ? D_RIGHT : (strcmp(direction, "left") == 0 ? D_LEFT : (strcmp(direction, "up") == 0 ? D_UP : D_DOWN))));
(strcmp(direction, "left") == 0 ? D_LEFT :
(strcmp(direction, "up") == 0 ? D_UP :
D_DOWN))));
cmd_output->needs_tree_render = true; cmd_output->needs_tree_render = true;
} }
@ -1763,7 +1765,6 @@ void cmd_focus_output(I3_CMD, char *name) {
* *
*/ */
void cmd_move_window_to_position(I3_CMD, char *method, char *cx, char *cy) { void cmd_move_window_to_position(I3_CMD, char *method, char *cx, char *cy) {
int x = atoi(cx); int x = atoi(cx);
int y = atoi(cy); int y = atoi(cy);
@ -1801,7 +1802,6 @@ void cmd_move_window_to_position(I3_CMD, char *method, char *cx, char *cy) {
* *
*/ */
void cmd_move_window_to_center(I3_CMD, char *method) { void cmd_move_window_to_center(I3_CMD, char *method) {
if (!con_is_floating(focused)) { if (!con_is_floating(focused)) {
ELOG("Cannot change position. The window/container is not floating\n"); ELOG("Cannot change position. The window/container is not floating\n");
yerror("Cannot change position. The window/container is not floating."); yerror("Cannot change position. The window/container is not floating.");
@ -1932,7 +1932,8 @@ void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) {
parsed_num < 0 || parsed_num < 0 ||
endptr == new_name) endptr == new_name)
workspace->num = -1; workspace->num = -1;
else workspace->num = parsed_num; else
workspace->num = parsed_num;
LOG("num = %d\n", workspace->num); LOG("num = %d\n", workspace->num);
/* By re-attaching, the sort order will be correct afterwards. */ /* By re-attaching, the sort order will be correct afterwards. */

View File

@ -184,7 +184,6 @@ static struct CommandResultIR command_output;
#include "GENERATED_command_call.h" #include "GENERATED_command_call.h"
static void next_state(const cmdp_token *token) { static void next_state(const cmdp_token *token) {
if (token->next_state == __CALL) { if (token->next_state == __CALL) {
subcommand_output.json_gen = command_output.json_gen; subcommand_output.json_gen = command_output.json_gen;
@ -239,7 +238,8 @@ CommandResult *parse_command(const char *input, yajl_gen gen) {
while ((size_t)(walk - input) <= len) { while ((size_t)(walk - input) <= len) {
/* skip whitespace and newlines before every token */ /* skip whitespace and newlines before every token */
while ((*walk == ' ' || *walk == '\t' || while ((*walk == ' ' || *walk == '\t' ||
*walk == '\r' || *walk == '\n') && *walk != '\0') *walk == '\r' || *walk == '\n') &&
*walk != '\0')
walk++; walk++;
cmdp_token_ptr *ptr = &(tokens[state]); cmdp_token_ptr *ptr = &(tokens[state]);

View File

@ -23,8 +23,7 @@ char *colors[] = {
"#aa0000", "#aa0000",
"#00aa00", "#00aa00",
"#0000aa", "#0000aa",
"#aa00aa" "#aa00aa"};
};
static void con_on_remove_child(Con *con); static void con_on_remove_child(Con *con);
@ -130,7 +129,8 @@ void con_attach(Con *con, Con *parent, bool ignore_focus) {
/* we need to insert con after current, if current is not NULL */ /* we need to insert con after current, if current is not NULL */
if (current) if (current)
TAILQ_INSERT_BEFORE(current, con, nodes); TAILQ_INSERT_BEFORE(current, con, nodes);
else TAILQ_INSERT_TAIL(nodes_head, con, nodes); else
TAILQ_INSERT_TAIL(nodes_head, con, nodes);
} }
} }
goto add_to_focus_head; goto add_to_focus_head;
@ -178,7 +178,8 @@ void con_attach(Con *con, Con *parent, bool ignore_focus) {
DLOG("Inserting con = %p after last focused tiling con %p\n", DLOG("Inserting con = %p after last focused tiling con %p\n",
con, current); con, current);
TAILQ_INSERT_AFTER(nodes_head, current, con, nodes); TAILQ_INSERT_AFTER(nodes_head, current, con, nodes);
} else TAILQ_INSERT_TAIL(nodes_head, con, nodes); } else
TAILQ_INSERT_TAIL(nodes_head, con, nodes);
} }
add_to_focus_head: add_to_focus_head:
@ -246,10 +247,7 @@ bool con_is_leaf(Con *con) {
* excluding dock containers) * excluding dock containers)
*/ */
bool con_has_managed_window(Con *con) { bool con_has_managed_window(Con *con) {
return (con != NULL return (con != NULL && con->window != NULL && con->window->id != XCB_WINDOW_NONE && con_get_workspace(con) != NULL);
&& con->window != NULL
&& con->window->id != XCB_WINDOW_NONE
&& con_get_workspace(con) != NULL);
} }
/** /**
@ -563,7 +561,8 @@ void con_fix_percent(Con *con) {
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);
else total += (child->percent = total / children_with_percent); else
total += (child->percent = total / children_with_percent);
} }
} }
} }
@ -733,7 +732,8 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
* to the coordinate space of the correct output */ * to the coordinate space of the correct output */
if (fix_coordinates && con->type == CT_FLOATING_CON) { if (fix_coordinates && con->type == CT_FLOATING_CON) {
floating_fix_coordinates(con, &(source_output->rect), &(dest_output->rect)); floating_fix_coordinates(con, &(source_output->rect), &(dest_output->rect));
} else DLOG("Not fixing coordinates, fix_coordinates flag = %d\n", fix_coordinates); } else
DLOG("Not fixing coordinates, fix_coordinates flag = %d\n", fix_coordinates);
/* If moving to a visible workspace, call show so it can be considered /* If moving to a visible workspace, call show so it can be considered
* focused. Must do before attaching because workspace_show checks to see * focused. Must do before attaching because workspace_show checks to see
@ -1032,7 +1032,8 @@ Con *con_descend_direction(Con *con, direction_t direction) {
* (D_RIGHT) or the last con (D_LEFT) */ * (D_RIGHT) or the last con (D_LEFT) */
if (direction == D_RIGHT) if (direction == D_RIGHT)
most = TAILQ_FIRST(&(con->nodes_head)); most = TAILQ_FIRST(&(con->nodes_head));
else most = TAILQ_LAST(&(con->nodes_head), nodes_head); else
most = TAILQ_LAST(&(con->nodes_head), nodes_head);
} else if (orientation == VERT) { } else if (orientation == VERT) {
/* 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
@ -1056,7 +1057,8 @@ Con *con_descend_direction(Con *con, direction_t direction) {
* (D_DOWN) or the last con (D_UP) */ * (D_DOWN) or the last con (D_UP) */
if (direction == D_UP) if (direction == D_UP)
most = TAILQ_LAST(&(con->nodes_head), nodes_head); most = TAILQ_LAST(&(con->nodes_head), nodes_head);
else most = TAILQ_FIRST(&(con->nodes_head)); else
most = TAILQ_FIRST(&(con->nodes_head));
} else if (orientation == HORIZ) { } else if (orientation == HORIZ) {
/* 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
@ -1129,7 +1131,6 @@ Rect con_border_style_rect(Con *con) {
result.height += border_width; result.height += border_width;
} }
return result; return result;
} }
/* /*
@ -1333,7 +1334,8 @@ void con_toggle_layout(Con *con, const char *toggle_mode) {
else { else {
if (parent->layout == L_SPLITH) if (parent->layout == L_SPLITH)
con_set_layout(con, L_SPLITV); con_set_layout(con, L_SPLITV);
else con_set_layout(con, L_SPLITH); else
con_set_layout(con, L_SPLITH);
} }
} else { } else {
if (parent->layout == L_STACKED) if (parent->layout == L_STACKED)
@ -1341,7 +1343,8 @@ void con_toggle_layout(Con *con, const char *toggle_mode) {
else if (parent->layout == L_TABBED) { else if (parent->layout == L_TABBED) {
if (strcmp(toggle_mode, "all") == 0) if (strcmp(toggle_mode, "all") == 0)
con_set_layout(con, L_SPLITH); con_set_layout(con, L_SPLITH);
else con_set_layout(con, parent->last_split_layout); else
con_set_layout(con, parent->last_split_layout);
} else if (parent->layout == L_SPLITH || parent->layout == L_SPLITV) { } else if (parent->layout == L_SPLITH || parent->layout == L_SPLITV) {
if (strcmp(toggle_mode, "all") == 0) { if (strcmp(toggle_mode, "all") == 0) {
/* When toggling through all modes, we toggle between /* When toggling through all modes, we toggle between
@ -1349,7 +1352,8 @@ void con_toggle_layout(Con *con, const char *toggle_mode) {
* stacked. */ * stacked. */
if (parent->layout == L_SPLITH) if (parent->layout == L_SPLITH)
con_set_layout(con, L_SPLITV); con_set_layout(con, L_SPLITV);
else con_set_layout(con, L_STACKED); else
con_set_layout(con, L_STACKED);
} else { } else {
con_set_layout(con, L_STACKED); con_set_layout(con, L_STACKED);
} }

View File

@ -105,8 +105,7 @@ static char *get_config_path(const char *override_configpath) {
free(buf); free(buf);
die("Unable to find the configuration file (looked at " die("Unable to find the configuration file (looked at "
"~/.i3/config, $XDG_CONFIG_HOME/i3/config, " "~/.i3/config, $XDG_CONFIG_HOME/i3/config, " SYSCONFDIR "/i3/config and $XDG_CONFIG_DIRS/i3/config)");
SYSCONFDIR "/i3/config and $XDG_CONFIG_DIRS/i3/config)");
} }
/* /*

View File

@ -175,7 +175,6 @@ CFGFUN(binding, const char *bindtype, const char *modifiers, const char *key, co
configure_binding(bindtype, modifiers, key, release, command, DEFAULT_BINDING_MODE); configure_binding(bindtype, modifiers, key, release, command, DEFAULT_BINDING_MODE);
} }
/******************************************************************************* /*******************************************************************************
* Mode handling * Mode handling
******************************************************************************/ ******************************************************************************/
@ -239,7 +238,8 @@ CFGFUN(default_orientation, const char *orientation) {
config.default_orientation = HORIZ; config.default_orientation = HORIZ;
else if (strcmp(orientation, "vertical") == 0) else if (strcmp(orientation, "vertical") == 0)
config.default_orientation = VERT; config.default_orientation = VERT;
else config.default_orientation = NO_ORIENTATION; else
config.default_orientation = NO_ORIENTATION;
} }
CFGFUN(workspace_layout, const char *layout) { CFGFUN(workspace_layout, const char *layout) {
@ -248,7 +248,8 @@ CFGFUN(workspace_layout, const char *layout) {
else if (strcmp(layout, "stacking") == 0 || else if (strcmp(layout, "stacking") == 0 ||
strcmp(layout, "stacked") == 0) strcmp(layout, "stacked") == 0)
config.default_layout = L_STACKED; config.default_layout = L_STACKED;
else config.default_layout = L_TABBED; else
config.default_layout = L_TABBED;
} }
CFGFUN(new_window, const char *windowtype, const char *border, const long width) { CFGFUN(new_window, const char *windowtype, const char *border, const long width) {
@ -291,7 +292,8 @@ CFGFUN(hide_edge_borders, const char *borders) {
config.hide_edge_borders = ADJ_NONE; config.hide_edge_borders = ADJ_NONE;
else if (eval_boolstr(borders)) else if (eval_boolstr(borders))
config.hide_edge_borders = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE; config.hide_edge_borders = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE;
else config.hide_edge_borders = ADJ_NONE; else
config.hide_edge_borders = ADJ_NONE;
} }
CFGFUN(focus_follows_mouse, const char *value) { CFGFUN(focus_follows_mouse, const char *value) {

View File

@ -146,7 +146,6 @@ static void push_long(const char *identifier, long num) {
"in the code, or a new command which contains more than " "in the code, or a new command which contains more than "
"10 identified tokens.\n"); "10 identified tokens.\n");
exit(1); exit(1);
} }
static const char *get_string(const char *identifier) { static const char *get_string(const char *identifier) {
@ -246,7 +245,6 @@ static int statelist_idx = 1;
#include "GENERATED_config_call.h" #include "GENERATED_config_call.h"
static void next_state(const cmdp_token *token) { static void next_state(const cmdp_token *token) {
cmdp_state _next_state = token->next_state; cmdp_state _next_state = token->next_state;
@ -516,7 +514,6 @@ struct ConfigResultIR *parse_config(const char *input, struct context *context)
possible_tokens); possible_tokens);
free(possible_tokens); free(possible_tokens);
/* Go back to the beginning of the line */ /* Go back to the beginning of the line */
const char *error_line = start_of_line(walk, input); const char *error_line = start_of_line(walk, input);
@ -770,8 +767,7 @@ static char *migrate_config(char *input, off_t size) {
static char *argv[] = { static char *argv[] = {
NULL, /* will be replaced by the executable path */ NULL, /* will be replaced by the executable path */
NULL NULL};
};
exec_i3_utility("i3-migrate-config-to-v4", argv); exec_i3_utility("i3-migrate-config-to-v4", argv);
} }
@ -996,7 +992,6 @@ void parse_file(const char *f) {
} }
} }
context = scalloc(sizeof(struct context)); context = scalloc(sizeof(struct context));
context->filename = f; context->filename = f;
@ -1021,17 +1016,14 @@ void parse_file(const char *f) {
"-t", "-t",
(context->has_errors ? "error" : "warning"), (context->has_errors ? "error" : "warning"),
"-m", "-m",
(context->has_errors ? (context->has_errors ? "You have an error in your i3 config file!" : "Your config is outdated. Please fix the warnings to make sure everything works."),
"You have an error in your i3 config file!" :
"Your config is outdated. Please fix the warnings to make sure everything works."),
"-b", "-b",
"edit config", "edit config",
editaction, editaction,
(errorfilename ? "-b" : NULL), (errorfilename ? "-b" : NULL),
(context->has_errors ? "show errors" : "show warnings"), (context->has_errors ? "show errors" : "show warnings"),
pageraction, pageraction,
NULL NULL};
};
start_nagbar(&config_error_nagbar_pid, argv); start_nagbar(&config_error_nagbar_pid, argv);
free(editaction); free(editaction);

View File

@ -60,7 +60,8 @@ void fake_outputs_init(const char *output_spec) {
/* We always treat the screen at 0x0 as the primary screen */ /* We always treat the screen at 0x0 as the primary screen */
if (new_output->rect.x == 0 && new_output->rect.y == 0) if (new_output->rect.x == 0 && new_output->rect.y == 0)
TAILQ_INSERT_HEAD(&outputs, new_output, outputs); TAILQ_INSERT_HEAD(&outputs, new_output, outputs);
else TAILQ_INSERT_TAIL(&outputs, new_output, outputs); else
TAILQ_INSERT_TAIL(&outputs, new_output, outputs);
output_init_con(new_output); output_init_con(new_output);
init_ws_for_output(new_output, output_get_content(new_output->con)); init_ws_for_output(new_output, output_get_content(new_output->con));
num_screens++; num_screens++;

View File

@ -258,7 +258,8 @@ void floating_enable(Con *con, bool automatic) {
/* Sanity check: Are the coordinates on the appropriate output? If not, we /* Sanity check: Are the coordinates on the appropriate output? If not, we
* need to change them */ * need to change them */
Output *current_output = get_output_containing(nc->rect.x + Output *current_output = get_output_containing(nc->rect.x +
(nc->rect.width / 2), nc->rect.y + (nc->rect.height / 2)); (nc->rect.width / 2),
nc->rect.y + (nc->rect.height / 2));
Con *correct_output = con_get_output(ws); Con *correct_output = con_get_output(ws);
if (!current_output || current_output->con != correct_output) { if (!current_output || current_output->con != correct_output) {
@ -336,7 +337,8 @@ void floating_disable(Con *con, bool automatic) {
* workspace itself */ * workspace itself */
if (focused->type == CT_WORKSPACE) if (focused->type == CT_WORKSPACE)
con->parent = focused; con->parent = focused;
else con->parent = focused->parent; else
con->parent = focused->parent;
/* con_fix_percent will adjust the percent value */ /* con_fix_percent will adjust the percent value */
con->percent = 0.0; con->percent = 0.0;
@ -487,11 +489,13 @@ DRAGGING_CB(resize_window_callback) {
* taking into account in which corner the client was grabbed */ * taking into account in which corner the client was grabbed */
if (corner & BORDER_LEFT) if (corner & BORDER_LEFT)
dest_width = old_rect->width - (new_x - event->root_x); dest_width = old_rect->width - (new_x - event->root_x);
else dest_width = old_rect->width + (new_x - event->root_x); else
dest_width = old_rect->width + (new_x - event->root_x);
if (corner & BORDER_TOP) if (corner & BORDER_TOP)
dest_height = old_rect->height - (new_y - event->root_y); dest_height = old_rect->height - (new_y - event->root_y);
else dest_height = old_rect->height + (new_y - event->root_y); else
dest_height = old_rect->height + (new_y - event->root_y);
/* User wants to keep proportions, so we may have to adjust our values */ /* User wants to keep proportions, so we may have to adjust our values */
if (params->proportional) { if (params->proportional) {
@ -537,18 +541,16 @@ void floating_resize_window(Con *con, const bool proportional,
if (event->event_x <= (int16_t)(con->rect.width / 2)) if (event->event_x <= (int16_t)(con->rect.width / 2))
corner |= BORDER_LEFT; corner |= BORDER_LEFT;
else corner |= BORDER_RIGHT; else
corner |= BORDER_RIGHT;
int cursor = 0; int cursor = 0;
if (event->event_y <= (int16_t)(con->rect.height / 2)) { if (event->event_y <= (int16_t)(con->rect.height / 2)) {
corner |= BORDER_TOP; corner |= BORDER_TOP;
cursor = (corner & BORDER_LEFT) ? cursor = (corner & BORDER_LEFT) ? XCURSOR_CURSOR_TOP_LEFT_CORNER : XCURSOR_CURSOR_TOP_RIGHT_CORNER;
XCURSOR_CURSOR_TOP_LEFT_CORNER : XCURSOR_CURSOR_TOP_RIGHT_CORNER; } else {
}
else {
corner |= BORDER_BOTTOM; corner |= BORDER_BOTTOM;
cursor = (corner & BORDER_LEFT) ? cursor = (corner & BORDER_LEFT) ? XCURSOR_CURSOR_BOTTOM_LEFT_CORNER : XCURSOR_CURSOR_BOTTOM_RIGHT_CORNER;
XCURSOR_CURSOR_BOTTOM_LEFT_CORNER : XCURSOR_CURSOR_BOTTOM_RIGHT_CORNER;
} }
struct resize_window_callback_params params = {corner, proportional, event}; struct resize_window_callback_params params = {corner, proportional, event};
@ -664,7 +666,6 @@ static void xcb_drag_check_cb(EV_P_ ev_check *w, int revents) {
free(last_motion_notify); free(last_motion_notify);
} }
/* /*
* This function grabs your pointer and keyboard and lets you drag stuff around * This function grabs your pointer and keyboard and lets you drag stuff around
* (borders). Every time you move your mouse, an XCB_MOTION_NOTIFY event will * (borders). Every time you move your mouse, an XCB_MOTION_NOTIFY event will
@ -674,10 +675,9 @@ static void xcb_drag_check_cb(EV_P_ ev_check *w, int revents) {
* *
*/ */
drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t
confine_to, border_t border, int cursor, callback_t callback, const void *extra) confine_to,
{ border_t border, int cursor, callback_t callback, const void *extra) {
xcb_cursor_t xcursor = (cursor && xcursor_supported) ? xcb_cursor_t xcursor = (cursor && xcursor_supported) ? xcursor_get_cursor(cursor) : XCB_NONE;
xcursor_get_cursor(cursor) : XCB_NONE;
/* Grab the pointer */ /* Grab the pointer */
xcb_grab_pointer_cookie_t cookie; xcb_grab_pointer_cookie_t cookie;
@ -797,10 +797,8 @@ void floating_fix_coordinates(Con *con, Rect *old_rect, Rect *new_rect) {
rel_x, rel_y, (double)rel_x / old_rect->width, (double)rel_y / old_rect->height, rel_x, rel_y, (double)rel_x / old_rect->width, (double)rel_y / old_rect->height,
old_rect->width, old_rect->height); old_rect->width, old_rect->height);
/* Here we have to multiply at first. Or we will lose precision when not compiled with -msse2 */ /* Here we have to multiply at first. Or we will lose precision when not compiled with -msse2 */
con->rect.x = (int32_t)new_rect->x + (double)(rel_x * (int32_t)new_rect->width) con->rect.x = (int32_t)new_rect->x + (double)(rel_x * (int32_t)new_rect->width) / (int32_t)old_rect->width - (int32_t)(con->rect.width / 2);
/ (int32_t)old_rect->width - (int32_t)(con->rect.width / 2); con->rect.y = (int32_t)new_rect->y + (double)(rel_y * (int32_t)new_rect->height) / (int32_t)old_rect->height - (int32_t)(con->rect.height / 2);
con->rect.y = (int32_t)new_rect->y + (double)(rel_y * (int32_t)new_rect->height)
/ (int32_t)old_rect->height - (int32_t)(con->rect.height / 2);
DLOG("Resulting coordinates: x = %d, y = %d\n", con->rect.x, con->rect.y); DLOG("Resulting coordinates: x = %d, y = %d\n", con->rect.x, con->rect.y);
} }

View File

@ -58,7 +58,8 @@ bool event_is_ignored(const int sequence, const int response_type) {
event = SLIST_NEXT(event, ignore_events); event = SLIST_NEXT(event, ignore_events);
SLIST_REMOVE(&ignore_events, save, Ignore_Event, ignore_events); SLIST_REMOVE(&ignore_events, save, Ignore_Event, ignore_events);
free(save); free(save);
} else event = SLIST_NEXT(event, ignore_events); } else
event = SLIST_NEXT(event, ignore_events);
} }
SLIST_FOREACH (event, &ignore_events, ignore_events) { SLIST_FOREACH (event, &ignore_events, ignore_events) {
@ -208,7 +209,6 @@ static void handle_enter_notify(xcb_enter_notify_event_t *event) {
* *
*/ */
static void handle_motion_notify(xcb_motion_notify_event_t *event) { static void handle_motion_notify(xcb_motion_notify_event_t *event) {
last_timestamp = event->time; last_timestamp = event->time;
/* Skip events where the pointer was over a child window, we are only /* Skip events where the pointer was over a child window, we are only
@ -308,7 +308,8 @@ static void handle_configure_request(xcb_configure_request_event_t *event) {
uint32_t mask = 0; uint32_t mask = 0;
uint32_t values[7]; uint32_t values[7];
int c = 0; int c = 0;
#define COPY_MASK_MEMBER(mask_member, event_member) do { \ #define COPY_MASK_MEMBER(mask_member, event_member) \
do { \
if (event->value_mask & mask_member) { \ if (event->value_mask & mask_member) { \
mask |= mask_member; \ mask |= mask_member; \
values[c++] = event->event_member; \ values[c++] = event->event_member; \
@ -903,7 +904,8 @@ static bool handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t stat
aspect_ratio = min_aspect; aspect_ratio = min_aspect;
} else if ((width / height) > max_aspect) { } else if ((width / height) > max_aspect) {
aspect_ratio = max_aspect; aspect_ratio = max_aspect;
} else goto render_and_return; } else
goto render_and_return;
if (fabs(con->aspect_ratio - aspect_ratio) > DBL_EPSILON) { if (fabs(con->aspect_ratio - aspect_ratio) > DBL_EPSILON) {
con->aspect_ratio = aspect_ratio; con->aspect_ratio = aspect_ratio;
@ -957,7 +959,8 @@ static bool handle_transient_for(void *data, xcb_connection_t *conn, uint8_t sta
if (prop == NULL) { if (prop == NULL) {
prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn, prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
false, window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 0, 32), NULL); false, window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 0, 32),
NULL);
if (prop == NULL) if (prop == NULL)
return false; return false;
} }
@ -980,7 +983,8 @@ static bool handle_clientleader_change(void *data, xcb_connection_t *conn, uint8
if (prop == NULL) { if (prop == NULL) {
prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn, prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
false, window, A_WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 32), NULL); false, window, A_WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 32),
NULL);
if (prop == NULL) if (prop == NULL)
return false; return false;
} }
@ -1058,8 +1062,7 @@ static struct property_handler_t property_handlers[] = {
{0, UINT_MAX, handle_normal_hints}, {0, UINT_MAX, handle_normal_hints},
{0, UINT_MAX, handle_clientleader_change}, {0, UINT_MAX, handle_clientleader_change},
{0, UINT_MAX, handle_transient_for}, {0, UINT_MAX, handle_transient_for},
{ 0, 128, handle_windowrole_change } {0, 128, handle_windowrole_change}};
};
#define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t)) #define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t))
/* /*
@ -1068,7 +1071,6 @@ static struct property_handler_t property_handlers[] = {
* *
*/ */
void property_handlers_init(void) { void property_handlers_init(void) {
sn_monitor_context_new(sndisplay, conn_screen, startup_monitor_event, NULL, NULL); sn_monitor_context_new(sndisplay, conn_screen, startup_monitor_event, NULL, NULL);
property_handlers[0].atom = A__NET_WM_NAME; property_handlers[0].atom = A__NET_WM_NAME;

View File

@ -189,7 +189,8 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
else { else {
if (con_orientation(con) == HORIZ) if (con_orientation(con) == HORIZ)
ystr("horizontal"); ystr("horizontal");
else ystr("vertical"); else
ystr("vertical");
} }
ystr("scratchpad_state"); ystr("scratchpad_state");
@ -208,7 +209,8 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
ystr("percent"); ystr("percent");
if (con->percent == 0.0) if (con->percent == 0.0)
y(null); y(null);
else y(double, con->percent); else
y(double, con->percent);
ystr("urgent"); ystr("urgent");
y(bool, con->urgent); y(bool, con->urgent);
@ -308,7 +310,8 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
ystr("window"); ystr("window");
if (con->window) if (con->window)
y(integer, con->window->id); y(integer, con->window->id);
else y(null); else
y(null);
if (con->window && !inplace_restart) { if (con->window && !inplace_restart) {
/* Window properties are useless to preserve when restarting because /* Window properties are useless to preserve when restarting because
@ -317,7 +320,8 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
ystr("window_properties"); ystr("window_properties");
y(map_open); y(map_open);
#define DUMP_PROPERTY(key, prop_name) do { \ #define DUMP_PROPERTY(key, prop_name) \
do { \
if (con->window->prop_name != NULL) { \ if (con->window->prop_name != NULL) { \
ystr(key); \ ystr(key); \
ystr(con->window->prop_name); \ ystr(con->window->prop_name); \
@ -391,7 +395,8 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
y(integer, match->insert_where); y(integer, match->insert_where);
} }
#define DUMP_REGEX(re_name) do { \ #define DUMP_REGEX(re_name) \
do { \
if (match->re_name != NULL) { \ if (match->re_name != NULL) { \
ystr(#re_name); \ ystr(#re_name); \
ystr(match->re_name->pattern); \ ystr(match->re_name->pattern); \
@ -510,7 +515,8 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
ystr("position"); ystr("position");
if (config->position == P_BOTTOM) if (config->position == P_BOTTOM)
ystr("bottom"); ystr("bottom");
else ystr("top"); else
ystr("top");
YSTR_IF_SET(status_command); YSTR_IF_SET(status_command);
YSTR_IF_SET(font); YSTR_IF_SET(font);
@ -573,7 +579,6 @@ IPC_HANDLER(tree) {
y(free); y(free);
} }
/* /*
* Formats the reply message for a GET_WORKSPACES request and sends it to the * Formats the reply message for a GET_WORKSPACES request and sends it to the
* client * client
@ -597,7 +602,8 @@ IPC_HANDLER(get_workspaces) {
ystr("num"); ystr("num");
if (ws->num == -1) if (ws->num == -1)
y(null); y(null);
else y(integer, ws->num); else
y(integer, ws->num);
ystr("name"); ystr("name");
ystr(ws->name); ystr(ws->name);
@ -678,7 +684,8 @@ IPC_HANDLER(get_outputs) {
Con *ws = NULL; Con *ws = NULL;
if (output->con && (ws = con_get_fullscreen_con(output->con, CF_OUTPUT))) if (output->con && (ws = con_get_fullscreen_con(output->con, CF_OUTPUT)))
ystr(ws->name); ystr(ws->name);
else y(null); else
y(null);
y(map_close); y(map_close);
} }
@ -970,7 +977,8 @@ void ipc_new_client(EV_P_ struct ev_io *w, int revents) {
if ((client = accept(w->fd, (struct sockaddr *)&peer, &len)) < 0) { if ((client = accept(w->fd, (struct sockaddr *)&peer, &len)) < 0) {
if (errno == EINTR) if (errno == EINTR)
return; return;
else perror("accept()"); else
perror("accept()");
return; return;
} }

View File

@ -195,7 +195,8 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
json_node->last_split_layout = L_SPLITH; json_node->last_split_layout = L_SPLITH;
else if (strcasecmp(buf, "vertical") == 0) else if (strcasecmp(buf, "vertical") == 0)
json_node->last_split_layout = L_SPLITV; json_node->last_split_layout = L_SPLITV;
else LOG("Unhandled orientation: %s\n", buf); else
LOG("Unhandled orientation: %s\n", buf);
free(buf); free(buf);
} else if (strcasecmp(last_key, "border") == 0) { } else if (strcasecmp(last_key, "border") == 0) {
char *buf = NULL; char *buf = NULL;
@ -209,7 +210,8 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
json_node->border_style = BS_PIXEL; json_node->border_style = BS_PIXEL;
else if (strcasecmp(buf, "normal") == 0) else if (strcasecmp(buf, "normal") == 0)
json_node->border_style = BS_NORMAL; json_node->border_style = BS_NORMAL;
else LOG("Unhandled \"border\": %s\n", buf); else
LOG("Unhandled \"border\": %s\n", buf);
free(buf); free(buf);
} else if (strcasecmp(last_key, "type") == 0) { } else if (strcasecmp(last_key, "type") == 0) {
char *buf = NULL; char *buf = NULL;
@ -226,7 +228,8 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
json_node->type = CT_WORKSPACE; json_node->type = CT_WORKSPACE;
else if (strcasecmp(buf, "dockarea") == 0) else if (strcasecmp(buf, "dockarea") == 0)
json_node->type = CT_DOCKAREA; json_node->type = CT_DOCKAREA;
else LOG("Unhandled \"type\": %s\n", buf); else
LOG("Unhandled \"type\": %s\n", buf);
free(buf); free(buf);
} else if (strcasecmp(last_key, "layout") == 0) { } else if (strcasecmp(last_key, "layout") == 0) {
char *buf = NULL; char *buf = NULL;
@ -246,7 +249,8 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
json_node->layout = L_SPLITH; json_node->layout = L_SPLITH;
else if (strcasecmp(buf, "splitv") == 0) else if (strcasecmp(buf, "splitv") == 0)
json_node->layout = L_SPLITV; json_node->layout = L_SPLITV;
else LOG("Unhandled \"layout\": %s\n", buf); else
LOG("Unhandled \"layout\": %s\n", buf);
free(buf); free(buf);
} else if (strcasecmp(last_key, "workspace_layout") == 0) { } else if (strcasecmp(last_key, "workspace_layout") == 0) {
char *buf = NULL; char *buf = NULL;
@ -257,7 +261,8 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
json_node->workspace_layout = L_STACKED; json_node->workspace_layout = L_STACKED;
else if (strcasecmp(buf, "tabbed") == 0) else if (strcasecmp(buf, "tabbed") == 0)
json_node->workspace_layout = L_TABBED; json_node->workspace_layout = L_TABBED;
else LOG("Unhandled \"workspace_layout\": %s\n", buf); else
LOG("Unhandled \"workspace_layout\": %s\n", buf);
free(buf); free(buf);
} else if (strcasecmp(last_key, "last_split_layout") == 0) { } else if (strcasecmp(last_key, "last_split_layout") == 0) {
char *buf = NULL; char *buf = NULL;
@ -266,7 +271,8 @@ static int json_string(void *ctx, const unsigned char *val, size_t len) {
json_node->last_split_layout = L_SPLITH; json_node->last_split_layout = L_SPLITH;
else if (strcasecmp(buf, "splitv") == 0) else if (strcasecmp(buf, "splitv") == 0)
json_node->last_split_layout = L_SPLITV; json_node->last_split_layout = L_SPLITV;
else LOG("Unhandled \"last_splitlayout\": %s\n", buf); else
LOG("Unhandled \"last_splitlayout\": %s\n", buf);
free(buf); free(buf);
} else if (strcasecmp(last_key, "mark") == 0) { } else if (strcasecmp(last_key, "mark") == 0) {
char *buf = NULL; char *buf = NULL;
@ -332,7 +338,8 @@ static int json_int(void *ctx, long long val) {
r = &(json_node->rect); r = &(json_node->rect);
else if (parsing_window_rect) else if (parsing_window_rect)
r = &(json_node->window_rect); r = &(json_node->window_rect);
else r = &(json_node->geometry); else
r = &(json_node->geometry);
if (strcasecmp(last_key, "x") == 0) if (strcasecmp(last_key, "x") == 0)
r->x = val; r->x = val;
else if (strcasecmp(last_key, "y") == 0) else if (strcasecmp(last_key, "y") == 0)
@ -341,7 +348,8 @@ static int json_int(void *ctx, long long val) {
r->width = val; r->width = val;
else if (strcasecmp(last_key, "height") == 0) else if (strcasecmp(last_key, "height") == 0)
r->height = val; r->height = val;
else ELOG("WARNING: unknown key %s in rect\n", last_key); else
ELOG("WARNING: unknown key %s in rect\n", last_key);
DLOG("rect now: (%d, %d, %d, %d)\n", DLOG("rect now: (%d, %d, %d, %d)\n",
r->x, r->y, r->width, r->height); r->x, r->y, r->width, r->height);
} }
@ -430,8 +438,7 @@ void tree_append_json(Con *con, const char *filename, char **errormsg) {
parsing_focus = false; parsing_focus = false;
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
stat = yajl_parse(hand, (const unsigned char *)buf, n); stat = yajl_parse(hand, (const unsigned char *)buf, n);
if (stat != yajl_status_ok) if (stat != yajl_status_ok) {
{
unsigned char *str = yajl_get_error(hand, 1, (const unsigned char *)buf, n); unsigned char *str = yajl_get_error(hand, 1, (const unsigned char *)buf, n);
ELOG("JSON parsing error: %s\n", str); ELOG("JSON parsing error: %s\n", str);
if (errormsg != NULL) if (errormsg != NULL)

View File

@ -296,8 +296,7 @@ int main(int argc, char *argv[]) {
{"fake_outputs", required_argument, 0, 0}, {"fake_outputs", required_argument, 0, 0},
{"fake-outputs", required_argument, 0, 0}, {"fake-outputs", required_argument, 0, 0},
{"force-old-config-parser-v4.4-only", no_argument, 0, 0}, {"force-old-config-parser-v4.4-only", no_argument, 0, 0},
{0, 0, 0, 0} {0, 0, 0, 0}};
};
int option_index = 0, opt; int option_index = 0, opt;
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
@ -427,7 +426,8 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "\t--shmlog-size <limit>\n" fprintf(stderr, "\t--shmlog-size <limit>\n"
"\tLimits the size of the i3 SHM log to <limit> bytes. Setting this\n" "\tLimits the size of the i3 SHM log to <limit> bytes. Setting this\n"
"\tto 0 disables SHM logging entirely.\n" "\tto 0 disables SHM logging entirely.\n"
"\tThe default is %d bytes.\n", shmlog_size); "\tThe default is %d bytes.\n",
shmlog_size);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, "If you pass plain text arguments, i3 will interpret them as a command\n" fprintf(stderr, "If you pass plain text arguments, i3 will interpret them as a command\n"
"to send to a currently running i3 (like i3-msg). This allows you to\n" "to send to a currently running i3 (like i3-msg). This allows you to\n"
@ -613,7 +613,8 @@ int main(int argc, char *argv[]) {
cursor until the first client is launched). */ cursor until the first client is launched). */
if (xcursor_supported) if (xcursor_supported)
xcursor_set_root_cursor(XCURSOR_CURSOR_POINTER); xcursor_set_root_cursor(XCURSOR_CURSOR_POINTER);
else xcb_set_root_cursor(XCURSOR_CURSOR_POINTER); else
xcb_set_root_cursor(XCURSOR_CURSOR_POINTER);
if (xkb_supported) { if (xkb_supported) {
int errBase, int errBase,
@ -632,9 +633,7 @@ int main(int argc, char *argv[]) {
} }
/* end of ugliness */ /* end of ugliness */
if (xkb_supported && !XkbSelectEvents(xkbdpy, XkbUseCoreKbd, if (xkb_supported && !XkbSelectEvents(xkbdpy, XkbUseCoreKbd, XkbMapNotifyMask | XkbStateNotifyMask, XkbMapNotifyMask | XkbStateNotifyMask)) {
XkbMapNotifyMask | XkbStateNotifyMask,
XkbMapNotifyMask | XkbStateNotifyMask)) {
fprintf(stderr, "Could not set XKB event mask\n"); fprintf(stderr, "Could not set XKB event mask\n");
return 1; return 1;
} }
@ -777,7 +776,6 @@ int main(int argc, char *argv[]) {
ev_io_init(xcb_watcher, xcb_got_event, xcb_get_file_descriptor(conn), EV_READ); ev_io_init(xcb_watcher, xcb_got_event, xcb_get_file_descriptor(conn), EV_READ);
ev_io_start(main_loop, xcb_watcher); ev_io_start(main_loop, xcb_watcher);
if (xkb_supported) { if (xkb_supported) {
ev_io_init(xkb, xkb_got_event, ConnectionNumber(xkbdpy), EV_READ); ev_io_init(xkb, xkb_got_event, ConnectionNumber(xkbdpy), EV_READ);
ev_io_start(main_loop, xkb); ev_io_start(main_loop, xkb);

View File

@ -92,7 +92,6 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
role_cookie, startup_id_cookie, wm_hints_cookie, role_cookie, startup_id_cookie, wm_hints_cookie,
wm_normal_hints_cookie, motif_wm_hints_cookie; wm_normal_hints_cookie, motif_wm_hints_cookie;
geomc = xcb_get_geometry(conn, d); geomc = xcb_get_geometry(conn, d);
/* Check if the window is mapped (it could be not mapped when intializing and /* Check if the window is mapped (it could be not mapped when intializing and
@ -279,14 +278,16 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
DLOG("focused on ws %s: %p / %s\n", startup_ws, nc, nc->name); DLOG("focused on ws %s: %p / %s\n", startup_ws, nc, nc->name);
if (nc->type == CT_WORKSPACE) if (nc->type == CT_WORKSPACE)
nc = tree_open_con(nc, cwindow); nc = tree_open_con(nc, cwindow);
else nc = tree_open_con(nc->parent, cwindow); else
nc = tree_open_con(nc->parent, cwindow);
} else { } else {
/* If not, insert it at the currently focused position */ /* If not, insert it at the currently focused position */
if (focused->type == CT_CON && con_accepts_window(focused)) { if (focused->type == CT_CON && con_accepts_window(focused)) {
LOG("using current container, focused = %p, focused->name = %s\n", LOG("using current container, focused = %p, focused->name = %s\n",
focused, focused->name); focused, focused->name);
nc = focused; nc = focused;
} else nc = tree_open_con(NULL, cwindow); } else
nc = tree_open_con(NULL, cwindow);
} }
} else { } else {
/* M_BELOW inserts the new window as a child of the one which was /* M_BELOW inserts the new window as a child of the one which was
@ -349,9 +350,12 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
if (workspace_is_visible(ws) && current_output == target_output) { if (workspace_is_visible(ws) && current_output == target_output) {
if (!match || !match->restart_mode) { if (!match || !match->restart_mode) {
set_focus = true; set_focus = true;
} else DLOG("not focusing, matched with restart_mode == true\n"); } else
} else DLOG("workspace not visible, not focusing\n"); DLOG("not focusing, matched with restart_mode == true\n");
} else DLOG("dock, not focusing\n"); } else
DLOG("workspace not visible, not focusing\n");
} else
DLOG("dock, not focusing\n");
} else { } else {
DLOG("fs = %p, ws = %p, not focusing\n", fs, ws); DLOG("fs = %p, ws = %p, not focusing\n", fs, ws);
/* Insert the new container in focus stack *after* the currently /* Insert the new container in focus stack *after* the currently

View File

@ -17,9 +17,7 @@
/* From sys/time.h, not sure if its available on all systems. */ /* From sys/time.h, not sure if its available on all systems. */
#define _i3_timercmp(a, b, CMP) \ #define _i3_timercmp(a, b, CMP) \
(((a).tv_sec == (b).tv_sec) ? \ (((a).tv_sec == (b).tv_sec) ? ((a).tv_usec CMP(b).tv_usec) : ((a).tv_sec CMP(b).tv_sec))
((a).tv_usec CMP (b).tv_usec) : \
((a).tv_sec CMP (b).tv_sec))
/* /*
* Initializes the Match data structure. This function is necessary because the * Initializes the Match data structure. This function is necessary because the
@ -65,7 +63,8 @@ void match_copy(Match *dest, Match *src) {
/* The DUPLICATE_REGEX macro creates a new regular expression from the /* The DUPLICATE_REGEX macro creates a new regular expression from the
* ->pattern of the old one. It therefore does use a little more memory then * ->pattern of the old one. It therefore does use a little more memory then
* with a refcounting system, but its easier this way. */ * with a refcounting system, but its easier this way. */
#define DUPLICATE_REGEX(field) do { \ #define DUPLICATE_REGEX(field) \
do { \
if (src->field != NULL) \ if (src->field != NULL) \
dest->field = regex_new(src->field->pattern); \ dest->field = regex_new(src->field->pattern); \
} while (0) } while (0)

View File

@ -11,7 +11,8 @@
*/ */
#include "all.h" #include "all.h"
typedef enum { BEFORE, AFTER } position_t; typedef enum { BEFORE,
AFTER } position_t;
/* /*
* This function detaches 'con' from its parent and inserts it either before or * This function detaches 'con' from its parent and inserts it either before or
@ -184,22 +185,22 @@ void tree_move(int direction) {
if (same_orientation == con->parent) { if (same_orientation == con->parent) {
DLOG("We are in the same container\n"); DLOG("We are in the same container\n");
Con *swap; Con *swap;
if ((swap = (direction == D_LEFT || direction == D_UP ? if ((swap = (direction == D_LEFT || direction == D_UP ? TAILQ_PREV(con, nodes_head, nodes) : TAILQ_NEXT(con, nodes)))) {
TAILQ_PREV(con, nodes_head, nodes) :
TAILQ_NEXT(con, nodes)))) {
if (!con_is_leaf(swap)) { if (!con_is_leaf(swap)) {
DLOG("Moving into our bordering branch\n"); DLOG("Moving into our bordering branch\n");
target = con_descend_direction(swap, direction); target = con_descend_direction(swap, direction);
position = (con_orientation(target->parent) != o || position = (con_orientation(target->parent) != o ||
direction == D_UP || direction == D_UP ||
direction == D_LEFT ? direction == D_LEFT
AFTER : BEFORE); ? AFTER
: BEFORE);
insert_con_into(con, target, position); insert_con_into(con, target, position);
goto end; goto end;
} }
if (direction == D_LEFT || direction == D_UP) if (direction == D_LEFT || direction == D_UP)
TAILQ_SWAP(swap, con, &(swap->parent->nodes_head), nodes); TAILQ_SWAP(swap, con, &(swap->parent->nodes_head), nodes);
else TAILQ_SWAP(con, swap, &(swap->parent->nodes_head), nodes); else
TAILQ_SWAP(con, swap, &(swap->parent->nodes_head), nodes);
TAILQ_REMOVE(&(con->parent->focus_head), con, focused); TAILQ_REMOVE(&(con->parent->focus_head), con, focused);
TAILQ_INSERT_HEAD(&(swap->parent->focus_head), con, focused); TAILQ_INSERT_HEAD(&(swap->parent->focus_head), con, focused);
@ -236,17 +237,16 @@ void tree_move(int direction) {
DLOG("above = %p\n", above); DLOG("above = %p\n", above);
Con *next = (direction == D_UP || direction == D_LEFT ? Con *next = (direction == D_UP || direction == D_LEFT ? TAILQ_PREV(above, nodes_head, nodes) : TAILQ_NEXT(above, nodes));
TAILQ_PREV(above, nodes_head, nodes) :
TAILQ_NEXT(above, nodes));
if (next && !con_is_leaf(next)) { if (next && !con_is_leaf(next)) {
DLOG("Moving into the bordering branch of our adjacent container\n"); DLOG("Moving into the bordering branch of our adjacent container\n");
target = con_descend_direction(next, direction); target = con_descend_direction(next, direction);
position = (con_orientation(target->parent) != o || position = (con_orientation(target->parent) != o ||
direction == D_UP || direction == D_UP ||
direction == D_LEFT ? direction == D_LEFT
AFTER : BEFORE); ? AFTER
: BEFORE);
insert_con_into(con, target, position); insert_con_into(con, target, position);
} else { } else {
DLOG("Moving into container above\n"); DLOG("Moving into container above\n");

View File

@ -114,7 +114,6 @@ bool contained_by_output(Rect rect){
return true; return true;
} }
return false; return false;
} }
/* /*
@ -540,7 +539,8 @@ static void handle_output(xcb_connection_t *conn, xcb_randr_output_t id,
if (!existing) { if (!existing) {
if (new->primary) if (new->primary)
TAILQ_INSERT_HEAD(&outputs, new, outputs); TAILQ_INSERT_HEAD(&outputs, new, outputs);
else TAILQ_INSERT_TAIL(&outputs, new, outputs); else
TAILQ_INSERT_TAIL(&outputs, new, outputs);
} else if (new->active) } else if (new->active)
new->to_be_disabled = true; new->to_be_disabled = true;
return; return;
@ -576,7 +576,8 @@ static void handle_output(xcb_connection_t *conn, xcb_randr_output_t id,
if (!existing) { if (!existing) {
if (new->primary) if (new->primary)
TAILQ_INSERT_HEAD(&outputs, new, outputs); TAILQ_INSERT_HEAD(&outputs, new, outputs);
else TAILQ_INSERT_TAIL(&outputs, new, outputs); else
TAILQ_INSERT_TAIL(&outputs, new, outputs);
} }
return; return;
} }
@ -610,7 +611,8 @@ void randr_query_outputs(void) {
if ((primary = xcb_randr_get_output_primary_reply(conn, pcookie, NULL)) == NULL) if ((primary = xcb_randr_get_output_primary_reply(conn, pcookie, NULL)) == NULL)
ELOG("Could not get RandR primary output\n"); ELOG("Could not get RandR primary output\n");
else DLOG("primary output is %08x\n", primary->output); else
DLOG("primary output is %08x\n", primary->output);
if ((res = xcb_randr_get_screen_resources_current_reply(conn, rcookie, NULL)) == NULL) { if ((res = xcb_randr_get_screen_resources_current_reply(conn, rcookie, NULL)) == NULL) {
disable_randr(conn); disable_randr(conn);
return; return;
@ -824,7 +826,8 @@ void randr_init(int *event_base) {
if (!extreply->present) { if (!extreply->present) {
disable_randr(conn); disable_randr(conn);
return; return;
} else randr_query_outputs(); } else
randr_query_outputs();
if (event_base != NULL) if (event_base != NULL)
*event_base = extreply->first_event; *event_base = extreply->first_event;

View File

@ -319,7 +319,6 @@ void render_con(Con *con, bool render_fullscreen) {
} }
} else { } else {
/* FIXME: refactor this into separate functions: */ /* FIXME: refactor this into separate functions: */
Con *child; Con *child;
TAILQ_FOREACH (child, &(con->nodes_head), nodes) { TAILQ_FOREACH (child, &(con->nodes_head), nodes) {

View File

@ -152,9 +152,7 @@ int resize_graphical_handler(Con *first, Con *second, orientation_t orientation,
values[1] = 1; values[1] = 1;
xcb_window_t helpwin = create_window(conn, helprect, XCB_COPY_FROM_PARENT, XCB_COPY_FROM_PARENT, xcb_window_t helpwin = create_window(conn, helprect, XCB_COPY_FROM_PARENT, XCB_COPY_FROM_PARENT,
XCB_WINDOW_CLASS_INPUT_OUTPUT, (orientation == HORIZ ? XCB_WINDOW_CLASS_INPUT_OUTPUT, (orientation == HORIZ ? XCURSOR_CURSOR_RESIZE_HORIZONTAL : XCURSOR_CURSOR_RESIZE_VERTICAL), true, mask, values);
XCURSOR_CURSOR_RESIZE_HORIZONTAL :
XCURSOR_CURSOR_RESIZE_VERTICAL), true, mask, values);
xcb_circulate_window(conn, XCB_CIRCULATE_RAISE_LOWEST, helpwin); xcb_circulate_window(conn, XCB_CIRCULATE_RAISE_LOWEST, helpwin);

View File

@ -140,12 +140,10 @@ static void update_placeholder_contents(placeholder_state *state) {
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) do { \ #define APPEND_REGEX(re_name) \
do { \
if (swallows->re_name != NULL) { \ if (swallows->re_name != NULL) { \
sasprintf(&serialized, "%s%s" #re_name "=\"%s\"", \ sasprintf(&serialized, "%s%s" #re_name "=\"%s\"", (serialized ? serialized : "["), (serialized ? " " : ""), swallows->re_name->pattern); \
(serialized ? serialized : "["), \
(serialized ? " " : ""), \
swallows->re_name->pattern); \
} \ } \
} while (0) } while (0)

View File

@ -21,7 +21,8 @@
void scratchpad_move(Con *con) { void scratchpad_move(Con *con) {
if (con->type == CT_WORKSPACE) { if (con->type == CT_WORKSPACE) {
LOG("'move scratchpad' used on a workspace \"%s\". Calling it " LOG("'move scratchpad' used on a workspace \"%s\". Calling it "
"recursively on all windows on this workspace.\n", con->name); "recursively on all windows on this workspace.\n",
con->name);
Con *current; Con *current;
current = TAILQ_FIRST(&(con->focus_head)); current = TAILQ_FIRST(&(con->focus_head));
while (current) { while (current) {

View File

@ -45,7 +45,6 @@
#include "sd-daemon.h" #include "sd-daemon.h"
int sd_listen_fds(int unset_environment) { int sd_listen_fds(int unset_environment) {
#if defined(DISABLE_SYSTEMD) || !defined(__linux__) #if defined(DISABLE_SYSTEMD) || !defined(__linux__)
return 0; return 0;
#else #else
@ -143,15 +142,13 @@ int sd_is_fifo(int fd, const char *path) {
memset(&st_path, 0, sizeof(st_path)); memset(&st_path, 0, sizeof(st_path));
if (stat(path, &st_path) < 0) { if (stat(path, &st_path) < 0) {
if (errno == ENOENT || errno == ENOTDIR) if (errno == ENOENT || errno == ENOTDIR)
return 0; return 0;
return -errno; return -errno;
} }
return return st_path.st_dev == st_fd.st_dev &&
st_path.st_dev == st_fd.st_dev &&
st_path.st_ino == st_fd.st_ino; st_path.st_ino == st_fd.st_ino;
} }
@ -312,13 +309,11 @@ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t
if (path[0]) if (path[0])
/* Normal path socket */ /* Normal path socket */
return return (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) &&
(l >= offsetof(struct sockaddr_un, sun_path) + length + 1) &&
memcmp(path, sockaddr.un.sun_path, length + 1) == 0; memcmp(path, sockaddr.un.sun_path, length + 1) == 0;
else else
/* Abstract namespace socket */ /* Abstract namespace socket */
return return (l == offsetof(struct sockaddr_un, sun_path) + length) &&
(l == offsetof(struct sockaddr_un, sun_path) + length) &&
memcmp(path, sockaddr.un.sun_path, length) == 0; memcmp(path, sockaddr.un.sun_path, length) == 0;
} }

View File

@ -34,8 +34,7 @@ static char *crash_text[] = {
"or press", "or press",
"- 'b' to save a backtrace (needs GDB),", "- 'b' to save a backtrace (needs GDB),",
"- 'r' to restart i3 in-place or", "- 'r' to restart i3 in-place or",
"- 'f' to forget the current layout and restart" "- 'f' to forget the current layout and restart"};
};
static int crash_text_longest = 5; static int crash_text_longest = 5;
static int backtrace_string_index = 3; static int backtrace_string_index = 3;
static int backtrace_done = 0; static int backtrace_done = 0;
@ -102,8 +101,7 @@ static int backtrace(void) {
"-ex", "set logging on", "-ex", "set logging on",
"-ex", "bt full", "-ex", "bt full",
"-ex", "quit", "-ex", "quit",
NULL NULL};
};
execvp(args[0], args); execvp(args[0], args);
DLOG("Failed to exec GDB\n"); DLOG("Failed to exec GDB\n");
exit(1); exit(1);

View File

@ -77,8 +77,7 @@ static int _prune_startup_sequences(void) {
* seconds ago or earlier. */ * seconds ago or earlier. */
struct Startup_Sequence *current, *next; struct Startup_Sequence *current, *next;
for (next = TAILQ_FIRST(&startup_sequences); for (next = TAILQ_FIRST(&startup_sequences);
next != TAILQ_END(&startup_sequences); next != TAILQ_END(&startup_sequences);) {
) {
current = next; current = next;
next = TAILQ_NEXT(next, sequences); next = TAILQ_NEXT(next, sequences);
@ -94,7 +93,6 @@ static int _prune_startup_sequences(void) {
} }
return active_sequences; return active_sequences;
} }
/** /**
@ -204,7 +202,8 @@ void start_application(const char *command, bool no_startup_id) {
/* Change the pointer of the root window to indicate progress */ /* Change the pointer of the root window to indicate progress */
if (xcursor_supported) if (xcursor_supported)
xcursor_set_root_cursor(XCURSOR_CURSOR_WATCH); xcursor_set_root_cursor(XCURSOR_CURSOR_WATCH);
else xcb_set_root_cursor(XCURSOR_CURSOR_WATCH); else
xcb_set_root_cursor(XCURSOR_CURSOR_WATCH);
} }
} }
@ -248,7 +247,8 @@ void startup_monitor_event(SnMonitorEvent *event, void *userdata) {
/* Change the pointer of the root window to indicate progress */ /* Change the pointer of the root window to indicate progress */
if (xcursor_supported) if (xcursor_supported)
xcursor_set_root_cursor(XCURSOR_CURSOR_POINTER); xcursor_set_root_cursor(XCURSOR_CURSOR_POINTER);
else xcb_set_root_cursor(XCURSOR_CURSOR_POINTER); else
xcb_set_root_cursor(XCURSOR_CURSOR_POINTER);
} }
break; break;
default: default:

View File

@ -80,8 +80,7 @@ bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry) {
geometry->x, geometry->x,
geometry->y, geometry->y,
geometry->width, geometry->width,
geometry->height geometry->height};
};
focused = croot; focused = croot;
tree_append_json(focused, globbed, NULL); tree_append_json(focused, globbed, NULL);
@ -123,8 +122,7 @@ void tree_init(xcb_get_geometry_reply_t *geometry) {
geometry->x, geometry->x,
geometry->y, geometry->y,
geometry->width, geometry->width,
geometry->height geometry->height};
};
_create___i3(); _create___i3();
} }
@ -337,10 +335,10 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool
} else { } else {
if (!force_set_focus && con != focused) if (!force_set_focus && con != focused)
DLOG("not changing focus, the container was not focused before\n"); DLOG("not changing focus, the container was not focused before\n");
else con_focus(next); else
con_focus(next);
} }
} } else {
else {
DLOG("not focusing because we're not killing anybody\n"); DLOG("not focusing because we're not killing anybody\n");
} }
} else { } else {
@ -472,16 +470,14 @@ bool level_down(void) {
if (next == TAILQ_END(&(focused->focus_head))) { if (next == TAILQ_END(&(focused->focus_head))) {
DLOG("cannot go down\n"); DLOG("cannot go down\n");
return false; return false;
} } else if (next->type == CT_FLOATING_CON) {
else if (next->type == CT_FLOATING_CON) {
/* Floating cons shouldn't be directly focused; try immediately /* Floating cons shouldn't be directly focused; try immediately
* going to the grandchild of the focused con. */ * going to the grandchild of the focused con. */
Con *child = TAILQ_FIRST(&(next->focus_head)); Con *child = TAILQ_FIRST(&(next->focus_head));
if (child == TAILQ_END(&(next->focus_head))) { if (child == TAILQ_END(&(next->focus_head))) {
DLOG("cannot go down\n"); DLOG("cannot go down\n");
return false; return false;
} } else
else
next = TAILQ_FIRST(&(next->focus_head)); next = TAILQ_FIRST(&(next->focus_head));
} }
@ -600,13 +596,15 @@ static bool _tree_next(Con *con, char way, orientation_t orientation, bool wrap)
Con *next; Con *next;
if (way == 'n') if (way == 'n')
next = TAILQ_NEXT(con, floating_windows); next = TAILQ_NEXT(con, floating_windows);
else next = TAILQ_PREV(con, floating_head, floating_windows); else
next = TAILQ_PREV(con, floating_head, floating_windows);
/* If there is no next/previous container, wrap */ /* If there is no next/previous container, wrap */
if (!next) { if (!next) {
if (way == 'n') if (way == 'n')
next = TAILQ_FIRST(&(parent->floating_head)); next = TAILQ_FIRST(&(parent->floating_head));
else next = TAILQ_LAST(&(parent->floating_head), floating_head); else
next = TAILQ_LAST(&(parent->floating_head), floating_head);
} }
/* Still no next/previous container? bail out */ /* Still no next/previous container? bail out */
@ -639,7 +637,8 @@ static bool _tree_next(Con *con, char way, orientation_t orientation, bool wrap)
Con *next; Con *next;
if (way == 'n') if (way == 'n')
next = TAILQ_NEXT(current, nodes); next = TAILQ_NEXT(current, nodes);
else next = TAILQ_PREV(current, nodes_head, nodes); else
next = TAILQ_PREV(current, nodes_head, nodes);
if (!next) { if (!next) {
if (!config.force_focus_wrapping) { if (!config.force_focus_wrapping) {
@ -655,7 +654,8 @@ static bool _tree_next(Con *con, char way, orientation_t orientation, bool wrap)
if (way == 'n') if (way == 'n')
next = TAILQ_FIRST(&(parent->nodes_head)); next = TAILQ_FIRST(&(parent->nodes_head));
else next = TAILQ_LAST(&(parent->nodes_head), nodes_head); else
next = TAILQ_LAST(&(parent->nodes_head), nodes_head);
} }
/* Don't violate fullscreen focus restrictions. */ /* Don't violate fullscreen focus restrictions. */

View File

@ -309,7 +309,8 @@ void i3_restart(bool forget_layout) {
if (restart_filename != NULL) { if (restart_filename != NULL) {
/* create the new argv */ /* create the new argv */
int num_args; int num_args;
for (num_args = 0; start_argv[num_args] != NULL; num_args++); for (num_args = 0; start_argv[num_args] != NULL; num_args++)
;
char **new_argv = scalloc((num_args + 3) * sizeof(char *)); char **new_argv = scalloc((num_args + 3) * sizeof(char *));
/* copy the arguments, but skip the ones we'll replace */ /* copy the arguments, but skip the ones we'll replace */

View File

@ -34,7 +34,8 @@ void window_update_class(i3Window *win, xcb_get_property_reply_t *prop, bool bef
win->class_instance = sstrdup(new_class); win->class_instance = sstrdup(new_class);
if ((strlen(new_class) + 1) < (size_t)xcb_get_property_value_length(prop)) if ((strlen(new_class) + 1) < (size_t)xcb_get_property_value_length(prop))
win->class_class = sstrdup(new_class + strlen(new_class) + 1); win->class_class = sstrdup(new_class + strlen(new_class) + 1);
else win->class_class = NULL; else
win->class_class = NULL;
LOG("WM_CLASS changed to %s (instance), %s (class)\n", LOG("WM_CLASS changed to %s (instance), %s (class)\n",
win->class_instance, win->class_class); win->class_instance, win->class_class);

View File

@ -64,9 +64,7 @@ Con *workspace_get(const char *num, bool *created) {
DLOG("Found workspace name assignment to output \"%s\"\n", assignment->output); DLOG("Found workspace name assignment to output \"%s\"\n", assignment->output);
GREP_FIRST(output, croot, !strcmp(child->name, assignment->output)); GREP_FIRST(output, croot, !strcmp(child->name, assignment->output));
break; break;
} else if (parsed_num != -1 } else if (parsed_num != -1 && name_is_digits(assignment->name) && ws_name_to_number(assignment->name) == parsed_num) {
&& name_is_digits(assignment->name)
&& ws_name_to_number(assignment->name) == parsed_num) {
DLOG("Found workspace number assignment to output \"%s\"\n", assignment->output); DLOG("Found workspace number assignment to output \"%s\"\n", assignment->output);
GREP_FIRST(output, croot, !strcmp(child->name, assignment->output)); GREP_FIRST(output, croot, !strcmp(child->name, assignment->output));
} }
@ -96,8 +94,7 @@ Con *workspace_get(const char *num, bool *created) {
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}"); ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");
if (created != NULL) if (created != NULL)
*created = true; *created = true;
} } else if (created != NULL) {
else if (created != NULL) {
*created = false; *created = false;
} }
@ -186,7 +183,8 @@ Con *create_workspace_on_output(Output *output, Con *content) {
parsed_num < 0 || parsed_num < 0 ||
endptr == ws->name) endptr == ws->name)
ws->num = -1; ws->num = -1;
else ws->num = parsed_num; else
ws->num = parsed_num;
LOG("Used number %d for workspace with name %s\n", ws->num, ws->name); LOG("Used number %d for workspace with name %s\n", ws->num, ws->name);
break; break;
@ -225,7 +223,6 @@ Con *create_workspace_on_output(Output *output, Con *content) {
return ws; return ws;
} }
/* /*
* Returns true if the workspace is currently visible. Especially important for * Returns true if the workspace is currently visible. Especially important for
* multi-monitor environments, as they can have multiple currenlty active * multi-monitor environments, as they can have multiple currenlty active
@ -602,7 +599,6 @@ workspace_prev_end:
return prev; return prev;
} }
/* /*
* Focuses the next workspace on the same output. * Focuses the next workspace on the same output.
* *

11
src/x.c
View File

@ -392,8 +392,7 @@ void x_draw_decoration(Con *con) {
/* left area */ /* left area */
{0, 0, w->x, r->height}, {0, 0, w->x, r->height},
/* right area */ /* right area */
{ w->x + w->width, 0, r->width - (w->x + w->width), r->height } {w->x + w->width, 0, r->width - (w->x + w->width), r->height}};
};
#if 0 #if 0
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
DLOG("rect is (%d, %d) with %d x %d\n", DLOG("rect is (%d, %d) with %d x %d\n",
@ -459,7 +458,6 @@ void x_draw_decoration(Con *con) {
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, (xcb_rectangle_t[]) { xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, (xcb_rectangle_t[]) {
{br.x, r->height + br.height + br.y, r->width - (2 * br.x), r->height}}); {br.x, r->height + br.height + br.y, r->width - (2 * br.x), r->height}});
} }
} }
/* if this is a borderless/1pixel window, we dont need to render the /* if this is a borderless/1pixel window, we dont need to render the
@ -486,10 +484,8 @@ void x_draw_decoration(Con *con) {
xcb_segment_t segments[] = { xcb_segment_t segments[] = {
{dr->x, dr->y, {dr->x, dr->y,
dr->x + dr->width - 1, dr->y}, dr->x + dr->width - 1, dr->y},
{dr->x + deco_diff_l, dr->y + dr->height - 1, {dr->x + deco_diff_l, dr->y + dr->height - 1,
dr->x - deco_diff_r + dr->width - 1, dr->y + dr->height - 1 } dr->x - deco_diff_r + dr->width - 1, dr->y + dr->height - 1}};
};
xcb_poly_segment(conn, parent->pixmap, parent->pm_gc, 2, segments); xcb_poly_segment(conn, parent->pixmap, parent->pm_gc, 2, segments);
/* 6: draw the title */ /* 6: draw the title */
@ -1143,8 +1139,7 @@ void x_set_i3_atoms(void) {
* x_push_changes(). * x_push_changes().
* *
*/ */
void x_set_warp_to(Rect *rect) void x_set_warp_to(Rect *rect) {
{
if (!config.disable_focus_follows_mouse && if (!config.disable_focus_follows_mouse &&
config.mouse_warping != POINTER_WARPING_NONE) config.mouse_warping != POINTER_WARPING_NONE)
warp_to = rect; warp_to = rect;

View File

@ -171,7 +171,6 @@ bool xcb_reply_contains_atom(xcb_get_property_reply_t *prop, xcb_atom_t atom) {
return true; return true;
return false; return false;
} }
/** /**

View File

@ -23,8 +23,7 @@ static const int xcb_cursors[XCURSOR_CURSOR_MAX] = {
XCB_CURSOR_LEFT_PTR, XCB_CURSOR_LEFT_PTR,
XCB_CURSOR_SB_H_DOUBLE_ARROW, XCB_CURSOR_SB_H_DOUBLE_ARROW,
XCB_CURSOR_SB_V_DOUBLE_ARROW, XCB_CURSOR_SB_V_DOUBLE_ARROW,
XCB_CURSOR_WATCH XCB_CURSOR_WATCH};
};
void xcursor_load_cursors(void) { void xcursor_load_cursors(void) {
if (xcb_cursor_context_new(conn, root_screen, &ctx) < 0) { if (xcb_cursor_context_new(conn, root_screen, &ctx) < 0) {

View File

@ -15,7 +15,6 @@
#include <xcb/xinerama.h> #include <xcb/xinerama.h>
static int num_screens; static int num_screens;
/* /*
@ -68,7 +67,8 @@ static void query_screens(xcb_connection_t *conn) {
/* We always treat the screen at 0x0 as the primary screen */ /* We always treat the screen at 0x0 as the primary screen */
if (s->rect.x == 0 && s->rect.y == 0) if (s->rect.x == 0 && s->rect.y == 0)
TAILQ_INSERT_HEAD(&outputs, s, outputs); TAILQ_INSERT_HEAD(&outputs, s, outputs);
else TAILQ_INSERT_TAIL(&outputs, s, outputs); else
TAILQ_INSERT_TAIL(&outputs, s, outputs);
output_init_con(s); output_init_con(s);
init_ws_for_output(s, output_get_content(s->con)); init_ws_for_output(s, output_get_content(s->con));
num_screens++; num_screens++;

View File

@ -34,7 +34,8 @@ void dump() {
printf("done\n\n"); printf("done\n\n");
} }
#define TAILQ_SWAP(first, second, head, field) do { \ #define TAILQ_SWAP(first, second, head, field) \
do { \
*((first)->field.tqe_prev) = (second); \ *((first)->field.tqe_prev) = (second); \
(second)->field.tqe_prev = (first)->field.tqe_prev; \ (second)->field.tqe_prev = (first)->field.tqe_prev; \
(first)->field.tqe_prev = &((second)->field.tqe_next); \ (first)->field.tqe_prev = &((second)->field.tqe_next); \
@ -65,7 +66,6 @@ void _TAILQ_SWAP(struct obj *first, struct obj *second, struct objhead *head) {
if (head->tqh_last == &(second->entry.tqe_next)) if (head->tqh_last == &(second->entry.tqe_next))
head->tqh_last = &(first->entry.tqe_next); head->tqh_last = &(first->entry.tqe_next);
} }
int main() { int main() {
@ -85,7 +85,6 @@ int main() {
struct obj fourth; struct obj fourth;
fourth.abc = 999; fourth.abc = 999;
struct obj fifth; struct obj fifth;
fifth.abc = 5555; fifth.abc = 5555;
@ -157,7 +156,6 @@ int main() {
dump(); dump();
/* /*
* ************************************************ * ************************************************
*/ */
@ -180,7 +178,6 @@ int main() {
dump(); dump();
/* /*
* ************************************************ * ************************************************
*/ */
@ -203,7 +200,6 @@ int main() {
dump(); dump();
/* /*
* ************************************************ * ************************************************
*/ */
@ -225,5 +221,4 @@ int main() {
TAILQ_REMOVE(&head, &second, entry); TAILQ_REMOVE(&head, &second, entry);
dump(); dump();
} }

View File

@ -26,5 +26,4 @@ int main() {
expand_table_rows(); expand_table_rows();
printf("table_dimensions = %d, %d\n", table_dims.x, table_dims.y); printf("table_dimensions = %d, %d\n", table_dims.x, table_dims.y);
print_table(); print_table();
} }