2 #define I3__FILE__ "commands.c"
15 #ifdef I3_ASAN_ENABLED
16 #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);
95 assert(output != NULL);
111 if (strcmp(ws->
name, name) != 0)
114 DLOG(
"This workspace is already focused.\n");
134 if (current == workspace) {
137 DLOG(
"Substituting workspace with back_and_forth, as it is focused.\n");
161 static owindows_head owindows;
197 DLOG(
"match specification finished, matching...\n");
200 struct owindows_head old = owindows;
209 DLOG(
"checking if con %p / %s matches\n", current->
con, current->
con->
name);
213 bool accept_match =
false;
219 DLOG(
"con_id matched.\n");
221 DLOG(
"con_id does not match.\n");
229 bool matched_by_mark =
false;
236 DLOG(
"match by mark\n");
237 matched_by_mark =
true;
241 if (!matched_by_mark) {
242 DLOG(
"mark does not match.\n");
250 DLOG(
"matches window!\n");
253 DLOG(
"doesn't match\n");
289 DLOG(
"which=%s\n", which);
305 if (strcmp(which,
"next") == 0)
307 else if (strcmp(which,
"prev") == 0)
309 else if (strcmp(which,
"next_on_output") == 0)
311 else if (strcmp(which,
"prev_on_output") == 0)
313 else if (strcmp(which,
"current") == 0)
316 ELOG(
"BUG: called with which=%s\n", which);
326 cmd_output->needs_tree_render =
true;
342 yerror(
"No workspace was previously active.");
353 cmd_output->needs_tree_render =
true;
363 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
364 LOG(
"You cannot move containers to i3-internal workspaces (\"%s\").\n", name);
369 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
376 ELOG(
"No windows match your criteria, cannot move.\n");
385 LOG(
"should move window to workspace %s\n", name);
389 if (!no_auto_back_and_forth)
399 cmd_output->needs_tree_render =
true;
409 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
422 LOG(
"should move window to workspace %s\n", which);
424 Con *output, *workspace = NULL;
428 if (parsed_num == -1) {
429 LOG(
"Could not parse initial part of \"%s\" as a number.\n", which);
430 yerror(
"Could not parse number \"%s\"", which);
436 child->
num == parsed_num);
442 if (!no_auto_back_and_forth)
452 cmd_output->needs_tree_render =
true;
458 LOG(
"floating resize\n");
466 if (window != NULL) {
467 if (strcmp(direction,
"up") == 0 || strcmp(direction,
"down") == 0 ||
468 strcmp(direction,
"height") == 0) {
473 }
else if (strcmp(direction,
"left") == 0 || strcmp(direction,
"right") == 0) {
481 if (strcmp(direction,
"up") == 0) {
483 }
else if (strcmp(direction,
"down") == 0 || strcmp(direction,
"height") == 0) {
485 }
else if (strcmp(direction,
"left") == 0) {
495 if (memcmp(&old_rect, &(floating_con->
rect),
sizeof(
Rect)) == 0)
498 if (strcmp(direction,
"up") == 0) {
500 }
else if (strcmp(direction,
"left") == 0) {
510 LOG(
"tiling resize\n");
512 Con *first = current;
514 if (!strcmp(direction,
"left"))
515 search_direction =
D_LEFT;
516 else if (!strcmp(direction,
"right"))
518 else if (!strcmp(direction,
"up"))
519 search_direction =
D_UP;
521 search_direction =
D_DOWN;
525 LOG(
"No second container in this direction found.\n");
532 LOG(
"ins. %d children\n", children);
533 double percentage = 1.0 / children;
534 LOG(
"default percentage = %f\n", percentage);
537 LOG(
"second->percent = %f\n", second->
percent);
538 LOG(
"first->percent before = %f\n", first->
percent);
543 double new_first_percent = first->
percent + ((double)ppt / 100.0);
544 double new_second_percent = second->
percent - ((double)ppt / 100.0);
545 LOG(
"new_first_percent = %f\n", new_first_percent);
546 LOG(
"new_second_percent = %f\n", new_second_percent);
551 first->
percent += ((double)ppt / 100.0);
552 second->
percent -= ((double)ppt / 100.0);
553 LOG(
"first->percent after = %f\n", first->
percent);
554 LOG(
"second->percent after = %f\n", second->
percent);
556 LOG(
"Not resizing, already at minimum size\n");
563 LOG(
"width/height resize\n");
567 current = current->
parent;
571 (strcmp(direction,
"width") == 0 ?
HORIZ :
VERT);
573 while (current->
type != CT_WORKSPACE &&
574 current->
type != CT_FLOATING_CON &&
576 current = current->
parent;
580 LOG(
"ins. %d children\n", children);
581 double percentage = 1.0 / children;
582 LOG(
"default percentage = %f\n", percentage);
586 if ((orientation ==
HORIZ &&
587 strcmp(direction,
"height") == 0) ||
588 (orientation ==
VERT &&
589 strcmp(direction,
"width") == 0)) {
590 LOG(
"You cannot resize in that direction. Your focus is in a %s split container currently.\n",
591 (orientation ==
HORIZ ?
"horizontal" :
"vertical"));
597 LOG(
"This is the only container, cannot resize.\n");
605 LOG(
"child->percent = %f (child %p)\n", child->
percent, child);
610 double new_current_percent = current->
percent + ((double)ppt / 100.0);
611 double subtract_percent = ((double)ppt / 100.0) / (children - 1);
612 LOG(
"new_current_percent = %f\n", new_current_percent);
613 LOG(
"subtract_percent = %f\n", subtract_percent);
617 if (child == current)
620 LOG(
"Not resizing, already at minimum size (child %p would end up with a size of %.f\n", child, child->
percent - subtract_percent);
626 LOG(
"Not resizing, already at minimum size\n");
631 current->
percent += ((double)ppt / 100.0);
632 LOG(
"current->percent after = %f\n", current->
percent);
635 if (child == current)
637 child->
percent -= subtract_percent;
638 LOG(
"child->percent after (%p) = %f\n", child, child->
percent);
648 void cmd_resize(
I3_CMD,
const char *way,
const char *direction,
long resize_px,
long resize_ppt) {
649 DLOG(
"resizing in way %s, direction %s, px %ld or ppt %ld\n", way, direction, resize_px, resize_ppt);
650 if (strcmp(way,
"shrink") == 0) {
661 DLOG(
"This is a dock window. Not resizing (con = %p)\n)", current->
con);
669 if (strcmp(direction,
"width") == 0 ||
670 strcmp(direction,
"height") == 0) {
672 current->
con, way, direction, resize_ppt))
676 current->
con, way, direction, resize_ppt))
682 cmd_output->needs_tree_render =
true;
692 DLOG(
"resizing to %ldx%ld px\n", cwidth, cheight);
693 if (cwidth <= 0 || cheight <= 0) {
694 ELOG(
"Resize failed: dimensions cannot be negative (was %ldx%ld)\n", cwidth, cheight);
706 ELOG(
"Resize failed: %p not a floating container\n", current->
con);
710 cmd_output->needs_tree_render =
true;
720 DLOG(
"border style should be changed to %s with border width %ld\n", border_style_str, border_width);
728 int con_border_width = border_width;
730 if (strcmp(border_style_str,
"toggle") == 0) {
734 con_border_width = 2;
735 else if (border_style ==
BS_NONE)
736 con_border_width = 0;
738 con_border_width = 1;
740 if (strcmp(border_style_str,
"normal") == 0) {
742 }
else if (strcmp(border_style_str,
"pixel") == 0) {
744 }
else if (strcmp(border_style_str,
"1pixel") == 0) {
746 con_border_width = 1;
747 }
else if (strcmp(border_style_str,
"none") == 0) {
750 ELOG(
"BUG: called with border_style=%s\n", border_style_str);
759 cmd_output->needs_tree_render =
true;
769 LOG(
"-------------------------------------------------\n");
770 LOG(
" NOP: %s\n", comment);
771 LOG(
"-------------------------------------------------\n");
780 LOG(
"Appending layout \"%s\"\n", path);
786 LOG(
"JSON content = %d\n", content);
788 ELOG(
"Could not determine the contents of \"%s\", not loading.\n", path);
789 yerror(
"Could not determine the contents of \"%s\".", path);
805 DLOG(
"Appending to parent=%p instead of focused=%p\n", parent,
focused);
806 char *errormsg = NULL;
808 if (errormsg != NULL) {
833 cmd_output->needs_tree_render =
true;
843 DLOG(
"which=%s\n", which);
846 LOG(
"Cannot switch workspace while in global fullscreen\n");
851 if (strcmp(which,
"next") == 0)
853 else if (strcmp(which,
"prev") == 0)
855 else if (strcmp(which,
"next_on_output") == 0)
857 else if (strcmp(which,
"prev_on_output") == 0)
860 ELOG(
"BUG: called with which=%s\n", which);
867 cmd_output->needs_tree_render =
true;
877 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
878 Con *output, *workspace = NULL;
881 LOG(
"Cannot switch workspace while in global fullscreen\n");
888 if (parsed_num == -1) {
889 LOG(
"Could not parse initial part of \"%s\" as a number.\n", which);
890 yerror(
"Could not parse number \"%s\"", which);
896 child->
num == parsed_num);
899 LOG(
"There is no workspace with number %ld, creating a new one.\n", parsed_num);
902 cmd_output->needs_tree_render =
true;
909 cmd_output->needs_tree_render =
true;
920 LOG(
"Cannot switch workspace while in global fullscreen\n");
927 cmd_output->needs_tree_render =
true;
937 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
939 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
940 LOG(
"You cannot switch to the i3-internal workspaces (\"%s\").\n", name);
946 LOG(
"Cannot switch workspace while in global fullscreen\n");
951 DLOG(
"should switch to workspace %s\n", name);
956 cmd_output->needs_tree_render =
true;
969 if (current == NULL) {
975 if (current !=
TAILQ_LAST(&owindows, owindows_head)) {
976 yerror(
"A mark must not be put onto more than one window");
983 if (toggle != NULL) {
989 cmd_output->needs_tree_render =
true;
1008 cmd_output->needs_tree_render =
true;
1018 DLOG(
"mode=%s\n", mode);
1030 DLOG(
"Should move window to output \"%s\".\n", name);
1034 bool had_error =
false;
1039 assert(current_output != NULL);
1042 if (output == NULL) {
1043 ELOG(
"Could not find output \"%s\", skipping.\n", name);
1051 ELOG(
"Could not find a visible workspace on output %p.\n", output);
1059 cmd_output->needs_tree_render =
true;
1068 DLOG(
"moving window to mark \"%s\"\n", mark);
1075 DLOG(
"moving matched window %p / %s to mark \"%s\"\n", current->
con, current->
con->
name, mark);
1079 cmd_output->needs_tree_render =
true;
1090 DLOG(
"floating_mode=%s\n", floating_mode);
1096 if (strcmp(floating_mode,
"toggle") == 0) {
1097 DLOG(
"should toggle mode\n");
1100 DLOG(
"should switch mode to %s\n", floating_mode);
1101 if (strcmp(floating_mode,
"enable") == 0) {
1109 cmd_output->needs_tree_render =
true;
1119 DLOG(
"should move workspace to output %s\n", name);
1128 ELOG(
"Failed to move workspace to output.\n");
1134 cmd_output->needs_tree_render =
true;
1147 LOG(
"splitting in direction %c\n", direction[0]);
1150 ELOG(
"Cannot split a docked container, skipping.\n");
1155 if (direction[0] ==
't') {
1157 if (current->
con->
type == CT_WORKSPACE) {
1173 cmd_output->needs_tree_render =
true;
1183 if (kill_mode_str == NULL)
1184 kill_mode_str =
"window";
1186 DLOG(
"kill_mode=%s\n", kill_mode_str);
1189 if (strcmp(kill_mode_str,
"window") == 0)
1191 else if (strcmp(kill_mode_str,
"client") == 0)
1194 ELOG(
"BUG: called with kill_mode=%s\n", kill_mode_str);
1206 cmd_output->needs_tree_render =
true;
1216 bool no_startup_id = (nosn != NULL);
1218 DLOG(
"should execute %s, no_startup_id = %d\n", command, no_startup_id);
1230 DLOG(
"direction = *%s*\n", direction);
1232 if (strcmp(direction,
"left") == 0)
1234 else if (strcmp(direction,
"right") == 0)
1236 else if (strcmp(direction,
"up") == 0)
1238 else if (strcmp(direction,
"down") == 0)
1241 ELOG(
"Invalid focus direction (%s)\n", direction);
1246 cmd_output->needs_tree_render =
true;
1256 DLOG(
"window_mode = %s\n", window_mode);
1260 if (strcmp(window_mode,
"mode_toggle") == 0) {
1262 window_mode =
"tiling";
1264 window_mode =
"floating";
1268 if ((strcmp(window_mode,
"floating") == 0 && current->
type != CT_FLOATING_CON) ||
1269 (strcmp(window_mode,
"tiling") == 0 && current->
type == CT_FLOATING_CON))
1277 cmd_output->needs_tree_render =
true;
1287 DLOG(
"level = %s\n", level);
1288 bool success =
false;
1292 if (strcmp(level,
"parent") == 0) {
1297 ELOG(
"'focus parent': Currently in fullscreen, not going up\n");
1305 cmd_output->needs_tree_render = success;
1318 ELOG(
"You have to specify which window/container should be focused.\n");
1319 ELOG(
"Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
1321 yerror(
"You have to specify which window/container should be focused");
1338 LOG(
"Cannot change focus while in fullscreen mode (fullscreen rules).\n");
1344 if (ws == __i3_scratch) {
1371 LOG(
"focusing %p / %s\n", current->
con, current->
con->
name);
1377 LOG(
"WARNING: Your criteria for the focus command matches %d containers, "
1378 "while only exactly one container can be focused at a time.\n",
1381 cmd_output->needs_tree_render =
true;
1392 DLOG(
"%s fullscreen, mode = %s\n", action, fullscreen_mode);
1399 if (strcmp(action,
"toggle") == 0) {
1401 }
else if (strcmp(action,
"enable") == 0) {
1403 }
else if (strcmp(action,
"disable") == 0) {
1408 cmd_output->needs_tree_render =
true;
1418 DLOG(
"%s sticky on window\n", action);
1424 ELOG(
"only containers holding a window can be made sticky, skipping con = %p\n", current->
con);
1427 DLOG(
"setting sticky for container = %p / %s\n", current->
con, current->
con->
name);
1429 bool sticky =
false;
1430 if (strcmp(action,
"enable") == 0)
1432 else if (strcmp(action,
"disable") == 0)
1434 else if (strcmp(action,
"toggle") == 0)
1447 cmd_output->needs_tree_render =
true;
1462 DLOG(
"moving in direction %s, px %ld\n", direction, move_px);
1464 DLOG(
"floating move with %ld pixels\n", move_px);
1466 if (strcmp(direction,
"left") == 0) {
1467 newrect.
x -= move_px;
1468 }
else if (strcmp(direction,
"right") == 0) {
1469 newrect.
x += move_px;
1470 }
else if (strcmp(direction,
"up") == 0) {
1471 newrect.
y -= move_px;
1472 }
else if (strcmp(direction,
"down") == 0) {
1473 newrect.
y += move_px;
1478 cmd_output->needs_tree_render =
true;
1483 if (
focused != initially_focused)
1497 if (strcmp(layout_str,
"stacking") == 0)
1498 layout_str =
"stacked";
1501 if (strcmp(layout_str,
"default") == 0)
1503 else if (strcmp(layout_str,
"stacked") == 0)
1505 else if (strcmp(layout_str,
"tabbed") == 0)
1507 else if (strcmp(layout_str,
"splitv") == 0)
1509 else if (strcmp(layout_str,
"splith") == 0)
1512 ELOG(
"Unknown layout \"%s\", this is a mismatch between code and parser spec.\n", layout_str);
1516 DLOG(
"changing layout to %s (%d)\n", layout_str, layout);
1521 ELOG(
"cannot change layout of a docked container, skipping it.\n");
1529 cmd_output->needs_tree_render =
true;
1541 if (toggle_mode == NULL)
1542 toggle_mode =
"default";
1544 DLOG(
"toggling layout (mode = %s)\n", toggle_mode);
1556 cmd_output->needs_tree_render =
true;
1566 LOG(
"Exiting due to user command.\n");
1567 #ifdef I3_ASAN_ENABLED
1568 __lsan_do_leak_check();
1572 xcb_disconnect(
conn);
1602 LOG(
"restarting i3\n");
1619 LOG(
"opening new container\n");
1628 y(integer, (
long int)con);
1631 cmd_output->needs_tree_render =
true;
1641 DLOG(
"name = %s\n", name);
1646 Output *current_output = NULL;
1651 assert(current_output != NULL);
1656 LOG(
"No such output found.\n");
1671 cmd_output->needs_tree_render =
true;
1681 bool has_error =
false;
1688 ELOG(
"Cannot change position. The window/container is not floating\n");
1691 yerror(
"Cannot change position of a window/container because it is not floating.");
1698 if (strcmp(method,
"absolute") == 0) {
1702 DLOG(
"moving to absolute position %ld %ld\n", x, y);
1704 cmd_output->needs_tree_render =
true;
1707 if (strcmp(method,
"position") == 0) {
1710 DLOG(
"moving to position %ld %ld\n", x, y);
1728 bool has_error =
false;
1734 if (floating_con == NULL) {
1735 ELOG(
"con %p / %s is not floating, cannot move it to the center.\n",
1739 yerror(
"Cannot change position of a window/container because it is not floating.");
1746 if (strcmp(method,
"absolute") == 0) {
1747 DLOG(
"moving to absolute center\n");
1751 cmd_output->needs_tree_render =
true;
1754 if (strcmp(method,
"position") == 0) {
1755 DLOG(
"moving to center\n");
1758 cmd_output->needs_tree_render =
true;
1777 if (floating_con == NULL) {
1778 DLOG(
"con %p / %s is not floating, cannot move it to the mouse position.\n",
1783 DLOG(
"moving floating container %p / %s to cursor position\n", floating_con, floating_con->
name);
1787 cmd_output->needs_tree_render =
true;
1796 DLOG(
"should move window to scratchpad\n");
1806 cmd_output->needs_tree_render =
true;
1816 DLOG(
"should show scratchpad window\n");
1828 cmd_output->needs_tree_render =
true;
1838 DLOG(
"setting title_format to \"%s\"\n", format);
1843 DLOG(
"setting title_format for %p / %s\n", current->
con, current->
con->
name);
1848 if (strcasecmp(format,
"%title") != 0) {
1872 cmd_output->needs_tree_render =
true;
1881 if (strncasecmp(new_name,
"__", strlen(
"__")) == 0) {
1882 LOG(
"Cannot rename workspace to \"%s\": names starting with __ are i3-internal.\n", new_name);
1887 LOG(
"Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name);
1889 LOG(
"Renaming current workspace to \"%s\"\n", new_name);
1892 Con *output, *workspace = NULL;
1896 !strcasecmp(child->name, old_name));
1899 old_name = workspace->
name;
1903 yerror(
"Old workspace \"%s\" not found", old_name);
1907 Con *check_dest = NULL;
1910 !strcasecmp(child->name, new_name));
1914 if (check_dest != NULL && check_dest != workspace) {
1915 yerror(
"New workspace \"%s\" already exists", new_name);
1921 char *old_name_copy =
sstrdup(old_name);
1926 LOG(
"num = %d\n", workspace->
num);
1937 if (assignment->
output == NULL)
1945 if (previously_focused)
1954 cmd_output->needs_tree_render =
true;
1963 free(old_name_copy);
1972 bool toggle =
false;
1973 if (strcmp(bar_mode,
"dock") == 0)
1975 else if (strcmp(bar_mode,
"hide") == 0)
1977 else if (strcmp(bar_mode,
"invisible") == 0)
1979 else if (strcmp(bar_mode,
"toggle") == 0)
1982 ELOG(
"Unknown bar mode \"%s\", this is a mismatch between code and parser spec.\n", bar_mode);
1986 bool changed_sth =
false;
1989 if (bar_id && strcmp(current->
id, bar_id) != 0)
1993 mode = (current->
mode + 1) % 2;
1995 DLOG(
"Changing bar mode of bar_id '%s' to '%s (%d)'\n", current->
id, bar_mode, mode);
1996 current->
mode = mode;
2003 if (bar_id && !changed_sth) {
2004 DLOG(
"Changing bar mode of bar_id %s failed, bar_id not found.\n", bar_id);
2016 int hidden_state = S_SHOW;
2017 bool toggle =
false;
2018 if (strcmp(bar_hidden_state,
"hide") == 0)
2019 hidden_state = S_HIDE;
2020 else if (strcmp(bar_hidden_state,
"show") == 0)
2021 hidden_state = S_SHOW;
2022 else if (strcmp(bar_hidden_state,
"toggle") == 0)
2025 ELOG(
"Unknown bar state \"%s\", this is a mismatch between code and parser spec.\n", bar_hidden_state);
2029 bool changed_sth =
false;
2032 if (bar_id && strcmp(current->
id, bar_id) != 0)
2038 DLOG(
"Changing bar hidden_state of bar_id '%s' to '%s (%d)'\n", current->
id, bar_hidden_state, hidden_state);
2046 if (bar_id && !changed_sth) {
2047 DLOG(
"Changing bar hidden_state of bar_id %s failed, bar_id not found.\n", bar_id);
2058 void cmd_bar(
I3_CMD,
const char *bar_type,
const char *bar_value,
const char *bar_id) {
2060 if (strcmp(bar_type,
"mode") == 0)
2062 else if (strcmp(bar_type,
"hidden_state") == 0)
2065 ELOG(
"Unknown bar option type \"%s\", this is a mismatch between code and parser spec.\n", bar_type);
2081 if (!strcmp(argument,
"toggle"))
2084 else if (!strcmp(argument,
"on"))
2086 else if (!strcmp(argument,
"off"))
2092 LOG(
"Restarting shm logging...\n");
2100 LOG(
"%s shm logging\n",
shmlog_size > 0 ?
"Enabling" :
"Disabling");
2113 if (!strcmp(argument,
"toggle")) {
2114 LOG(
"%s debug logging\n", logging ?
"Disabling" :
"Enabling");
2116 }
else if (!strcmp(argument,
"on") && !logging) {
2117 LOG(
"Enabling debug logging\n");
2119 }
else if (!strcmp(argument,
"off") && logging) {
2120 LOG(
"Disabling debug logging\n");
static bool cmd_resize_tiling_direction(I3_CMD, Con *current, const char *way, const char *direction, int ppt)
void cmd_mark(I3_CMD, const char *mark, const char *mode, const char *toggle)
Implementation of 'mark [–add|–replace] [–toggle] <mark>'.
void floating_disable(Con *con, bool automatic)
Disables floating mode for the given container by re-attaching the container to its old parent...
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
bool con_fullscreen_permits_focusing(Con *con)
Returns true if changing the focus to con would be allowed considering the fullscreen focus constrain...
enum Con::@22 scratchpad_state
void scratchpad_move(Con *con)
Moves the specified window to the __i3_scratch workspace, making it floating and setting the appropri...
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
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>'.
layout_t
Container layouts.
void tree_next(char way, orientation_t orientation)
Changes focus in the given way (next/previous) and given orientation (horizontal/vertical).
void con_mark(Con *con, const char *mark, mark_mode_t mode)
Assigns a mark to the container.
void floating_enable(Con *con, bool automatic)
Enables floating mode for the given container by detaching it from its parent, creating a new contain...
char * title_format
The format with which the window's name should be displayed.
Con * workspace_next(void)
Returns the next workspace.
#define TAILQ_ENTRY(type)
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
bool match_is_empty(Match *match)
Check if a match is empty.
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 con_disable_fullscreen(Con *con)
Disables fullscreen mode for the given container, if necessary.
void con_focus(Con *con)
Sets input focus to the given container.
Con * tree_open_con(Con *con, i3Window *window)
Opens an empty container in the current container.
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
bool workspace_auto_back_and_forth
Automatic workspace back and forth switching.
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
Con * workspace_prev_on_output(void)
Returns the previous workspace on the same 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>'...
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...
#define TAILQ_EMPTY(head)
Con * output_get_content(Con *output)
Returns the output container below the given output container.
void tree_append_json(Con *con, const char *filename, char **errormsg)
enum Barconfig::@8 mode
Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mo...
void con_unmark(Con *con, const char *name)
void i3_restart(bool forget_layout)
Restart i3 in-place appends -a to argument list to disable autostart.
bool match_matches_window(Match *match, i3Window *window)
Check if a match data structure matches the given window.
void cmd_criteria_match_windows(I3_CMD)
A match specification just finished (the closing square bracket was found), so we filter the list of ...
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.
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 con_close(Con *con, kill_window_t kill_window)
Closes the given container.
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 match_parse_property(Match *match, const char *ctype, const char *cvalue)
Interprets a ctype=cvalue pair and adds it to the given match specification.
#define TAILQ_LAST(head, headname)
void cmd_exec(I3_CMD, const char *nosn, const char *command)
Implementation of 'exec [–no-startup-id] <command>'.
void scratchpad_show(Con *con)
Either shows the top-most scratchpad window (con == NULL) or shows the specified con (if it is scratc...
void match_init(Match *match)
bool get_debug_logging(void)
Checks if debug logging is active.
Stores which workspace (by name or number) goes to which output.
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]'.
#define TAILQ_FOREACH(var, head, field)
enum Barconfig::@9 hidden_state
const int default_shmlog_size
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...
Con * workspace_back_and_forth_get(void)
Returns the previously focused workspace con, or NULL if unavailable.
void match_free(Match *match)
Frees the given match.
struct barconfig_head barconfigs
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
xcb_connection_t * conn
XCB connection and root screen.
void ewmh_update_current_desktop(void)
Updates _NET_CURRENT_DESKTOP with the current desktop number.
void con_toggle_layout(Con *con, const char *toggle_mode)
This function toggles the layout of a given container.
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.
void con_mark_toggle(Con *con, const char *mark, mark_mode_t mode)
Toggles the mark on a container.
#define TAILQ_NEXT(elm, field)
void floating_center(Con *con, Rect rect)
Centers a floating con above the specified rect.
void cmd_floating(I3_CMD, const char *floating_mode)
Implementation of 'floating enable|disable|toggle'.
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 not...
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on...
void cmd_split(I3_CMD, const char *direction)
Implementation of 'split v|h|t|vertical|horizontal|toggle'.
pid_t config_error_nagbar_pid
void cmd_workspace_back_and_forth(I3_CMD)
Implementation of 'workspace back_and_forth'.
void set_debug_logging(const bool _debug_logging)
Set debug logging.
void con_detach(Con *con)
Detaches the given container from its current parent.
#define I3_CMD
The beginning of the prototype for every cmd_ function.
fullscreen_mode_t
Fullscreen modes.
void startup_sequence_rename_workspace(const char *old_name, const char *new_name)
Renames workspaces that are mentioned in the startup sequences.
bool level_up(void)
Moves focus one level up.
void cmd_debuglog(I3_CMD, const char *argument)
void workspace_show(Con *workspace)
Switches to the given workspace.
void kill_nagbar(pid_t *nagbar_pid, bool wait_for_it)
Kills the i3-nagbar process, if *nagbar_pid != -1.
void x_set_i3_atoms(void)
Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH)
void cmd_shmlog(I3_CMD, const char *argument)
void cmd_mode(I3_CMD, const char *mode)
Implementation of 'mode <string>'.
void cmd_focus_window_mode(I3_CMD, const char *window_mode)
Implementation of 'focus tiling|floating|mode_toggle'.
void cmd_move_window_to_mouse(I3_CMD)
Implementation of 'move [window|container] [to] position mouse'.
void cmd_exit(I3_CMD)
Implementation of 'exit'.
#define GREP_FIRST(dest, head, condition)
void cmd_layout_toggle(I3_CMD, const char *toggle_mode)
Implementation of 'layout toggle [all|split]'.
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)
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory...
bool cmd_bar_mode(const char *bar_mode, const char *bar_id)
void cmd_restart(I3_CMD)
Implementation of 'restart'.
Con * con
Pointer to the Con which represents this output.
void cmd_append_layout(I3_CMD, const char *cpath)
Implementation of 'append_layout <path>'.
void cmd_sticky(I3_CMD, const char *action)
Implementation of 'sticky enable|disable|toggle'.
#define TAILQ_REMOVE(head, elm, field)
void ewmh_update_visible_name(xcb_window_t window, const char *name)
Updates _NET_WM_VISIBLE_NAME.
struct ws_assignments_head ws_assignments
void cmd_focus_level(I3_CMD, const char *level)
Implementation of 'focus parent|child'.
static Output * get_output_of_con(Con *con)
#define TAILQ_HEAD(name, type)
void start_application(const char *command, bool no_startup_id)
Starts the given application by passing it through a shell.
void cmd_move_con_to_mark(I3_CMD, const char *mark)
Implementation of 'move [window|container] [to] mark <str>'.
Con * workspace_next_on_output(void)
Returns the next workspace on the same output.
void toggle_floating_mode(Con *con, bool automatic)
Calls floating_enable() for tiling containers and floating_disable() for floating containers...
void cmd_reload(I3_CMD)
Implementation of 'reload'.
void cmd_kill(I3_CMD, const char *kill_mode_str)
Implementation of 'kill [window|client]'.
void cmd_move_direction(I3_CMD, const char *direction, long move_px)
Implementation of 'move <direction> [<pixels> [px]]'.
Stores a rectangle, for example the size of a window, the child window etc.
Holds the status bar configuration (i3bar).
void init_logging(void)
Initializes logging by creating an error logfile in /tmp (or XDG_RUNTIME_DIR, see get_process_filenam...
void ipc_shutdown(void)
Calls shutdown() on each socket and closes it.
void cmd_move_window_to_center(I3_CMD, const char *method)
Implementation of 'move [window|container] [to] [absolute] position center.
void cmd_title_format(I3_CMD, const char *format)
Implementation of 'title_format <format>'.
static Match current_match
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
static void cmd_resize_floating(I3_CMD, const char *way, const char *direction, Con *floating_con, int px)
void cmd_open(I3_CMD)
Implementation of 'open'.
json_content_t json_determine_content(const char *filename)
Con * workspace_prev(void)
Returns the previous workspace.
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
void cmd_focus_direction(I3_CMD, const char *direction)
Implementation of 'focus left|right|up|down'.
orientation_t con_orientation(Con *con)
Returns the orientation of the given container (for stacked containers, vertical orientation is used ...
bool level_down(void)
Moves focus one level down.
void con_enable_fullscreen(Con *con, fullscreen_mode_t fullscreen_mode)
Enables fullscreen mode for the given container, if necessary.
bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction)
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>'.
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
#define yerror(format,...)
Con * con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode)
Returns the first fullscreen node below this node.
pid_t command_error_nagbar_pid
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_move_con_to_output(I3_CMD, const char *name)
Implementation of 'move [window|container] [to] output <str>'.
void switch_mode(const char *new_mode)
Switches the key bindings to the given mode, if the mode exists.
bool con_accepts_window(Con *con)
Returns true if this node accepts a window (if the node swallows windows, it might already have swall...
A 'Con' represents everything from the X11 root window down to a single X11 window.
void restore_open_placeholder_windows(Con *parent)
Open placeholder windows for all children of 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.
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
static bool definitelyGreaterThan(float a, float b, float epsilon)
#define TAILQ_FIRST(head)
#define HANDLE_EMPTY_MATCH
When the command did not include match criteria (!), we use the currently focused container...
void cmd_workspace(I3_CMD, const char *which)
Implementation of 'workspace next|prev|next_on_output|prev_on_output'.
char * resolve_tilde(const char *path)
This function resolves ~ in pathnames.
void cmd_move_con_to_workspace_back_and_forth(I3_CMD)
Implementation of 'move [window|container] [to] workspace back_and_forth'.
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
int logical_px(const int logical)
Convert a logical amount of pixels (e.g.
struct _i3String i3String
Opaque data structure for storing strings.
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]...
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
#define TAILQ_INSERT_TAIL(head, elm, field)
int con_num_children(Con *con)
Returns the number of children of this container.
void render_con(Con *con, bool render_fullscreen)
"Renders" the given container (and its children), meaning that all rects are updated correctly...
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 floating_move_to_pointer(Con *con)
Moves the given floating con to the current pointer position.
border_style_t border_style
bool con_is_docked(Con *con)
Returns true if the container is a docked container.
#define ysuccess(success)
i3String * con_parse_title_format(Con *con)
Returns the window title considering the current title format.
void workspace_show_by_name(const char *num)
Looks up the workspace by name and switches to it.
void cmd_fullscreen(I3_CMD, const char *action, const char *fullscreen_mode)
Implementation of 'fullscreen [enable|disable|toggle] [global]'.
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 workspace_back_and_forth(void)
Focuses the previously focused workspace.
bool con_has_children(Con *con)
Returns true if this node has regular or floating children.
long ws_name_to_number(const char *name)
Parses the workspace name as a number.
void update_shmlog_atom()
Set up the SHMLOG_PATH atom.
void floating_check_size(Con *floating_con)
Called when a floating window is created or resized.
void cmd_focus(I3_CMD)
Implementation of 'focus'.
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 floating_resize(Con *floating_con, int x, int y)
Sets size of the CT_FLOATING_CON to specified dimensions.
void cmd_unmark(I3_CMD, const char *mark)
Implementation of 'unmark [mark]'.
Output * get_output_by_name(const char *name)
Returns the output with the given name if it is active (!) or NULL.
struct all_cons_head all_cons
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>]'...
enum Window::@13 dock
Whether the window says it is a dock window.
An Output is a physical output on your graphics driver.
bool workspace_move_to_output(Con *ws, const char *name)
Move the given workspace to the specified output.
bool con_is_floating(Con *con)
Returns true if the node is floating.
void cmd_move_workspace_to_output(I3_CMD, const char *name)
Implementation of 'move workspace to [output] <str>'.
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.
bool con_move_to_mark(Con *con, const char *mark)
Moves the given container to the given mark.
void update_barconfig()
Sends the current bar configuration as an event to all barconfig_update listeners.
static Con * maybe_auto_back_and_forth_workspace(Con *workspace)
void cmd_layout(I3_CMD, const char *layout_str)
Implementation of 'layout default|stacked|stacking|tabbed|splitv|splith'.
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 purge_zerobyte_logfile(void)
Deletes the unused log files.
void ewmh_update_desktop_names(void)
Updates _NET_DESKTOP_NAMES: "The names of all virtual desktops.
bool cmd_bar_hidden_state(const char *bar_hidden_state, const char *bar_id)
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 cmd_nop(I3_CMD, const char *comment)
Implementation of 'nop <comment>'.
char * id
Automatically generated ID for this bar config.
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 tree_split(Con *con, orientation_t orientation)
Splits (horizontally or vertically) the given container by creating a new container which contains th...
void con_set_layout(Con *con, layout_t layout)
This function changes the layout of a given container.
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 cmd_move_scratchpad(I3_CMD)
Implementation of 'move scratchpad'.
void cmd_resize_set(I3_CMD, long cwidth, long cheight)
Implementation of 'resize set <px> [px] <px> [px]'.