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); \ 86 return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
100 if (strcmp(ws->
name, name) != 0)
103 DLOG(
"This workspace is already focused.\n");
123 if (current == workspace) {
126 DLOG(
"Substituting workspace with back_and_forth, as it is focused.\n");
150 static owindows_head owindows;
186 DLOG(
"match specification finished, matching...\n");
189 struct owindows_head old = owindows;
198 DLOG(
"checking if con %p / %s matches\n", current->
con, current->
con->
name);
202 bool accept_match =
false;
208 DLOG(
"con_id matched.\n");
210 DLOG(
"con_id does not match.\n");
218 bool matched_by_mark =
false;
225 DLOG(
"match by mark\n");
226 matched_by_mark =
true;
230 if (!matched_by_mark) {
231 DLOG(
"mark does not match.\n");
239 DLOG(
"matches window!\n");
242 DLOG(
"doesn't match\n");
278 DLOG(
"which=%s\n", which);
294 if (strcmp(which,
"next") == 0)
296 else if (strcmp(which,
"prev") == 0)
298 else if (strcmp(which,
"next_on_output") == 0)
300 else if (strcmp(which,
"prev_on_output") == 0)
302 else if (strcmp(which,
"current") == 0)
305 ELOG(
"BUG: called with which=%s\n", which);
315 cmd_output->needs_tree_render =
true;
331 yerror(
"No workspace was previously active.");
342 cmd_output->needs_tree_render =
true;
352 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
353 LOG(
"You cannot move containers to i3-internal workspaces (\"%s\").\n", name);
358 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
365 ELOG(
"No windows match your criteria, cannot move.\n");
374 LOG(
"should move window to workspace %s\n", name);
378 if (!no_auto_back_and_forth)
388 cmd_output->needs_tree_render =
true;
398 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
411 LOG(
"should move window to workspace %s\n", which);
413 Con *output, *workspace = NULL;
417 if (parsed_num == -1) {
418 LOG(
"Could not parse initial part of \"%s\" as a number.\n", which);
419 yerror(
"Could not parse number \"%s\"", which);
425 child->
num == parsed_num);
431 if (!no_auto_back_and_forth)
441 cmd_output->needs_tree_render =
true;
447 LOG(
"floating resize\n");
455 if (window != NULL) {
456 if (strcmp(direction,
"up") == 0 || strcmp(direction,
"down") == 0 ||
457 strcmp(direction,
"height") == 0) {
462 }
else if (strcmp(direction,
"left") == 0 || strcmp(direction,
"right") == 0) {
470 if (strcmp(direction,
"up") == 0) {
472 }
else if (strcmp(direction,
"down") == 0 || strcmp(direction,
"height") == 0) {
474 }
else if (strcmp(direction,
"left") == 0) {
484 if (memcmp(&old_rect, &(floating_con->
rect),
sizeof(
Rect)) == 0)
487 if (strcmp(direction,
"up") == 0) {
489 }
else if (strcmp(direction,
"left") == 0) {
499 LOG(
"tiling resize\n");
501 Con *first = current;
503 if (!strcmp(direction,
"left"))
504 search_direction =
D_LEFT;
505 else if (!strcmp(direction,
"right"))
507 else if (!strcmp(direction,
"up"))
508 search_direction =
D_UP;
510 search_direction =
D_DOWN;
514 LOG(
"No second container in this direction found.\n");
521 LOG(
"ins. %d children\n", children);
522 double percentage = 1.0 / children;
523 LOG(
"default percentage = %f\n", percentage);
526 LOG(
"second->percent = %f\n", second->
percent);
527 LOG(
"first->percent before = %f\n", first->
percent);
532 double new_first_percent = first->
percent + ((double)ppt / 100.0);
533 double new_second_percent = second->
percent - ((double)ppt / 100.0);
534 LOG(
"new_first_percent = %f\n", new_first_percent);
535 LOG(
"new_second_percent = %f\n", new_second_percent);
540 first->
percent += ((double)ppt / 100.0);
541 second->
percent -= ((double)ppt / 100.0);
542 LOG(
"first->percent after = %f\n", first->
percent);
543 LOG(
"second->percent after = %f\n", second->
percent);
545 LOG(
"Not resizing, already at minimum size\n");
552 LOG(
"width/height resize\n");
556 current = current->
parent;
560 (strcmp(direction,
"width") == 0 ?
HORIZ :
VERT);
562 while (current->
type != CT_WORKSPACE &&
563 current->
type != CT_FLOATING_CON &&
565 current = current->
parent;
569 LOG(
"ins. %d children\n", children);
570 double percentage = 1.0 / children;
571 LOG(
"default percentage = %f\n", percentage);
575 if ((orientation ==
HORIZ &&
576 strcmp(direction,
"height") == 0) ||
577 (orientation ==
VERT &&
578 strcmp(direction,
"width") == 0)) {
579 LOG(
"You cannot resize in that direction. Your focus is in a %s split container currently.\n",
580 (orientation ==
HORIZ ?
"horizontal" :
"vertical"));
586 LOG(
"This is the only container, cannot resize.\n");
594 LOG(
"child->percent = %f (child %p)\n", child->
percent, child);
599 double new_current_percent = current->
percent + ((double)ppt / 100.0);
600 double subtract_percent = ((double)ppt / 100.0) / (children - 1);
601 LOG(
"new_current_percent = %f\n", new_current_percent);
602 LOG(
"subtract_percent = %f\n", subtract_percent);
606 if (child == current)
609 LOG(
"Not resizing, already at minimum size (child %p would end up with a size of %.f\n", child, child->
percent - subtract_percent);
615 LOG(
"Not resizing, already at minimum size\n");
620 current->
percent += ((double)ppt / 100.0);
621 LOG(
"current->percent after = %f\n", current->
percent);
624 if (child == current)
626 child->
percent -= subtract_percent;
627 LOG(
"child->percent after (%p) = %f\n", child, child->
percent);
637 void cmd_resize(
I3_CMD,
const char *way,
const char *direction,
long resize_px,
long resize_ppt) {
638 DLOG(
"resizing in way %s, direction %s, px %ld or ppt %ld\n", way, direction, resize_px, resize_ppt);
639 if (strcmp(way,
"shrink") == 0) {
650 DLOG(
"This is a dock window. Not resizing (con = %p)\n)", current->
con);
658 if (strcmp(direction,
"width") == 0 ||
659 strcmp(direction,
"height") == 0) {
661 current->
con, way, direction, resize_ppt))
665 current->
con, way, direction, resize_ppt))
671 cmd_output->needs_tree_render =
true;
681 DLOG(
"resizing to %ldx%ld px\n", cwidth, cheight);
682 if (cwidth <= 0 || cheight <= 0) {
683 ELOG(
"Resize failed: dimensions cannot be negative (was %ldx%ld)\n", cwidth, cheight);
695 ELOG(
"Resize failed: %p not a floating container\n", current->
con);
699 cmd_output->needs_tree_render =
true;
709 DLOG(
"border style should be changed to %s with border width %ld\n", border_style_str, border_width);
717 int con_border_width = border_width;
719 if (strcmp(border_style_str,
"toggle") == 0) {
723 con_border_width = 2;
724 else if (border_style ==
BS_NONE)
725 con_border_width = 0;
727 con_border_width = 1;
729 if (strcmp(border_style_str,
"normal") == 0) {
731 }
else if (strcmp(border_style_str,
"pixel") == 0) {
733 }
else if (strcmp(border_style_str,
"1pixel") == 0) {
735 con_border_width = 1;
736 }
else if (strcmp(border_style_str,
"none") == 0) {
739 ELOG(
"BUG: called with border_style=%s\n", border_style_str);
748 cmd_output->needs_tree_render =
true;
758 LOG(
"-------------------------------------------------\n");
759 LOG(
" NOP: %s\n", comment);
760 LOG(
"-------------------------------------------------\n");
769 LOG(
"Appending layout \"%s\"\n", path);
775 LOG(
"JSON content = %d\n", content);
777 ELOG(
"Could not determine the contents of \"%s\", not loading.\n", path);
778 yerror(
"Could not determine the contents of \"%s\".", path);
794 DLOG(
"Appending to parent=%p instead of focused=%p\n", parent,
focused);
795 char *errormsg = NULL;
797 if (errormsg != NULL) {
822 cmd_output->needs_tree_render =
true;
832 DLOG(
"which=%s\n", which);
835 LOG(
"Cannot switch workspace while in global fullscreen\n");
840 if (strcmp(which,
"next") == 0)
842 else if (strcmp(which,
"prev") == 0)
844 else if (strcmp(which,
"next_on_output") == 0)
846 else if (strcmp(which,
"prev_on_output") == 0)
849 ELOG(
"BUG: called with which=%s\n", which);
856 cmd_output->needs_tree_render =
true;
866 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
867 Con *output, *workspace = NULL;
870 LOG(
"Cannot switch workspace while in global fullscreen\n");
877 if (parsed_num == -1) {
878 LOG(
"Could not parse initial part of \"%s\" as a number.\n", which);
879 yerror(
"Could not parse number \"%s\"", which);
885 child->
num == parsed_num);
888 LOG(
"There is no workspace with number %ld, creating a new one.\n", parsed_num);
891 cmd_output->needs_tree_render =
true;
898 cmd_output->needs_tree_render =
true;
909 LOG(
"Cannot switch workspace while in global fullscreen\n");
916 cmd_output->needs_tree_render =
true;
926 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
928 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
929 LOG(
"You cannot switch to the i3-internal workspaces (\"%s\").\n", name);
935 LOG(
"Cannot switch workspace while in global fullscreen\n");
940 DLOG(
"should switch to workspace %s\n", name);
945 cmd_output->needs_tree_render =
true;
958 if (current == NULL) {
964 if (current !=
TAILQ_LAST(&owindows, owindows_head)) {
965 yerror(
"A mark must not be put onto more than one window");
972 if (toggle != NULL) {
978 cmd_output->needs_tree_render =
true;
997 cmd_output->needs_tree_render =
true;
1007 DLOG(
"mode=%s\n", mode);
1019 DLOG(
"Should move window to output \"%s\".\n", name);
1023 bool had_error =
false;
1028 assert(current_output != NULL);
1031 if (output == NULL) {
1032 ELOG(
"Could not find output \"%s\", skipping.\n", name);
1040 ELOG(
"Could not find a visible workspace on output %p.\n", output);
1048 cmd_output->needs_tree_render =
true;
1057 DLOG(
"moving window to mark \"%s\"\n", mark);
1064 DLOG(
"moving matched window %p / %s to mark \"%s\"\n", current->
con, current->
con->
name, mark);
1068 cmd_output->needs_tree_render =
true;
1079 DLOG(
"floating_mode=%s\n", floating_mode);
1085 if (strcmp(floating_mode,
"toggle") == 0) {
1086 DLOG(
"should toggle mode\n");
1089 DLOG(
"should switch mode to %s\n", floating_mode);
1090 if (strcmp(floating_mode,
"enable") == 0) {
1098 cmd_output->needs_tree_render =
true;
1108 DLOG(
"should move workspace to output %s\n", name);
1117 ELOG(
"Failed to move workspace to output.\n");
1123 cmd_output->needs_tree_render =
true;
1136 LOG(
"splitting in direction %c\n", direction[0]);
1139 ELOG(
"Cannot split a docked container, skipping.\n");
1144 if (direction[0] ==
't') {
1146 if (current->
con->
type == CT_WORKSPACE) {
1162 cmd_output->needs_tree_render =
true;
1172 if (kill_mode_str == NULL)
1173 kill_mode_str =
"window";
1175 DLOG(
"kill_mode=%s\n", kill_mode_str);
1178 if (strcmp(kill_mode_str,
"window") == 0)
1180 else if (strcmp(kill_mode_str,
"client") == 0)
1183 ELOG(
"BUG: called with kill_mode=%s\n", kill_mode_str);
1195 cmd_output->needs_tree_render =
true;
1205 bool no_startup_id = (nosn != NULL);
1207 DLOG(
"should execute %s, no_startup_id = %d\n", command, no_startup_id);
1219 DLOG(
"direction = *%s*\n", direction);
1221 if (strcmp(direction,
"left") == 0)
1223 else if (strcmp(direction,
"right") == 0)
1225 else if (strcmp(direction,
"up") == 0)
1227 else if (strcmp(direction,
"down") == 0)
1230 ELOG(
"Invalid focus direction (%s)\n", direction);
1235 cmd_output->needs_tree_render =
true;
1245 DLOG(
"window_mode = %s\n", window_mode);
1249 if (strcmp(window_mode,
"mode_toggle") == 0) {
1251 window_mode =
"tiling";
1253 window_mode =
"floating";
1257 if ((strcmp(window_mode,
"floating") == 0 && current->
type != CT_FLOATING_CON) ||
1258 (strcmp(window_mode,
"tiling") == 0 && current->
type == CT_FLOATING_CON))
1266 cmd_output->needs_tree_render =
true;
1276 DLOG(
"level = %s\n", level);
1277 bool success =
false;
1281 if (strcmp(level,
"parent") == 0) {
1286 ELOG(
"'focus parent': Currently in fullscreen, not going up\n");
1294 cmd_output->needs_tree_render = success;
1307 ELOG(
"You have to specify which window/container should be focused.\n");
1308 ELOG(
"Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
1310 yerror(
"You have to specify which window/container should be focused");
1327 LOG(
"Cannot change focus while in fullscreen mode (fullscreen rules).\n");
1333 if (ws == __i3_scratch) {
1360 LOG(
"focusing %p / %s\n", current->
con, current->
con->
name);
1366 LOG(
"WARNING: Your criteria for the focus command matches %d containers, " 1367 "while only exactly one container can be focused at a time.\n",
1370 cmd_output->needs_tree_render =
true;
1381 DLOG(
"%s fullscreen, mode = %s\n", action, fullscreen_mode);
1388 if (strcmp(action,
"toggle") == 0) {
1390 }
else if (strcmp(action,
"enable") == 0) {
1392 }
else if (strcmp(action,
"disable") == 0) {
1397 cmd_output->needs_tree_render =
true;
1407 DLOG(
"%s sticky on window\n", action);
1413 ELOG(
"only containers holding a window can be made sticky, skipping con = %p\n", current->
con);
1416 DLOG(
"setting sticky for container = %p / %s\n", current->
con, current->
con->
name);
1418 bool sticky =
false;
1419 if (strcmp(action,
"enable") == 0)
1421 else if (strcmp(action,
"disable") == 0)
1423 else if (strcmp(action,
"toggle") == 0)
1436 cmd_output->needs_tree_render =
true;
1451 DLOG(
"moving in direction %s, px %ld\n", direction, move_px);
1453 DLOG(
"floating move with %ld pixels\n", move_px);
1455 if (strcmp(direction,
"left") == 0) {
1456 newrect.
x -= move_px;
1457 }
else if (strcmp(direction,
"right") == 0) {
1458 newrect.
x += move_px;
1459 }
else if (strcmp(direction,
"up") == 0) {
1460 newrect.
y -= move_px;
1461 }
else if (strcmp(direction,
"down") == 0) {
1462 newrect.
y += move_px;
1467 cmd_output->needs_tree_render =
true;
1472 if (
focused != initially_focused)
1486 if (strcmp(layout_str,
"stacking") == 0)
1487 layout_str =
"stacked";
1490 if (strcmp(layout_str,
"default") == 0)
1492 else if (strcmp(layout_str,
"stacked") == 0)
1494 else if (strcmp(layout_str,
"tabbed") == 0)
1496 else if (strcmp(layout_str,
"splitv") == 0)
1498 else if (strcmp(layout_str,
"splith") == 0)
1501 ELOG(
"Unknown layout \"%s\", this is a mismatch between code and parser spec.\n", layout_str);
1505 DLOG(
"changing layout to %s (%d)\n", layout_str, layout);
1510 ELOG(
"cannot change layout of a docked container, skipping it.\n");
1518 cmd_output->needs_tree_render =
true;
1530 if (toggle_mode == NULL)
1531 toggle_mode =
"default";
1533 DLOG(
"toggling layout (mode = %s)\n", toggle_mode);
1545 cmd_output->needs_tree_render =
true;
1555 LOG(
"Exiting due to user command.\n");
1556 #ifdef I3_ASAN_ENABLED 1557 __lsan_do_leak_check();
1561 xcb_disconnect(
conn);
1591 LOG(
"restarting i3\n");
1608 LOG(
"opening new container\n");
1617 y(integer, (uintptr_t)con);
1620 cmd_output->needs_tree_render =
true;
1630 DLOG(
"name = %s\n", name);
1635 Output *current_output = NULL;
1640 assert(current_output != NULL);
1645 LOG(
"No such output found.\n");
1660 cmd_output->needs_tree_render =
true;
1670 bool has_error =
false;
1677 ELOG(
"Cannot change position. The window/container is not floating\n");
1680 yerror(
"Cannot change position of a window/container because it is not floating.");
1687 if (strcmp(method,
"absolute") == 0) {
1691 DLOG(
"moving to absolute position %ld %ld\n", x, y);
1693 cmd_output->needs_tree_render =
true;
1696 if (strcmp(method,
"position") == 0) {
1699 DLOG(
"moving to position %ld %ld\n", x, y);
1717 bool has_error =
false;
1723 if (floating_con == NULL) {
1724 ELOG(
"con %p / %s is not floating, cannot move it to the center.\n",
1728 yerror(
"Cannot change position of a window/container because it is not floating.");
1735 if (strcmp(method,
"absolute") == 0) {
1736 DLOG(
"moving to absolute center\n");
1740 cmd_output->needs_tree_render =
true;
1743 if (strcmp(method,
"position") == 0) {
1744 DLOG(
"moving to center\n");
1747 cmd_output->needs_tree_render =
true;
1766 if (floating_con == NULL) {
1767 DLOG(
"con %p / %s is not floating, cannot move it to the mouse position.\n",
1772 DLOG(
"moving floating container %p / %s to cursor position\n", floating_con, floating_con->
name);
1776 cmd_output->needs_tree_render =
true;
1785 DLOG(
"should move window to scratchpad\n");
1795 cmd_output->needs_tree_render =
true;
1805 DLOG(
"should show scratchpad window\n");
1817 cmd_output->needs_tree_render =
true;
1827 DLOG(
"setting title_format to \"%s\"\n", format);
1832 DLOG(
"setting title_format for %p / %s\n", current->
con, current->
con->
name);
1837 if (strcasecmp(format,
"%title") != 0) {
1861 cmd_output->needs_tree_render =
true;
1870 if (strncasecmp(new_name,
"__", strlen(
"__")) == 0) {
1871 LOG(
"Cannot rename workspace to \"%s\": names starting with __ are i3-internal.\n", new_name);
1876 LOG(
"Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name);
1878 LOG(
"Renaming current workspace to \"%s\"\n", new_name);
1881 Con *output, *workspace = NULL;
1885 !strcasecmp(child->name, old_name));
1888 old_name = workspace->
name;
1892 yerror(
"Old workspace \"%s\" not found", old_name);
1896 Con *check_dest = NULL;
1899 !strcasecmp(child->name, new_name));
1903 if (check_dest != NULL && check_dest != workspace) {
1904 yerror(
"New workspace \"%s\" already exists", new_name);
1910 char *old_name_copy =
sstrdup(old_name);
1915 LOG(
"num = %d\n", workspace->
num);
1926 if (assignment->
output == NULL)
1934 if (previously_focused)
1943 cmd_output->needs_tree_render =
true;
1952 free(old_name_copy);
1961 bool toggle =
false;
1962 if (strcmp(bar_mode,
"dock") == 0)
1964 else if (strcmp(bar_mode,
"hide") == 0)
1966 else if (strcmp(bar_mode,
"invisible") == 0)
1968 else if (strcmp(bar_mode,
"toggle") == 0)
1971 ELOG(
"Unknown bar mode \"%s\", this is a mismatch between code and parser spec.\n", bar_mode);
1975 bool changed_sth =
false;
1978 if (bar_id && strcmp(current->
id, bar_id) != 0)
1982 mode = (current->
mode + 1) % 2;
1984 DLOG(
"Changing bar mode of bar_id '%s' to '%s (%d)'\n", current->
id, bar_mode, mode);
1985 current->
mode = mode;
1992 if (bar_id && !changed_sth) {
1993 DLOG(
"Changing bar mode of bar_id %s failed, bar_id not found.\n", bar_id);
2005 int hidden_state = S_SHOW;
2006 bool toggle =
false;
2007 if (strcmp(bar_hidden_state,
"hide") == 0)
2008 hidden_state = S_HIDE;
2009 else if (strcmp(bar_hidden_state,
"show") == 0)
2010 hidden_state = S_SHOW;
2011 else if (strcmp(bar_hidden_state,
"toggle") == 0)
2014 ELOG(
"Unknown bar state \"%s\", this is a mismatch between code and parser spec.\n", bar_hidden_state);
2018 bool changed_sth =
false;
2021 if (bar_id && strcmp(current->
id, bar_id) != 0)
2027 DLOG(
"Changing bar hidden_state of bar_id '%s' to '%s (%d)'\n", current->
id, bar_hidden_state, hidden_state);
2035 if (bar_id && !changed_sth) {
2036 DLOG(
"Changing bar hidden_state of bar_id %s failed, bar_id not found.\n", bar_id);
2047 void cmd_bar(
I3_CMD,
const char *bar_type,
const char *bar_value,
const char *bar_id) {
2049 if (strcmp(bar_type,
"mode") == 0)
2051 else if (strcmp(bar_type,
"hidden_state") == 0)
2054 ELOG(
"Unknown bar option type \"%s\", this is a mismatch between code and parser spec.\n", bar_type);
2070 if (!strcmp(argument,
"toggle"))
2073 else if (!strcmp(argument,
"on"))
2075 else if (!strcmp(argument,
"off"))
2081 LOG(
"Restarting shm logging...\n");
2089 LOG(
"%s shm logging\n",
shmlog_size > 0 ?
"Enabling" :
"Disabling");
2102 if (!strcmp(argument,
"toggle")) {
2103 LOG(
"%s debug logging\n", logging ?
"Disabling" :
"Enabling");
2105 }
else if (!strcmp(argument,
"on") && !logging) {
2106 LOG(
"Enabling debug logging\n");
2108 }
else if (!strcmp(argument,
"off") && logging) {
2109 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.
void con_detach(Con *con)
Detaches the given container from its current parent.
Stores which workspace (by name or number) goes to which output.
void ewmh_update_current_desktop(void)
Updates _NET_CURRENT_DESKTOP with the current desktop number.
void ewmh_update_desktop_names(void)
Updates _NET_DESKTOP_NAMES: "The names of all virtual desktops.
void cmd_kill(I3_CMD, const char *kill_mode_str)
Implementation of 'kill [window|client]'.
void cmd_mark(I3_CMD, const char *mark, const char *mode, const char *toggle)
Implementation of 'mark [–add|–replace] [–toggle] <mark>'.
void cmd_title_format(I3_CMD, const char *format)
Implementation of 'title_format <format>'.
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 cmd_open(I3_CMD)
Implementation of 'open'.
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>'.
static void cmd_resize_floating(I3_CMD, const char *way, const char *direction, Con *floating_con, int px)
void set_debug_logging(const bool _debug_logging)
Set debug logging.
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'.
#define TAILQ_LAST(head, headname)
static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *way, const char *direction, int ppt)
void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name)
Implementation of 'rename workspace <name> to <name>'.
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
struct barconfig_head barconfigs
#define yerror(format,...)
bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction)
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.
#define TAILQ_ENTRY(type)
bool workspace_move_to_output(Con *ws, const char *name)
Move the given workspace to the specified output.
bool level_up(void)
Moves focus one level up.
void purge_zerobyte_logfile(void)
Deletes the unused log files.
void cmd_move_con_to_output(I3_CMD, const char *name)
Implementation of 'move [window|container] [to] output <str>'.
#define TAILQ_NEXT(elm, field)
fullscreen_mode_t
Fullscreen modes.
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.
An Output is a physical output on your graphics driver.
void cmd_criteria_match_windows(I3_CMD)
A match specification just finished (the closing square bracket was found), so we filter the list of ...
bool match_matches_window(Match *match, i3Window *window)
Check if a match data structure matches the given window.
void cmd_move_window_to_position(I3_CMD, const char *method, long x, long y)
Implementation of 'move [window|container] [to] [absolute] position <px> [px] <px> [px]...
void floating_center(Con *con, Rect rect)
Centers a floating con above the specified rect.
void restore_open_placeholder_windows(Con *parent)
Open placeholder windows for all children of parent.
void match_free(Match *match)
Frees the given match.
layout_t
Container layouts.
char * id
Automatically generated ID for this bar config.
void startup_sequence_rename_workspace(const char *old_name, const char *new_name)
Renames workspaces that are mentioned in the startup sequences.
enum Barconfig::@9 hidden_state
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...
Con * output_get_content(Con *output)
Returns the output container below the given output container.
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)
void render_con(Con *con, bool render_fullscreen)
"Renders" the given container (and its children), meaning that all rects are updated correctly...
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 cmd_move_window_to_mouse(I3_CMD)
Implementation of 'move [window|container] [to] position mouse'.
pid_t command_error_nagbar_pid
bool workspace_auto_back_and_forth
Automatic workspace back and forth switching.
Stores a rectangle, for example the size of a window, the child window etc.
void cmd_layout_toggle(I3_CMD, const char *toggle_mode)
Implementation of 'layout toggle [all|split]'.
json_content_t json_determine_content(const char *filename)
void con_mark(Con *con, const char *mark, mark_mode_t mode)
Assigns a mark to the container.
#define TAILQ_INSERT_TAIL(head, elm, field)
const int default_shmlog_size
void cmd_unmark(I3_CMD, const char *mark)
Implementation of 'unmark [mark]'.
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 cmd_bar_mode(const char *bar_mode, const char *bar_id)
void cmd_restart(I3_CMD)
Implementation of 'restart'.
char * resolve_tilde(const char *path)
This function resolves ~ in pathnames.
void cmd_workspace_back_and_forth(I3_CMD)
Implementation of 'workspace back_and_forth'.
void update_shmlog_atom()
Set up the SHMLOG_PATH atom.
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>'.
void cmd_sticky(I3_CMD, const char *action)
Implementation of 'sticky enable|disable|toggle'.
struct ws_assignments_head ws_assignments
typedef TAILQ_HEAD(owindows_head, owindow)
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
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.
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
Con * workspace_next(void)
Returns the next workspace.
void cmd_scratchpad_show(I3_CMD)
Implementation of 'scratchpad show'.
Holds the status bar configuration (i3bar).
xcb_connection_t * conn
XCB connection and root screen.
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.
#define TAILQ_FOREACH(var, head, field)
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 floating_resize(Con *floating_con, int x, int y)
Sets size of the CT_FLOATING_CON to specified dimensions.
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.
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.
#define TAILQ_FIRST(head)
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
orientation_t con_orientation(Con *con)
Returns the orientation of the given container (for stacked containers, vertical orientation is used ...
void cmd_resize_set(I3_CMD, long cwidth, long cheight)
Implementation of 'resize set <px> [px] <px> [px]'.
void cmd_move_direction(I3_CMD, const char *direction, long move_px)
Implementation of 'move <direction> [<pixels> [px]]'.
static bool cmd_resize_tiling_direction(I3_CMD, Con *current, const char *way, const char *direction, int ppt)
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'.
void scratchpad_move(Con *con)
Moves the specified window to the __i3_scratch workspace, making it floating and setting the appropri...
Con * workspace_back_and_forth_get(void)
Returns the previously focused workspace con, or NULL if unavailable.
border_style_t border_style
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.
void ipc_shutdown(void)
Calls shutdown() on each socket and closes it.
#define TAILQ_REMOVE(head, elm, field)
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 workspace_back_and_forth(void)
Focuses the previously focused workspace.
void match_init(Match *match)
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'.
void update_barconfig()
Sends the current bar configuration as an event to all barconfig_update listeners.
bool con_fullscreen_permits_focusing(Con *con)
Returns true if changing the focus to con would be allowed considering the fullscreen focus constrain...
void tree_append_json(Con *con, const char *filename, char **errormsg)
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.
Con * con
Pointer to the Con which represents this output.
bool get_debug_logging(void)
Checks if debug logging is active.
void floating_move_to_pointer(Con *con)
Moves the given floating con to the current pointer position.
void cmd_workspace(I3_CMD, const char *which)
Implementation of 'workspace next|prev|next_on_output|prev_on_output'.
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
void start_application(const char *command, bool no_startup_id)
Starts the given application by passing it through a shell.
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory...
void con_set_layout(Con *con, layout_t layout)
This function changes the layout of a given container.
struct all_cons_head all_cons
bool con_has_children(Con *con)
Returns true if this node has regular or floating children.
void con_disable_fullscreen(Con *con)
Disables fullscreen mode for the given container, if necessary.
void toggle_floating_mode(Con *con, bool automatic)
Calls floating_enable() for tiling containers and floating_disable() for floating containers...
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
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...
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
void con_toggle_layout(Con *con, const char *toggle_mode)
This function toggles the layout of a given container.
void init_logging(void)
Initializes logging by creating an error logfile in /tmp (or XDG_RUNTIME_DIR, see get_process_filenam...
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 cmd_exec(I3_CMD, const char *nosn, const char *command)
Implementation of 'exec [–no-startup-id] <command>'.
enum Barconfig::@8 mode
Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mo...
A 'Con' represents everything from the X11 root window down to a single X11 window.
static bool definitelyGreaterThan(float a, float b, float epsilon)
#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 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 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'.
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
bool match_is_empty(Match *match)
Check if a match is empty.
void floating_reposition(Con *con, Rect newrect)
Repositions the CT_FLOATING_CON to have the coordinates specified by newrect, but only if the coordin...
void floating_check_size(Con *floating_con)
Called when a floating window is created or resized.
enum Con::@22 scratchpad_state
void i3_restart(bool forget_layout)
Restart i3 in-place appends -a to argument list to disable autostart.
Output * get_output_for_con(Con *con)
Returns the output for the given con.
void cmd_floating(I3_CMD, const char *floating_mode)
Implementation of 'floating enable|disable|toggle'.
void scratchpad_show(Con *con)
Either shows the top-most scratchpad window (con == NULL) or shows the specified con (if it is scratc...
void cmd_split(I3_CMD, const char *direction)
Implementation of 'split v|h|t|vertical|horizontal|toggle'.
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
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)
int logical_px(const int logical)
Convert a logical amount of pixels (e.g.
struct _i3String i3String
Opaque data structure for storing strings.
Con * workspace_prev_on_output(void)
Returns the previous workspace on the same output.
void ewmh_update_visible_name(xcb_window_t window, const char *name)
Updates _NET_WM_VISIBLE_NAME.
#define TAILQ_EMPTY(head)
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
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_shmlog(I3_CMD, const char *argument)
void cmd_mode(I3_CMD, const char *mode)
Implementation of 'mode <string>'.
void cmd_exit(I3_CMD)
Implementation of 'exit'.
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_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.
#define I3_CMD
The beginning of the prototype for every cmd_ function.
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 x_set_i3_atoms(void)
Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH)
char * title_format
The format with which the window's name should be displayed.
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 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...
pid_t config_error_nagbar_pid
Con * tree_open_con(Con *con, i3Window *window)
Opens an empty container in the current container.
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.
void output_push_sticky_windows(Con *to_focus)
Iterates over all outputs and pushes sticky windows to the currently visible workspace on that output...
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
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'.
static Con * maybe_auto_back_and_forth_workspace(Con *workspace)
void floating_disable(Con *con, bool automatic)
Disables floating mode for the given container by re-attaching the container to its old parent...
bool cmd_bar_hidden_state(const char *bar_hidden_state, const char *bar_id)
enum Window::@13 dock
Whether the window says it is a dock window.
void cmd_move_con_to_mark(I3_CMD, const char *mark)
Implementation of 'move [window|container] [to] mark <str>'.