16 #ifdef I3_ASAN_ENABLED 17 #include <sanitizer/lsan_interface.h> 23 #define y(x, ...) (cmd_output->json_gen != NULL ? yajl_gen_##x(cmd_output->json_gen, ##__VA_ARGS__) : 0) 24 #define ystr(str) (cmd_output->json_gen != NULL ? yajl_gen_string(cmd_output->json_gen, (unsigned char *)str, strlen(str)) : 0) 25 #define ysuccess(success) \ 27 if (cmd_output->json_gen != NULL) { \ 34 #define yerror(format, ...) \ 36 if (cmd_output->json_gen != NULL) { \ 38 sasprintf(&message, format, ##__VA_ARGS__); \ 51 #define HANDLE_INVALID_MATCH \ 53 if (current_match->error != NULL) { \ 54 yerror("Invalid match: %s", current_match->error); \ 64 #define HANDLE_EMPTY_MATCH \ 66 HANDLE_INVALID_MATCH; \ 68 if (match_is_empty(current_match)) { \ 69 while (!TAILQ_EMPTY(&owindows)) { \ 70 owindow *ow = TAILQ_FIRST(&owindows); \ 71 TAILQ_REMOVE(&owindows, ow, owindows); \ 74 owindow *ow = smalloc(sizeof(owindow)); \ 76 TAILQ_INIT(&owindows); \ 77 TAILQ_INSERT_TAIL(&owindows, ow, owindows); \ 92 if (strcmp(ws->
name, name) != 0)
95 DLOG(
"This workspace is already focused.\n");
115 if (current == workspace) {
118 DLOG(
"Substituting workspace with back_and_forth, as it is focused.\n");
180 DLOG(
"match specification finished, matching...\n");
183 struct owindows_head old =
owindows;
192 DLOG(
"checking if con %p / %s matches\n", current->
con, current->
con->
name);
196 bool accept_match =
false;
202 DLOG(
"con_id matched.\n");
204 DLOG(
"con_id does not match.\n");
212 bool matched_by_mark =
false;
219 DLOG(
"match by mark\n");
220 matched_by_mark =
true;
224 if (!matched_by_mark) {
225 DLOG(
"mark does not match.\n");
233 DLOG(
"matches window!\n");
236 DLOG(
"doesn't match\n");
272 #define CHECK_MOVE_CON_TO_WORKSPACE \ 274 HANDLE_EMPTY_MATCH; \ 275 if (TAILQ_EMPTY(&owindows)) { \ 276 yerror("Nothing to move: specified criteria don't match any window"); \ 279 bool found = false; \ 280 owindow *current = TAILQ_FIRST(&owindows); \ 282 owindow *next = TAILQ_NEXT(current, owindows); \ 284 if (current->con->type == CT_WORKSPACE && !con_has_children(current->con)) { \ 285 TAILQ_REMOVE(&owindows, current, owindows); \ 293 yerror("Nothing to move: workspace empty"); \ 305 DLOG(
"which=%s\n", which);
311 if (strcmp(which,
"next") == 0)
313 else if (strcmp(which,
"prev") == 0)
315 else if (strcmp(which,
"next_on_output") == 0)
317 else if (strcmp(which,
"prev_on_output") == 0)
319 else if (strcmp(which,
"current") == 0)
322 yerror(
"BUG: called with which=%s", which);
328 cmd_output->needs_tree_render =
true;
340 yerror(
"No workspace was previously active.");
348 cmd_output->needs_tree_render =
true;
358 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
359 yerror(
"You cannot move containers to i3-internal workspaces (\"%s\").", name);
365 LOG(
"should move window to workspace %s\n", name);
369 if (no_auto_back_and_forth == NULL) {
375 cmd_output->needs_tree_render =
true;
387 LOG(
"should move window to workspace %s\n", which);
390 if (parsed_num == -1) {
391 LOG(
"Could not parse initial part of \"%s\" as a number.\n", which);
392 yerror(
"Could not parse number \"%s\"", which);
401 if (no_auto_back_and_forth == NULL) {
407 cmd_output->needs_tree_render =
true;
417 if (strcmp(str,
"left") == 0) {
419 }
else if (strcmp(str,
"right") == 0) {
421 }
else if (strcmp(str,
"up") == 0) {
423 }
else if (strcmp(str,
"down") == 0) {
426 ELOG(
"Invalid direction. This is a parser bug.\n");
436 if (strcmp(direction_str,
"height") == 0) {
438 }
else if (strcmp(direction_str,
"width") == 0) {
449 if (window != NULL) {
450 if (orientation ==
VERT) {
465 if (orientation ==
VERT) {
474 if (memcmp(&old_rect, &(floating_con->
rect),
sizeof(
Rect)) == 0) {
478 if (direction ==
D_UP) {
480 }
else if (direction ==
D_LEFT) {
492 Con *first = current;
497 yerror(
"No second container found in this direction.");
510 LOG(
"width/height resize\n");
516 if (search_result ==
false) {
517 yerror(
"Failed to find appropriate tiling containers for resize operation");
523 LOG(
"ins. %d children\n", children);
524 double percentage = 1.0 / children;
525 LOG(
"default percentage = %f\n", percentage);
530 LOG(
"child->percent = %f (child %p)\n", child->
percent, child);
535 double new_current_percent;
536 double subtract_percent;
538 new_current_percent = current->
percent + ppt;
541 ppt = new_current_percent - current->
percent;
543 subtract_percent = ppt / (children - 1);
545 yerror(
"Not resizing, container would end with less than 1px");
549 LOG(
"new_current_percent = %f\n", new_current_percent);
550 LOG(
"subtract_percent = %f\n", subtract_percent);
552 if (subtract_percent >= 0.0) {
554 if (child == current) {
558 yerror(
"Not resizing, already at minimum size (child %p would end up with a size of %.f", child, child->
percent - subtract_percent);
564 current->
percent = new_current_percent;
565 LOG(
"current->percent after = %f\n", current->
percent);
568 if (child == current)
570 child->
percent -= subtract_percent;
571 LOG(
"child->percent after (%p) = %f\n", child, child->
percent);
581 void cmd_resize(
I3_CMD,
const char *way,
const char *direction,
long resize_px,
long resize_ppt) {
582 DLOG(
"resizing in way %s, direction %s, px %ld or ppt %ld\n", way, direction, resize_px, resize_ppt);
583 if (strcmp(way,
"shrink") == 0) {
594 DLOG(
"This is a dock window. Not resizing (con = %p)\n)", current->
con);
602 if (strcmp(direction,
"width") == 0 ||
603 strcmp(direction,
"height") == 0) {
604 const double ppt = (double)resize_ppt / 100.0;
606 current->
con, direction,
611 current->
con, direction,
612 resize_px, resize_ppt))
618 cmd_output->needs_tree_render =
true;
626 if (resize_orientation ==
HORIZ) {
627 search_direction =
D_LEFT;
630 search_direction =
D_DOWN;
642 ppt = (double)target_size / 100.0 - target->
percent;
649 target, mode, px, ppt);
657 DLOG(
"resizing to %ld %s x %ld %s\n", cwidth, mode_width, cheight, mode_height);
658 if (cwidth < 0 || cheight < 0) {
659 ELOG(
"Resize failed: dimensions cannot be negative (was %ld %s x %ld %s)\n", cwidth, mode_width, cheight, mode_height);
673 }
else if (mode_width && strcmp(mode_width,
"ppt") == 0) {
674 cwidth = output->
rect.
width * ((double)cwidth / 100.0);
678 }
else if (mode_height && strcmp(mode_height,
"ppt") == 0) {
679 cheight = output->
rect.
height * ((double)cheight / 100.0);
684 DLOG(
"This is a dock window. Not resizing (con = %p)\n)", current->
con);
689 bool is_ppt = mode_width && strcmp(mode_width,
"ppt") == 0;
691 HORIZ, is_ppt, cwidth);
694 bool is_ppt = mode_height && strcmp(mode_height,
"ppt") == 0;
696 VERT, is_ppt, cheight);
701 cmd_output->needs_tree_render =
true;
714 DLOG(
"border style should be changed to %s with border width %ld\n", border_style_str, border_width);
723 if (strcmp(border_style_str,
"toggle") == 0) {
725 }
else if (strcmp(border_style_str,
"normal") == 0) {
727 }
else if (strcmp(border_style_str,
"pixel") == 0) {
729 }
else if (strcmp(border_style_str,
"none") == 0) {
732 yerror(
"BUG: called with border_style=%s", border_style_str);
740 cmd_output->needs_tree_render =
true;
749 LOG(
"-------------------------------------------------\n");
750 LOG(
" NOP: %s\n", comment);
751 LOG(
"-------------------------------------------------\n");
760 LOG(
"Appending layout \"%s\"\n", cpath);
767 if ((len =
slurp(path, &buf)) < 0) {
773 ELOG(
"Could not parse \"%s\" as JSON, not loading.\n", path);
774 yerror(
"Could not parse \"%s\" as JSON.", path);
779 LOG(
"JSON content = %d\n", content);
781 ELOG(
"Could not determine the contents of \"%s\", not loading.\n", path);
782 yerror(
"Could not determine the contents of \"%s\".", path);
797 DLOG(
"Appending to parent=%p instead of focused=%p\n", parent,
focused);
798 char *errormsg = NULL;
800 if (errormsg != NULL) {
824 cmd_output->needs_tree_render =
true;
837 DLOG(
"which=%s\n", which);
840 yerror(
"Cannot switch workspace while in global fullscreen");
844 if (strcmp(which,
"next") == 0)
846 else if (strcmp(which,
"prev") == 0)
848 else if (strcmp(which,
"next_on_output") == 0)
850 else if (strcmp(which,
"prev_on_output") == 0)
853 yerror(
"BUG: called with which=%s", which);
859 cmd_output->needs_tree_render =
true;
869 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
872 yerror(
"Cannot switch workspace while in global fullscreen");
877 if (parsed_num == -1) {
878 yerror(
"Could not parse initial part of \"%s\" as a number.", which);
884 LOG(
"There is no workspace with number %ld, creating a new one.\n", parsed_num);
887 cmd_output->needs_tree_render =
true;
896 cmd_output->needs_tree_render =
true;
907 yerror(
"Cannot switch workspace while in global fullscreen");
913 cmd_output->needs_tree_render =
true;
923 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
925 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
926 yerror(
"You cannot switch to the i3-internal workspaces (\"%s\").", name);
931 yerror(
"Cannot switch workspace while in global fullscreen");
935 DLOG(
"should switch to workspace %s\n", name);
942 cmd_output->needs_tree_render =
true;
955 if (current == NULL) {
956 yerror(
"Given criteria don't match a window");
962 yerror(
"A mark must not be put onto more than one window");
969 if (toggle != NULL) {
975 cmd_output->needs_tree_render =
true;
994 cmd_output->needs_tree_render =
true;
1004 DLOG(
"mode=%s\n", mode);
1016 DLOG(
"Should move window to output \"%s\".\n", name);
1020 bool had_error =
false;
1027 cmd_output->needs_tree_render =
true;
1036 DLOG(
"moving window to mark \"%s\"\n", mark);
1043 DLOG(
"moving matched window %p / %s to mark \"%s\"\n", current->
con, current->
con->
name, mark);
1047 cmd_output->needs_tree_render =
true;
1058 DLOG(
"floating_mode=%s\n", floating_mode);
1064 if (strcmp(floating_mode,
"toggle") == 0) {
1065 DLOG(
"should toggle mode\n");
1068 DLOG(
"should switch mode to %s\n", floating_mode);
1069 if (strcmp(floating_mode,
"enable") == 0) {
1077 cmd_output->needs_tree_render =
true;
1087 DLOG(
"should move workspace to output %s\n", name);
1099 if (current_output == NULL) {
1100 yerror(
"Cannot get current output. This is a bug in i3.");
1105 if (!target_output) {
1106 yerror(
"Could not get output from string \"%s\"", name);
1112 yerror(
"Failed to move workspace to output.");
1117 cmd_output->needs_tree_render =
true;
1129 LOG(
"splitting in direction %c\n", direction[0]);
1132 ELOG(
"Cannot split a docked container, skipping.\n");
1137 if (direction[0] ==
't') {
1139 if (current->
con->
type == CT_WORKSPACE) {
1155 cmd_output->needs_tree_render =
true;
1165 if (kill_mode_str == NULL)
1166 kill_mode_str =
"window";
1168 DLOG(
"kill_mode=%s\n", kill_mode_str);
1171 if (strcmp(kill_mode_str,
"window") == 0)
1173 else if (strcmp(kill_mode_str,
"client") == 0)
1176 yerror(
"BUG: called with kill_mode=%s", kill_mode_str);
1187 cmd_output->needs_tree_render =
true;
1197 bool no_startup_id = (nosn != NULL);
1199 DLOG(
"should execute %s, no_startup_id = %d\n", command, no_startup_id);
1225 cmd_output->needs_tree_render =
true;
1238 if (fullscreen_on_ws && fullscreen_on_ws != con && !
con_has_parent(con, fullscreen_on_ws)) {
1249 DLOG(
"window_mode = %s\n", window_mode);
1251 bool to_floating =
false;
1252 if (strcmp(window_mode,
"mode_toggle") == 0) {
1254 }
else if (strcmp(window_mode,
"floating") == 0) {
1256 }
else if (strcmp(window_mode,
"tiling") == 0) {
1257 to_floating =
false;
1262 bool success =
false;
1264 if ((to_floating && current->
type != CT_FLOATING_CON) ||
1265 (!to_floating && current->
type == CT_FLOATING_CON))
1274 cmd_output->needs_tree_render =
true;
1277 yerror(
"Failed to find a %s container in workspace.", to_floating ?
"floating" :
"tiling");
1286 DLOG(
"level = %s\n", level);
1287 bool success =
false;
1291 if (strcmp(level,
"parent") == 0) {
1296 ELOG(
"'focus parent': Currently in fullscreen, not going up\n");
1304 cmd_output->needs_tree_render = success;
1317 ELOG(
"You have to specify which window/container should be focused.\n");
1318 ELOG(
"Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
1320 yerror(
"You have to specify which window/container should be focused");
1336 if (ws == __i3_scratch) {
1363 LOG(
"focusing %p / %s\n", current->
con, current->
con->
name);
1369 LOG(
"WARNING: Your criteria for the focus command matches %d containers, " 1370 "while only exactly one container can be focused at a time.\n",
1373 cmd_output->needs_tree_render =
true;
1384 DLOG(
"%s fullscreen, mode = %s\n", action, fullscreen_mode);
1391 if (strcmp(action,
"toggle") == 0) {
1393 }
else if (strcmp(action,
"enable") == 0) {
1395 }
else if (strcmp(action,
"disable") == 0) {
1400 cmd_output->needs_tree_render =
true;
1410 DLOG(
"%s sticky on window\n", action);
1416 ELOG(
"only containers holding a window can be made sticky, skipping con = %p\n", current->
con);
1419 DLOG(
"setting sticky for container = %p / %s\n", current->
con, current->
con->
name);
1421 bool sticky =
false;
1422 if (strcmp(action,
"enable") == 0)
1424 else if (strcmp(action,
"disable") == 0)
1426 else if (strcmp(action,
"toggle") == 0)
1439 cmd_output->needs_tree_render =
true;
1455 DLOG(
"moving in direction %s, px %ld\n", direction_str, move_px);
1457 DLOG(
"floating move with %ld pixels\n", move_px);
1460 switch (direction) {
1462 newrect.
x -= move_px;
1465 newrect.
x += move_px;
1468 newrect.
y -= move_px;
1471 newrect.
y += move_px;
1478 cmd_output->needs_tree_render =
true;
1483 if (
focused != initially_focused)
1499 ELOG(
"Unknown layout \"%s\", this is a mismatch between code and parser spec.\n", layout_str);
1503 DLOG(
"changing layout to %s (%d)\n", layout_str, layout);
1508 ELOG(
"cannot change layout of a docked container, skipping it.\n");
1516 cmd_output->needs_tree_render =
true;
1528 if (toggle_mode == NULL)
1529 toggle_mode =
"default";
1531 DLOG(
"toggling layout (mode = %s)\n", toggle_mode);
1543 cmd_output->needs_tree_render =
true;
1553 LOG(
"Exiting due to user command.\n");
1554 #ifdef I3_ASAN_ENABLED 1555 __lsan_do_leak_check();
1559 xcb_disconnect(
conn);
1589 LOG(
"restarting i3\n");
1606 LOG(
"opening new container\n");
1615 y(integer, (uintptr_t)con);
1618 cmd_output->needs_tree_render =
true;
1628 DLOG(
"name = %s\n", name);
1633 Output *current_output = NULL;
1638 assert(current_output != NULL);
1643 yerror(
"No such output found.");
1651 yerror(
"BUG: No workspace found on output.");
1657 cmd_output->needs_tree_render =
true;
1667 bool has_error =
false;
1674 ELOG(
"Cannot change position. The window/container is not floating\n");
1677 yerror(
"Cannot change position of a window/container because it is not floating.");
1686 DLOG(
"moving to position %ld %ld\n", x, y);
1691 yerror(
"Cannot move window/container out of bounds.");
1705 bool has_error =
false;
1711 if (floating_con == NULL) {
1712 ELOG(
"con %p / %s is not floating, cannot move it to the center.\n",
1716 yerror(
"Cannot change position of a window/container because it is not floating.");
1723 if (strcmp(method,
"absolute") == 0) {
1724 DLOG(
"moving to absolute center\n");
1728 cmd_output->needs_tree_render =
true;
1731 if (strcmp(method,
"position") == 0) {
1732 DLOG(
"moving to center\n");
1735 cmd_output->needs_tree_render =
true;
1754 if (floating_con == NULL) {
1755 DLOG(
"con %p / %s is not floating, cannot move it to the mouse position.\n",
1760 DLOG(
"moving floating container %p / %s to cursor position\n", floating_con, floating_con->
name);
1764 cmd_output->needs_tree_render =
true;
1773 DLOG(
"should move window to scratchpad\n");
1783 cmd_output->needs_tree_render =
true;
1793 DLOG(
"should show scratchpad window\n");
1795 bool result =
false;
1806 cmd_output->needs_tree_render =
true;
1819 if (match == NULL) {
1820 yerror(
"No match found for swapping.");
1823 if (match->
con == NULL) {
1824 yerror(
"Match %p has no container.", match);
1829 if (strcmp(mode,
"id") == 0) {
1832 yerror(
"Failed to parse %s into a window id.", arg);
1837 }
else if (strcmp(mode,
"con_id") == 0) {
1840 yerror(
"Failed to parse %s into a container id.", arg);
1845 }
else if (strcmp(mode,
"mark") == 0) {
1848 yerror(
"Unhandled swap mode \"%s\". This is a bug.", mode);
1853 yerror(
"Could not find container for %s = %s", mode, arg);
1858 LOG(
"More than one container matched the swap command, only using the first one.");
1861 DLOG(
"Swapping %p with %p.\n", match->
con, con);
1864 cmd_output->needs_tree_render =
true;
1874 DLOG(
"setting title_format to \"%s\"\n", format);
1879 DLOG(
"setting title_format for %p / %s\n", current->
con, current->
con->
name);
1884 if (strcasecmp(format,
"%title") != 0) {
1908 cmd_output->needs_tree_render =
true;
1917 if (strncasecmp(new_name,
"__", strlen(
"__")) == 0) {
1918 yerror(
"Cannot rename workspace to \"%s\": names starting with __ are i3-internal.", new_name);
1922 LOG(
"Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name);
1924 LOG(
"Renaming current workspace to \"%s\"\n", new_name);
1932 old_name = workspace->
name;
1936 yerror(
"Old workspace \"%s\" not found", old_name);
1944 if (check_dest != NULL && check_dest != workspace) {
1945 yerror(
"New workspace \"%s\" already exists", new_name);
1951 char *old_name_copy =
sstrdup(old_name);
1956 LOG(
"num = %d\n", workspace->
num);
1969 if (assignment->
output == NULL)
1976 if (!target_output) {
1977 LOG(
"Could not get output named \"%s\"\n", assignment->
output);
1988 bool can_restore_focus = previously_focused != NULL;
1994 if (previously_focused_content) {
1995 Con *workspace = NULL;
1996 GREP_FIRST(workspace, previously_focused_content, child == previously_focused);
1997 can_restore_focus &= (workspace != NULL);
2000 if (can_restore_focus) {
2006 cmd_output->needs_tree_render =
true;
2014 free(old_name_copy);
2023 bool toggle =
false;
2024 if (strcmp(bar_mode,
"dock") == 0)
2026 else if (strcmp(bar_mode,
"hide") == 0)
2028 else if (strcmp(bar_mode,
"invisible") == 0)
2030 else if (strcmp(bar_mode,
"toggle") == 0)
2033 ELOG(
"Unknown bar mode \"%s\", this is a mismatch between code and parser spec.\n", bar_mode);
2037 bool changed_sth =
false;
2040 if (bar_id && strcmp(current->
id, bar_id) != 0)
2044 mode = (current->
mode + 1) % 2;
2046 DLOG(
"Changing bar mode of bar_id '%s' to '%s (%d)'\n", current->
id, bar_mode, mode);
2047 current->
mode = mode;
2054 if (bar_id && !changed_sth) {
2055 DLOG(
"Changing bar mode of bar_id %s failed, bar_id not found.\n", bar_id);
2067 int hidden_state = S_SHOW;
2068 bool toggle =
false;
2069 if (strcmp(bar_hidden_state,
"hide") == 0)
2070 hidden_state = S_HIDE;
2071 else if (strcmp(bar_hidden_state,
"show") == 0)
2072 hidden_state = S_SHOW;
2073 else if (strcmp(bar_hidden_state,
"toggle") == 0)
2076 ELOG(
"Unknown bar state \"%s\", this is a mismatch between code and parser spec.\n", bar_hidden_state);
2080 bool changed_sth =
false;
2083 if (bar_id && strcmp(current->
id, bar_id) != 0)
2089 DLOG(
"Changing bar hidden_state of bar_id '%s' to '%s (%d)'\n", current->
id, bar_hidden_state, hidden_state);
2097 if (bar_id && !changed_sth) {
2098 DLOG(
"Changing bar hidden_state of bar_id %s failed, bar_id not found.\n", bar_id);
2109 void cmd_bar(
I3_CMD,
const char *bar_type,
const char *bar_value,
const char *bar_id) {
2111 if (strcmp(bar_type,
"mode") == 0)
2113 else if (strcmp(bar_type,
"hidden_state") == 0)
2116 ELOG(
"Unknown bar option type \"%s\", this is a mismatch between code and parser spec.\n", bar_type);
2132 if (!strcmp(argument,
"toggle"))
2135 else if (!strcmp(argument,
"on"))
2137 else if (!strcmp(argument,
"off"))
2142 yerror(
"Failed to parse %s into a shmlog size.", argument);
2148 LOG(
"Restarting shm logging...\n");
2153 LOG(
"%s shm logging\n",
shmlog_size > 0 ?
"Enabling" :
"Disabling");
2165 if (!strcmp(argument,
"toggle")) {
2166 LOG(
"%s debug logging\n", logging ?
"Disabling" :
"Enabling");
2168 }
else if (!strcmp(argument,
"on") && !logging) {
2169 LOG(
"Enabling debug logging\n");
2171 }
else if (!strcmp(argument,
"off") && logging) {
2172 LOG(
"Disabling debug logging\n");
void cmd_reload(I3_CMD)
Implementation of 'reload'.
bool con_move_to_mark(Con *con, const char *mark)
Moves the given container to the given mark.
double percent_for_1px(Con *con)
Calculate the minimum percent needed for the given container to be at least 1 pixel.
void con_detach(Con *con)
Detaches the given container from its current parent.
orientation_t orientation_from_direction(direction_t direction)
Convert a direction to its corresponding orientation.
void cmd_kill(I3_CMD, const char *kill_mode_str)
Implementation of 'kill [window|client]'.
void cmd_resize_set(I3_CMD, long cwidth, const char *mode_width, long cheight, const char *mode_height)
Implementation of 'resize set <width> [px | ppt] <height> [px | ppt]'.
void cmd_mark(I3_CMD, const char *mark, const char *mode, const char *toggle)
Implementation of 'mark [–add|–replace] [–toggle] <mark>'.
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
bool con_swap(Con *first, Con *second)
Swaps the two containers.
void cmd_title_format(I3_CMD, const char *format)
Implementation of 'title_format <format>'.
void toggle_floating_mode(Con *con, bool automatic)
Calls floating_enable() for tiling containers and floating_disable() for floating containers...
void floating_enable(Con *con, bool automatic)
Enables floating mode for the given container by detaching it from its parent, creating a new contain...
void cmd_open(I3_CMD)
Implementation of 'open'.
void cmd_move_window_to_position(I3_CMD, long x, long y)
Implementation of 'move [window|container] [to] [absolute] position <px> [px] <px> [px]...
void workspace_show(Con *workspace)
Switches to the given workspace.
void cmd_workspace_name(I3_CMD, const char *name, const char *_no_auto_back_and_forth)
Implementation of 'workspace [–no-auto-back-and-forth] <name>'.
bool parse_long(const char *str, long *out, int base)
Converts a string into a long using strtol().
void kill_nagbar(pid_t *nagbar_pid, bool wait_for_it)
Kills the i3-nagbar process, if *nagbar_pid != -1.
void cmd_focus_direction(I3_CMD, const char *direction)
Implementation of 'focus left|right|up|down'.
void update_barconfig(void)
Sends the current bar configuration as an event to all barconfig_update listeners.
void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name)
Implementation of 'rename workspace <name> to <name>'.
void init_logging(void)
Initializes logging by creating an error logfile in /tmp (or XDG_RUNTIME_DIR, see get_process_filenam...
static void cmd_focus_force_focus(Con *con)
struct barconfig_head barconfigs
#define yerror(format,...)
Output * get_output_for_con(Con *con)
Returns the output for the given con.
void cmd_criteria_add(I3_CMD, const char *ctype, const char *cvalue)
Interprets a ctype=cvalue pair and adds it to the current match specification.
Stores which workspace (by name or number) goes to which output.
bool level_up(void)
Moves focus one level up.
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
void cmd_move_con_to_output(I3_CMD, const char *name)
Implementation of 'move [window|container] [to] output <str>'.
bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction, bool both_sides)
bool json_validate(const char *buf, const size_t len)
Returns true if the provided JSON could be parsed by yajl.
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
#define TAILQ_EMPTY(head)
Con * con_by_con_id(long target)
Returns the container with the given container ID or NULL if no such container exists.
bool get_debug_logging(void)
Checks if debug logging is active.
xcb_connection_t * conn
XCB connection and root screen.
void match_free(Match *match)
Frees the given match.
fullscreen_mode_t
Fullscreen modes.
An Output is a physical output on your graphics driver.
Output * get_output_from_string(Output *current_output, const char *output_str)
Returns an 'output' corresponding to one of left/right/down/up or a specific output name...
void switch_mode(const char *new_mode)
Switches the key bindings to the given mode, if the mode exists.
Con * workspace_prev(void)
Returns the previous workspace.
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
void con_focus(Con *con)
Sets input focus to the given container.
void start_application(const char *command, bool no_startup_id)
Starts the given application by passing it through a shell.
bool output_triggers_assignment(Output *output, struct Workspace_Assignment *assignment)
Returns true if the first output assigned to a workspace with the given workspace assignment is the s...
void cmd_criteria_match_windows(I3_CMD)
A match specification just finished (the closing square bracket was found), so we filter the list of ...
enum Window::@13 dock
Whether the window says it is a dock window.
static bool cmd_bar_hidden_state(const char *bar_hidden_state, const char *bar_id)
bool resize_neighboring_cons(Con *first, Con *second, int px, int ppt)
Resize the two given containers using the given amount of pixels or percentage points.
layout_t
Container layouts.
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
bool workspace_auto_back_and_forth
Automatic workspace back and forth switching.
bool con_has_parent(Con *con, Con *parent)
Checks if the container has the given parent as an actual parent.
void scratchpad_move(Con *con)
Moves the specified window to the __i3_scratch workspace, making it floating and setting the appropri...
static bool resize_set_tiling(I3_CMD, Con *target, orientation_t resize_orientation, bool is_ppt, long target_size)
void tree_move(Con *con, int direction)
Moves the given container in the given direction (TOK_LEFT, TOK_RIGHT, TOK_UP, TOK_DOWN from cmdparse...
void cmd_resize(I3_CMD, const char *way, const char *direction, long resize_px, long resize_ppt)
Implementation of 'resize grow|shrink <direction> [<px> px] [or <ppt> ppt]'.
void con_unmark(Con *con, const char *name)
Removes marks from containers.
const int default_shmlog_size
void cmd_fullscreen(I3_CMD, const char *action, const char *fullscreen_mode)
Implementation of 'fullscreen [enable|disable|toggle] [global]'.
#define ysuccess(success)
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
void update_shmlog_atom(void)
Set up the SHMLOG_PATH atom.
bool layout_from_name(const char *layout_str, layout_t *out)
Set 'out' to the layout_t value for the given layout.
void cmd_move_window_to_mouse(I3_CMD)
Implementation of 'move [window|container] [to] position mouse'.
Con * con_by_window_id(xcb_window_t window)
Returns the container with the given client window ID or NULL if no such container exists...
#define CHECK_MOVE_CON_TO_WORKSPACE
void match_parse_property(Match *match, const char *ctype, const char *cvalue)
Interprets a ctype=cvalue pair and adds it to the given match specification.
pid_t command_error_nagbar_pid
void cmd_layout_toggle(I3_CMD, const char *toggle_mode)
Implementation of 'layout toggle [all|split]'.
void con_mark(Con *con, const char *mark, mark_mode_t mode)
Assigns a mark to the container.
void ewmh_update_current_desktop(void)
Updates _NET_CURRENT_DESKTOP with the current desktop number.
void floating_center(Con *con, Rect rect)
Centers a floating con above the specified rect.
void cmd_unmark(I3_CMD, const char *mark)
Implementation of 'unmark [mark]'.
Output * get_output_by_name(const char *name, const bool require_active)
Returns the output with the given name or NULL.
void cmd_bar(I3_CMD, const char *bar_type, const char *bar_value, const char *bar_id)
Implementation of 'bar (hidden_state hide|show|toggle)|(mode dock|hide|invisible|toggle) [<bar_id>]'...
bool floating_reposition(Con *con, Rect newrect)
Repositions the CT_FLOATING_CON to have the coordinates specified by newrect, but only if the coordin...
void cmd_restart(I3_CMD)
Implementation of 'restart'.
void cmd_workspace_back_and_forth(I3_CMD)
Implementation of 'workspace back_and_forth'.
void cmd_layout(I3_CMD, const char *layout_str)
Implementation of 'layout default|stacked|stacking|tabbed|splitv|splith'.
void cmd_move_workspace_to_output(I3_CMD, const char *name)
Implementation of 'move workspace to [output] <str>'.
#define TAILQ_REMOVE(head, elm, field)
void cmd_sticky(I3_CMD, const char *action)
Implementation of 'sticky enable|disable|toggle'.
typedef TAILQ_HEAD(owindows_head, owindow)
bool level_down(void)
Moves focus one level down.
void con_mark_toggle(Con *con, const char *mark, mark_mode_t mode)
Toggles the mark on a container.
void ewmh_update_desktop_viewport(void)
Updates _NET_DESKTOP_VIEWPORT, which is an array of pairs of cardinals that define the top left corne...
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
void cmd_swap(I3_CMD, const char *mode, const char *arg)
Implementation of 'swap [container] [with] id|con_id|mark <arg>'.
Con * workspace_next(void)
Returns the next workspace.
bool floating_maybe_reassign_ws(Con *con)
Checks if con’s coordinates are within its workspace and re-assigns it to the actual workspace if no...
#define TAILQ_FIRST(head)
void cmd_scratchpad_show(I3_CMD)
Implementation of 'scratchpad show'.
void cmd_border(I3_CMD, const char *border_style_str, long border_width)
Implementation of 'border normal|pixel [<n>]', 'border none|1pixel|toggle'.
void workspace_show_by_name(const char *num)
Looks up the workspace by name and switches to it.
Con * con
Pointer to the Con which represents this output.
enum Barconfig::@10 hidden_state
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on...
void cmd_nop(I3_CMD, const char *comment)
Implementation of 'nop <comment>'.
int con_num_children(Con *con)
Returns the number of children of this container.
Stores a rectangle, for example the size of a window, the child window etc.
void cmd_move_direction(I3_CMD, const char *direction_str, long move_px)
Implementation of 'move <direction> [<pixels> [px]]'.
bool con_is_floating(Con *con)
Returns true if the node is floating.
void cmd_focus_output(I3_CMD, const char *name)
Implementation of 'focus output <output>'.
static bool maybe_back_and_forth(struct CommandResultIR *cmd_output, const char *name)
long ws_name_to_number(const char *name)
Parses the workspace name as a number.
bool match_is_empty(Match *match)
Check if a match is empty.
#define TAILQ_NEXT(elm, field)
bool con_is_docked(Con *con)
Returns true if the container is a docked container.
void cmd_move_scratchpad(I3_CMD)
Implementation of 'move scratchpad'.
Holds an intermediate represenation of the result of a call to any command.
Con * workspace_back_and_forth_get(void)
Returns the previously focused workspace con, or NULL if unavailable.
void floating_disable(Con *con, bool automatic)
Disables floating mode for the given container by re-attaching the container to its old parent...
void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool dont_warp, bool ignore_focus)
Moves the given container to the currently focused container on the given workspace.
bool con_accepts_window(Con *con)
Returns true if this node accepts a window (if the node swallows windows, it might already have swall...
void ewmh_update_desktop_names(void)
Updates _NET_DESKTOP_NAMES: "The names of all virtual desktops.
json_content_t json_determine_content(const char *buf, const size_t len)
#define TAILQ_ENTRY(type)
bool scratchpad_show(Con *con)
Either shows the top-most scratchpad window (con == NULL) or shows the specified con (if it is scratc...
void workspace_back_and_forth(void)
Focuses the previously focused workspace.
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
void render_con(Con *con, bool render_fullscreen)
"Renders" the given container (and its children), meaning that all rects are updated correctly...
bool match_matches_window(Match *match, i3Window *window)
Check if a match data structure matches the given window.
void output_push_sticky_windows(Con *old_focus)
Iterates over all outputs and pushes sticky windows to the currently visible workspace on that output...
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
void load_configuration(xcb_connection_t *conn, const char *override_configpath, bool reload)
Reads the configuration from ~/.i3/config or /etc/i3/config if not found.
void cmd_move_con_to_workspace(I3_CMD, const char *which)
Implementation of 'move [window|container] [to] workspace next|prev|next_on_output|prev_on_output'.
enum Barconfig::@9 mode
Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mo...
Con * output_get_content(Con *output)
Returns the output container below the given output container.
bool con_fullscreen_permits_focusing(Con *con)
Returns true if changing the focus to con would be allowed considering the fullscreen focus constrain...
struct _i3String i3String
Opaque data structure for storing strings.
Con * workspace_get(const char *num, bool *created)
Returns a pointer to the workspace with the given number (starting at 0), creating the workspace if n...
void cmd_move_window_to_center(I3_CMD, const char *method)
Implementation of 'move [window|container] [to] [absolute] position center.
void floating_check_size(Con *floating_con)
Called when a floating window is created or resized.
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
void ipc_shutdown(shutdown_reason_t reason)
Calls shutdown() on each socket and closes it.
void cmd_workspace(I3_CMD, const char *which)
Implementation of 'workspace next|prev|next_on_output|prev_on_output'.
void cmd_move_con_to_workspace_name(I3_CMD, const char *name, const char *no_auto_back_and_forth)
Implementation of 'move [–no-auto-back-and-forth] [window|container] [to] workspace <name>'...
void con_set_layout(Con *con, layout_t layout)
This function changes the layout of a given container.
static direction_t parse_direction(const char *str)
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
void restore_open_placeholder_windows(Con *parent)
Open placeholder windows for all children of parent.
struct all_cons_head all_cons
void startup_sequence_rename_workspace(const char *old_name, const char *new_name)
Renames workspaces that are mentioned in the startup sequences.
void set_debug_logging(const bool _debug_logging)
Set debug logging.
Con * get_existing_workspace_by_name(const char *name)
Returns the workspace with the given name or NULL if such a workspace does not exist.
void con_disable_fullscreen(Con *con)
Disables fullscreen mode for the given container, if necessary.
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
Con * con_by_mark(const char *mark)
Returns the container with the given mark or NULL if no such container exists.
void con_toggle_layout(Con *con, const char *toggle_mode)
This function toggles the layout of a given container.
Holds the status bar configuration (i3bar).
enum Con::@22 scratchpad_state
void cmd_workspace_number(I3_CMD, const char *which, const char *_no_auto_back_and_forth)
Implementation of 'workspace [–no-auto-back-and-forth] number <number>'.
void ewmh_update_visible_name(xcb_window_t window, const char *name)
Updates _NET_WM_VISIBLE_NAME.
A 'Con' represents everything from the X11 root window down to a single X11 window.
void cmd_exec(I3_CMD, const char *nosn, const char *command)
Implementation of 'exec [–no-startup-id] <command>'.
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
void purge_zerobyte_logfile(void)
Deletes the unused log files.
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
#define HANDLE_EMPTY_MATCH
When the command did not include match criteria (!), we use the currently focused container...
void con_enable_fullscreen(Con *con, fullscreen_mode_t fullscreen_mode)
Enables fullscreen mode for the given container, if necessary.
void tree_split(Con *con, orientation_t orientation)
Splits (horizontally or vertically) the given container by creating a new container which contains th...
void cmd_criteria_init(I3_CMD)
Initializes the specified 'Match' data structure and the initial state of commands.c for matching target windows of a command.
#define GREP_FIRST(dest, head, condition)
void con_set_border_style(Con *con, int border_style, int border_width)
Sets the given border style on con, correctly keeping the position/size of a floating window...
void cmd_move_con_to_workspace_back_and_forth(I3_CMD)
Implementation of 'move [window|container] [to] workspace back_and_forth'.
#define TAILQ_LAST(head, headname)
void con_close(Con *con, kill_window_t kill_window)
Closes the given container.
void cmd_focus(I3_CMD)
Implementation of 'focus'.
Con * con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode)
Returns the first fullscreen node below this node.
static Match current_match
char * resolve_tilde(const char *path)
This function resolves ~ in pathnames.
ssize_t slurp(const char *path, char **buf)
Slurp reads path in its entirety into buf, returning the length of the file or -1 if the file could n...
void i3_restart(bool forget_layout)
Restart i3 in-place appends -a to argument list to disable autostart.
void cmd_floating(I3_CMD, const char *floating_mode)
Implementation of 'floating enable|disable|toggle'.
struct ws_assignments_head ws_assignments
static void cmd_resize_floating(I3_CMD, const char *way, const char *direction_str, Con *floating_con, int px)
bool con_move_to_output_name(Con *con, const char *name, bool fix_coordinates)
Moves the given container to the currently focused container on the visible workspace on the output s...
char * title_format
The format with which the window's name should be displayed.
void cmd_split(I3_CMD, const char *direction)
Implementation of 'split v|h|t|vertical|horizontal|toggle'.
static bool cmd_resize_tiling_direction(I3_CMD, Con *current, const char *direction, int px, int ppt)
static bool cmd_bar_mode(const char *bar_mode, const char *bar_id)
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
bool workspace_move_to_output(Con *ws, Output *output)
Move the given workspace to the specified output.
void tree_next(char way, orientation_t orientation)
Changes focus in the given way (next/previous) and given orientation (horizontal/vertical).
void cmd_debuglog(I3_CMD, const char *argument)
Implementation of 'debuglog toggle|on|off'.
void con_activate(Con *con)
Sets input focus to the given container and raises it to the top.
Con * workspace_prev_on_output(void)
Returns the previous workspace on the same output.
bool regex_matches(struct regex *regex, const char *input)
Checks if the given regular expression matches the given input and returns true if it does...
void cmd_shmlog(I3_CMD, const char *argument)
Implementation of 'shmlog <size>|toggle|on|off'.
void cmd_mode(I3_CMD, const char *mode)
Implementation of 'mode <string>'.
void match_init(Match *match)
Initializes the Match data structure.
void cmd_exit(I3_CMD)
Implementation of 'exit'.
void ipc_send_workspace_event(const char *change, Con *current, Con *old)
For the workspace events we send, along with the usual "change" field, also the workspace container i...
void tree_append_json(Con *con, const char *buf, const size_t len, char **errormsg)
void cmd_focus_window_mode(I3_CMD, const char *window_mode)
Implementation of 'focus tiling|floating|mode_toggle'.
Con * workspace_next_on_output(void)
Returns the next workspace on the same output.
static void move_matches_to_workspace(Con *ws)
#define I3_CMD
The beginning of the prototype for every cmd_ function.
void floating_resize(Con *floating_con, int x, int y)
Sets size of the CT_FLOATING_CON to specified dimensions.
void floating_move_to_pointer(Con *con)
Moves the given floating con to the current pointer position.
void cmd_move_con_to_workspace_number(I3_CMD, const char *which, const char *no_auto_back_and_forth)
Implementation of 'move [–no-auto-back-and-forth] [window|container] [to] workspace number <number>'...
void x_set_i3_atoms(void)
Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH)
Con * get_existing_workspace_by_num(int num)
Returns the workspace with the given number or NULL if such a workspace does not exist.
pid_t config_error_nagbar_pid
Con * tree_open_con(Con *con, i3Window *window)
Opens an empty container in the current container.
static int border_width_from_style(border_style_t border_style, long border_width, Con *con)
Con * con_get_fullscreen_covering_ws(Con *ws)
Returns the fullscreen node that covers the given workspace if it exists.
#define TAILQ_INSERT_TAIL(head, elm, field)
#define TAILQ_FOREACH(var, head, field)
i3String * con_parse_title_format(Con *con)
Returns the window title considering the current title format.
void cmd_append_layout(I3_CMD, const char *cpath)
Implementation of 'append_layout <path>'.
void cmd_focus_level(I3_CMD, const char *level)
Implementation of 'focus parent|child'.
double px_resize_to_percent(Con *con, int px_diff)
Calculate the given container's new percent given a change in pixels.
static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *direction, int px, double ppt)
static Con * maybe_auto_back_and_forth_workspace(Con *workspace)
border_style_t border_style
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory...
char * id
Automatically generated ID for this bar config.
void cmd_move_con_to_mark(I3_CMD, const char *mark)
Implementation of 'move [window|container] [to] mark <str>'.