21 #define y(x, ...) (cmd_output->json_gen != NULL ? yajl_gen_##x(cmd_output->json_gen, ##__VA_ARGS__) : 0) 22 #define ystr(str) (cmd_output->json_gen != NULL ? yajl_gen_string(cmd_output->json_gen, (unsigned char *)str, strlen(str)) : 0) 23 #define ysuccess(success) \ 25 if (cmd_output->json_gen != NULL) { \ 32 #define yerror(format, ...) \ 34 if (cmd_output->json_gen != NULL) { \ 36 sasprintf(&message, format, ##__VA_ARGS__); \ 49 #define HANDLE_INVALID_MATCH \ 51 if (current_match->error != NULL) { \ 52 yerror("Invalid match: %s", current_match->error); \ 62 #define HANDLE_EMPTY_MATCH \ 64 HANDLE_INVALID_MATCH; \ 66 if (match_is_empty(current_match)) { \ 67 while (!TAILQ_EMPTY(&owindows)) { \ 68 owindow *ow = TAILQ_FIRST(&owindows); \ 69 TAILQ_REMOVE(&owindows, ow, owindows); \ 72 owindow *ow = smalloc(sizeof(owindow)); \ 74 TAILQ_INIT(&owindows); \ 75 TAILQ_INSERT_TAIL(&owindows, ow, owindows); \ 90 if (strcmp(ws->
name, name) != 0)
93 DLOG(
"This workspace is already focused.\n");
113 if (current == workspace) {
116 DLOG(
"Substituting workspace with back_and_forth, as it is focused.\n");
178 DLOG(
"match specification finished, matching...\n");
181 struct owindows_head old =
owindows;
190 DLOG(
"checking if con %p / %s matches\n", current->
con, current->
con->
name);
194 bool accept_match =
false;
200 DLOG(
"con_id matched.\n");
202 DLOG(
"con_id does not match.\n");
210 bool matched_by_mark =
false;
217 DLOG(
"match by mark\n");
218 matched_by_mark =
true;
222 if (!matched_by_mark) {
223 DLOG(
"mark does not match.\n");
231 DLOG(
"matches window!\n");
234 DLOG(
"doesn't match\n");
270 #define CHECK_MOVE_CON_TO_WORKSPACE \ 272 HANDLE_EMPTY_MATCH; \ 273 if (TAILQ_EMPTY(&owindows)) { \ 274 yerror("Nothing to move: specified criteria don't match any window"); \ 277 bool found = false; \ 278 owindow *current = TAILQ_FIRST(&owindows); \ 280 owindow *next = TAILQ_NEXT(current, owindows); \ 282 if (current->con->type == CT_WORKSPACE && !con_has_children(current->con)) { \ 283 TAILQ_REMOVE(&owindows, current, owindows); \ 291 yerror("Nothing to move: workspace empty"); \ 303 DLOG(
"which=%s\n", which);
309 if (strcmp(which,
"next") == 0)
311 else if (strcmp(which,
"prev") == 0)
313 else if (strcmp(which,
"next_on_output") == 0)
315 else if (strcmp(which,
"prev_on_output") == 0)
317 else if (strcmp(which,
"current") == 0)
320 yerror(
"BUG: called with which=%s", which);
326 cmd_output->needs_tree_render =
true;
338 yerror(
"No workspace was previously active.");
346 cmd_output->needs_tree_render =
true;
356 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
357 yerror(
"You cannot move containers to i3-internal workspaces (\"%s\").", name);
363 LOG(
"should move window to workspace %s\n", name);
367 if (no_auto_back_and_forth == NULL) {
373 cmd_output->needs_tree_render =
true;
385 LOG(
"should move window to workspace %s\n", which);
388 if (parsed_num == -1) {
389 LOG(
"Could not parse initial part of \"%s\" as a number.\n", which);
390 yerror(
"Could not parse number \"%s\"", which);
399 if (no_auto_back_and_forth == NULL) {
405 cmd_output->needs_tree_render =
true;
415 if (strcmp(str,
"left") == 0) {
417 }
else if (strcmp(str,
"right") == 0) {
419 }
else if (strcmp(str,
"up") == 0) {
421 }
else if (strcmp(str,
"down") == 0) {
424 ELOG(
"Invalid direction. This is a parser bug.\n");
434 if (strcmp(direction_str,
"height") == 0) {
436 }
else if (strcmp(direction_str,
"width") == 0) {
447 if (window != NULL) {
448 if (orientation ==
VERT) {
463 if (orientation ==
VERT) {
472 if (memcmp(&old_rect, &(floating_con->
rect),
sizeof(
Rect)) == 0) {
476 if (direction ==
D_UP) {
478 }
else if (direction ==
D_LEFT) {
490 Con *first = current;
495 yerror(
"No second container found in this direction.");
508 LOG(
"width/height resize\n");
514 if (search_result ==
false) {
515 yerror(
"Failed to find appropriate tiling containers for resize operation");
521 LOG(
"ins. %d children\n", children);
522 double percentage = 1.0 / children;
523 LOG(
"default percentage = %f\n", percentage);
528 LOG(
"child->percent = %f (child %p)\n", child->
percent, child);
533 double new_current_percent;
534 double subtract_percent;
536 new_current_percent = current->
percent + ppt;
540 new_current_percent = current->
percent + ppt;
542 subtract_percent = ppt / (children - 1);
544 yerror(
"Not resizing, container would end with less than 1px");
548 LOG(
"new_current_percent = %f\n", new_current_percent);
549 LOG(
"subtract_percent = %f\n", subtract_percent);
551 if (subtract_percent >= 0.0) {
553 if (child == current) {
557 yerror(
"Not resizing, already at minimum size (child %p would end up with a size of %.f", child, child->
percent - subtract_percent);
563 current->
percent = new_current_percent;
564 LOG(
"current->percent after = %f\n", current->
percent);
567 if (child == current)
569 child->
percent -= subtract_percent;
570 LOG(
"child->percent after (%p) = %f\n", child, child->
percent);
580 void cmd_resize(
I3_CMD,
const char *way,
const char *direction,
long resize_px,
long resize_ppt) {
581 DLOG(
"resizing in way %s, direction %s, px %ld or ppt %ld\n", way, direction, resize_px, resize_ppt);
582 if (strcmp(way,
"shrink") == 0) {
593 DLOG(
"This is a dock window. Not resizing (con = %p)\n)", current->
con);
601 if (strcmp(direction,
"width") == 0 ||
602 strcmp(direction,
"height") == 0) {
603 const double ppt = (double)resize_ppt / 100.0;
605 current->
con, direction,
612 current->
con, direction,
613 resize_px, resize_ppt)) {
621 cmd_output->needs_tree_render =
true;
629 if (resize_orientation ==
HORIZ) {
630 search_direction =
D_LEFT;
633 search_direction =
D_DOWN;
645 ppt = (double)target_size / 100.0 - target->
percent;
652 target, mode, px, ppt);
660 DLOG(
"resizing to %ld %s x %ld %s\n", cwidth, mode_width, cheight, mode_height);
661 if (cwidth < 0 || cheight < 0) {
662 yerror(
"Dimensions cannot be negative.");
676 }
else if (mode_width && strcmp(mode_width,
"ppt") == 0) {
677 cwidth = output->
rect.
width * ((double)cwidth / 100.0);
681 }
else if (mode_height && strcmp(mode_height,
"ppt") == 0) {
682 cheight = output->
rect.
height * ((double)cheight / 100.0);
687 DLOG(
"This is a dock window. Not resizing (con = %p)\n)", current->
con);
692 bool is_ppt = mode_width && strcmp(mode_width,
"ppt") == 0;
694 HORIZ, is_ppt, cwidth);
697 bool is_ppt = mode_height && strcmp(mode_height,
"ppt") == 0;
699 VERT, is_ppt, cheight);
704 cmd_output->needs_tree_render =
true;
712 if (border_width >= 0) {
733 DLOG(
"border style should be changed to %s with border width %ld\n", border_style_str, border_width);
742 if (strcmp(border_style_str,
"toggle") == 0) {
744 }
else if (strcmp(border_style_str,
"normal") == 0) {
746 }
else if (strcmp(border_style_str,
"pixel") == 0) {
748 }
else if (strcmp(border_style_str,
"none") == 0) {
751 yerror(
"BUG: called with border_style=%s", border_style_str);
759 cmd_output->needs_tree_render =
true;
768 LOG(
"-------------------------------------------------\n");
769 LOG(
" NOP: %s\n", comment);
770 LOG(
"-------------------------------------------------\n");
779 LOG(
"Appending layout \"%s\"\n", cpath);
786 if ((len =
slurp(path, &buf)) < 0) {
787 yerror(
"Could not slurp \"%s\".", path);
793 ELOG(
"Could not parse \"%s\" as JSON, not loading.\n", path);
794 yerror(
"Could not parse \"%s\" as JSON.", path);
799 LOG(
"JSON content = %d\n", content);
801 ELOG(
"Could not determine the contents of \"%s\", not loading.\n", path);
802 yerror(
"Could not determine the contents of \"%s\".", path);
817 DLOG(
"Appending to parent=%p instead of focused=%p\n", parent,
focused);
818 char *errormsg = NULL;
820 if (errormsg != NULL) {
844 cmd_output->needs_tree_render =
true;
857 DLOG(
"which=%s\n", which);
860 yerror(
"Cannot switch workspace while in global fullscreen");
864 if (strcmp(which,
"next") == 0)
866 else if (strcmp(which,
"prev") == 0)
868 else if (strcmp(which,
"next_on_output") == 0)
870 else if (strcmp(which,
"prev_on_output") == 0)
873 yerror(
"BUG: called with which=%s", which);
879 cmd_output->needs_tree_render =
true;
889 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
892 yerror(
"Cannot switch workspace while in global fullscreen");
897 if (parsed_num == -1) {
898 yerror(
"Could not parse initial part of \"%s\" as a number.", which);
904 LOG(
"There is no workspace with number %ld, creating a new one.\n", parsed_num);
907 cmd_output->needs_tree_render =
true;
916 cmd_output->needs_tree_render =
true;
927 yerror(
"Cannot switch workspace while in global fullscreen");
933 cmd_output->needs_tree_render =
true;
943 const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
945 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
946 yerror(
"You cannot switch to the i3-internal workspaces (\"%s\").", name);
951 yerror(
"Cannot switch workspace while in global fullscreen");
955 DLOG(
"should switch to workspace %s\n", name);
962 cmd_output->needs_tree_render =
true;
975 if (current == NULL) {
976 yerror(
"Given criteria don't match a window");
982 yerror(
"A mark must not be put onto more than one window");
989 if (toggle != NULL) {
995 cmd_output->needs_tree_render =
true;
1014 cmd_output->needs_tree_render =
true;
1024 DLOG(
"mode=%s\n", mode);
1036 DLOG(
"Should move window to output \"%s\".\n", name);
1040 bool had_error =
false;
1047 cmd_output->needs_tree_render =
true;
1056 DLOG(
"moving window to mark \"%s\"\n", mark);
1063 DLOG(
"moving matched window %p / %s to mark \"%s\"\n", current->
con, current->
con->
name, mark);
1067 cmd_output->needs_tree_render =
true;
1078 DLOG(
"floating_mode=%s\n", floating_mode);
1084 if (strcmp(floating_mode,
"toggle") == 0) {
1085 DLOG(
"should toggle mode\n");
1088 DLOG(
"should switch mode to %s\n", floating_mode);
1089 if (strcmp(floating_mode,
"enable") == 0) {
1097 cmd_output->needs_tree_render =
true;
1107 DLOG(
"should move workspace to output %s\n", name);
1120 if (!target_output) {
1121 yerror(
"Could not get output from string \"%s\"", name);
1128 cmd_output->needs_tree_render =
true;
1140 LOG(
"splitting in direction %c\n", direction[0]);
1143 ELOG(
"Cannot split a docked container, skipping.\n");
1148 if (direction[0] ==
't') {
1150 if (current->
con->
type == CT_WORKSPACE) {
1166 cmd_output->needs_tree_render =
true;
1176 if (kill_mode_str == NULL)
1177 kill_mode_str =
"window";
1179 DLOG(
"kill_mode=%s\n", kill_mode_str);
1182 if (strcmp(kill_mode_str,
"window") == 0)
1184 else if (strcmp(kill_mode_str,
"client") == 0)
1187 yerror(
"BUG: called with kill_mode=%s", kill_mode_str);
1198 cmd_output->needs_tree_render =
true;
1208 bool no_startup_id = (nosn != NULL);
1210 DLOG(
"should execute %s, no_startup_id = %d\n", command, no_startup_id);
1236 cmd_output->needs_tree_render =
true;
1260 DLOG(
"window_mode = %s\n", window_mode);
1262 bool to_floating =
false;
1263 if (strcmp(window_mode,
"mode_toggle") == 0) {
1265 }
else if (strcmp(window_mode,
"floating") == 0) {
1267 }
else if (strcmp(window_mode,
"tiling") == 0) {
1268 to_floating =
false;
1273 bool success =
false;
1275 if ((to_floating && current->
type != CT_FLOATING_CON) ||
1276 (!to_floating && current->
type == CT_FLOATING_CON))
1285 cmd_output->needs_tree_render =
true;
1288 yerror(
"Failed to find a %s container in workspace.", to_floating ?
"floating" :
"tiling");
1297 DLOG(
"level = %s\n", level);
1298 bool success =
false;
1302 if (strcmp(level,
"parent") == 0) {
1307 ELOG(
"'focus parent': Currently in fullscreen, not going up\n");
1315 cmd_output->needs_tree_render = success;
1328 ELOG(
"You have to specify which window/container should be focused.\n");
1329 ELOG(
"Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
1331 yerror(
"You have to specify which window/container should be focused");
1347 if (ws == __i3_scratch) {
1374 LOG(
"focusing %p / %s\n", current->
con, current->
con->
name);
1380 LOG(
"WARNING: Your criteria for the focus command matches %d containers, " 1381 "while only exactly one container can be focused at a time.\n",
1384 cmd_output->needs_tree_render =
true;
1395 DLOG(
"%s fullscreen, mode = %s\n", action, fullscreen_mode);
1402 if (strcmp(action,
"toggle") == 0) {
1404 }
else if (strcmp(action,
"enable") == 0) {
1406 }
else if (strcmp(action,
"disable") == 0) {
1411 cmd_output->needs_tree_render =
true;
1421 DLOG(
"%s sticky on window\n", action);
1427 ELOG(
"only containers holding a window can be made sticky, skipping con = %p\n", current->
con);
1430 DLOG(
"setting sticky for container = %p / %s\n", current->
con, current->
con->
name);
1432 bool sticky =
false;
1433 if (strcmp(action,
"enable") == 0)
1435 else if (strcmp(action,
"disable") == 0)
1437 else if (strcmp(action,
"toggle") == 0)
1450 cmd_output->needs_tree_render =
true;
1466 DLOG(
"moving in direction %s, px %ld\n", direction_str, move_px);
1468 DLOG(
"floating move with %ld pixels\n", move_px);
1471 switch (direction) {
1473 newrect.
x -= move_px;
1476 newrect.
x += move_px;
1479 newrect.
y -= move_px;
1482 newrect.
y += move_px;
1489 cmd_output->needs_tree_render =
true;
1494 if (
focused != initially_focused)
1510 yerror(
"Unknown layout \"%s\", this is a mismatch between code and parser spec.", layout_str);
1514 DLOG(
"changing layout to %s (%d)\n", layout_str, layout);
1519 ELOG(
"cannot change layout of a docked container, skipping it.\n");
1527 cmd_output->needs_tree_render =
true;
1539 if (toggle_mode == NULL)
1540 toggle_mode =
"default";
1542 DLOG(
"toggling layout (mode = %s)\n", toggle_mode);
1554 cmd_output->needs_tree_render =
true;
1564 LOG(
"Exiting due to user command.\n");
1594 LOG(
"restarting i3\n");
1596 if (cmd_output->client != NULL) {
1597 exempt_fd = cmd_output->client->fd;
1598 LOG(
"Carrying file descriptor %d across restart\n", exempt_fd);
1600 if ((flags = fcntl(exempt_fd, F_GETFD)) < 0 ||
1601 fcntl(exempt_fd, F_SETFD, flags & ~FD_CLOEXEC) < 0) {
1602 ELOG(
"Could not disable FD_CLOEXEC on fd %d\n", exempt_fd);
1606 setenv(
"_I3_RESTART_FD", fdstr, 1);
1623 LOG(
"opening new container\n");
1632 y(integer, (uintptr_t)
con);
1635 cmd_output->needs_tree_render =
true;
1654 yerror(
"Output %s not found.", name);
1662 yerror(
"BUG: No workspace found on output.");
1668 cmd_output->needs_tree_render =
true;
1677 bool has_error =
false;
1684 ELOG(
"Cannot change position. The window/container is not floating\n");
1687 yerror(
"Cannot change position of a window/container because it is not floating.");
1696 DLOG(
"moving to position %ld %ld\n",
x,
y);
1701 yerror(
"Cannot move window/container out of bounds.");
1715 bool has_error =
false;
1721 if (floating_con == NULL) {
1722 ELOG(
"con %p / %s is not floating, cannot move it to the center.\n",
1726 yerror(
"Cannot change position of a window/container because it is not floating.");
1733 if (strcmp(method,
"absolute") == 0) {
1734 DLOG(
"moving to absolute center\n");
1738 cmd_output->needs_tree_render =
true;
1741 if (strcmp(method,
"position") == 0) {
1742 DLOG(
"moving to center\n");
1745 cmd_output->needs_tree_render =
true;
1764 if (floating_con == NULL) {
1765 DLOG(
"con %p / %s is not floating, cannot move it to the mouse position.\n",
1770 DLOG(
"moving floating container %p / %s to cursor position\n", floating_con, floating_con->
name);
1774 cmd_output->needs_tree_render =
true;
1783 DLOG(
"should move window to scratchpad\n");
1793 cmd_output->needs_tree_render =
true;
1803 DLOG(
"should show scratchpad window\n");
1805 bool result =
false;
1816 cmd_output->needs_tree_render =
true;
1829 if (match == NULL) {
1830 yerror(
"No match found for swapping.");
1833 if (match->
con == NULL) {
1834 yerror(
"Match %p has no container.", match);
1839 if (strcmp(mode,
"id") == 0) {
1842 yerror(
"Failed to parse %s into a window id.", arg);
1847 }
else if (strcmp(mode,
"con_id") == 0) {
1850 yerror(
"Failed to parse %s into a container id.", arg);
1855 }
else if (strcmp(mode,
"mark") == 0) {
1858 yerror(
"Unhandled swap mode \"%s\". This is a bug.", mode);
1863 yerror(
"Could not find container for %s = %s", mode, arg);
1868 LOG(
"More than one container matched the swap command, only using the first one.");
1871 DLOG(
"Swapping %p with %p.\n", match->
con,
con);
1874 cmd_output->needs_tree_render =
true;
1884 DLOG(
"setting title_format to \"%s\"\n", format);
1889 DLOG(
"setting title_format for %p / %s\n", current->
con, current->
con->
name);
1894 if (strcasecmp(format,
"%title") != 0) {
1918 cmd_output->needs_tree_render =
true;
1927 if (strncasecmp(new_name,
"__", strlen(
"__")) == 0) {
1928 yerror(
"Cannot rename workspace to \"%s\": names starting with __ are i3-internal.", new_name);
1932 LOG(
"Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name);
1934 LOG(
"Renaming current workspace to \"%s\"\n", new_name);
1942 old_name = workspace->
name;
1946 yerror(
"Old workspace \"%s\" not found", old_name);
1954 if (check_dest != NULL && check_dest != workspace) {
1955 yerror(
"New workspace \"%s\" already exists", new_name);
1961 char *old_name_copy =
sstrdup(old_name);
1966 LOG(
"num = %d\n", workspace->
num);
1979 if (assignment->
output == NULL)
1986 if (!target_output) {
1987 LOG(
"Could not get output named \"%s\"\n", assignment->
output);
1998 bool can_restore_focus = previously_focused != NULL;
2004 if (previously_focused_content) {
2005 Con *workspace = NULL;
2006 GREP_FIRST(workspace, previously_focused_content, child == previously_focused);
2007 can_restore_focus &= (workspace != NULL);
2010 if (can_restore_focus) {
2016 cmd_output->needs_tree_render =
true;
2022 free(old_name_copy);
2031 bool toggle =
false;
2032 if (strcmp(bar_mode,
"dock") == 0)
2034 else if (strcmp(bar_mode,
"hide") == 0)
2036 else if (strcmp(bar_mode,
"invisible") == 0)
2038 else if (strcmp(bar_mode,
"toggle") == 0)
2041 ELOG(
"Unknown bar mode \"%s\", this is a mismatch between code and parser spec.\n", bar_mode);
2045 bool changed_sth =
false;
2048 if (bar_id && strcmp(current->
id, bar_id) != 0)
2052 mode = (current->
mode + 1) % 2;
2054 DLOG(
"Changing bar mode of bar_id '%s' to '%s (%d)'\n", current->
id, bar_mode, mode);
2055 current->
mode = mode;
2062 if (bar_id && !changed_sth) {
2063 DLOG(
"Changing bar mode of bar_id %s failed, bar_id not found.\n", bar_id);
2075 int hidden_state = S_SHOW;
2076 bool toggle =
false;
2077 if (strcmp(bar_hidden_state,
"hide") == 0)
2078 hidden_state = S_HIDE;
2079 else if (strcmp(bar_hidden_state,
"show") == 0)
2080 hidden_state = S_SHOW;
2081 else if (strcmp(bar_hidden_state,
"toggle") == 0)
2084 ELOG(
"Unknown bar state \"%s\", this is a mismatch between code and parser spec.\n", bar_hidden_state);
2088 bool changed_sth =
false;
2091 if (bar_id && strcmp(current->
id, bar_id) != 0)
2097 DLOG(
"Changing bar hidden_state of bar_id '%s' to '%s (%d)'\n", current->
id, bar_hidden_state, hidden_state);
2105 if (bar_id && !changed_sth) {
2106 DLOG(
"Changing bar hidden_state of bar_id %s failed, bar_id not found.\n", bar_id);
2117 void cmd_bar(
I3_CMD,
const char *bar_type,
const char *bar_value,
const char *bar_id) {
2119 if (strcmp(bar_type,
"mode") == 0)
2121 else if (strcmp(bar_type,
"hidden_state") == 0)
2124 ELOG(
"Unknown bar option type \"%s\", this is a mismatch between code and parser spec.\n", bar_type);
2140 if (!strcmp(argument,
"toggle"))
2143 else if (!strcmp(argument,
"on"))
2145 else if (!strcmp(argument,
"off"))
2150 yerror(
"Failed to parse %s into a shmlog size.", argument);
2156 LOG(
"Restarting shm logging...\n");
2161 LOG(
"%s shm logging\n",
shmlog_size > 0 ?
"Enabling" :
"Disabling");
2173 if (!strcmp(argument,
"toggle")) {
2174 LOG(
"%s debug logging\n", logging ?
"Disabling" :
"Enabling");
2176 }
else if (!strcmp(argument,
"on") && !logging) {
2177 LOG(
"Enabling debug logging\n");
2179 }
else if (!strcmp(argument,
"off") && logging) {
2180 LOG(
"Disabling debug logging\n");
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
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 floating_check_size(Con *floating_con, bool prefer_height)
Called when a floating window is created or resized.
void cmd_mark(I3_CMD, const char *mark, const char *mode, const char *toggle)
Implementation of 'mark [–add|–replace] [–toggle] <mark>'.
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.
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
int logical_px(const int logical)
Convert a logical amount of pixels (e.g.
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
char * id
Automatically generated ID for this bar config.
#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.
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 workspace_auto_back_and_forth
Automatic workspace back and forth switching.
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.
void match_free(Match *match)
Frees the given match.
fullscreen_mode_t
Fullscreen modes.
Holds an intermediate represenation of the result of a call to any command.
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 ...
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.
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
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 load_configuration(const char *override_configpath, config_load_t load_type)
(Re-)loads the configuration file (sets useful defaults before).
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.
Stores a rectangle, for example the size of a window, the child window etc.
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
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
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]'.
enum Barconfig::@10 hidden_state
void con_mark(Con *con, const char *mark, mark_mode_t mode)
Assigns a mark to the container.
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]'.
Con * con
Pointer to the Con which represents this output.
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'.
void render_con(Con *con)
"Renders" the given container (and its children), meaning that all rects are updated correctly...
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.
enum Con::@22 scratchpad_state
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 n...
A 'Con' represents everything from the X11 root window down to a single X11 window.
#define TAILQ_FIRST(head)
void cmd_scratchpad_show(I3_CMD)
Implementation of 'scratchpad show'.
int sasprintf(char **strp, const char *fmt,...)
Safe-wrapper around asprintf which exits if it returns -1 (meaning that there is no more memory avail...
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_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.
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'.
int default_floating_border_width
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...
json_content_t json_determine_content(const char *buf, const size_t len)
#define TAILQ_ENTRY(type)
struct pending_marks * marks
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.
Stores which workspace (by name or number) goes to which output.
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
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 ipc_shutdown(shutdown_reason_t reason, int exempt_fd)
Calls shutdown() on each socket and closes it.
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'.
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...
border_style_t default_floating_border
The default border style for new floating windows.
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 floating_resize(Con *floating_con, uint32_t x, uint32_t y)
Sets size of the CT_FLOATING_CON to specified dimensions.
void cmd_move_window_to_center(I3_CMD, const char *method)
Implementation of 'move [window|container] [to] [absolute] position center.
border_style_t border_style
An Output is a physical output on your graphics driver.
char * title_format
The format with which the window's name should be displayed.
void ewmh_update_desktop_properties(void)
Updates all the EWMH desktop properties.
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)
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 workspace_move_to_output(Con *ws, Output *output)
Move the given workspace to the specified output.
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.
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.
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.
#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...
uint32_t con_rect_size_in_orientation(Con *con)
Returns given container's rect size depending on its orientation.
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.
enum Barconfig::@9 mode
Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mo...
#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.
border_style_t default_border
The default border style for new windows.
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...
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.
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_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)
Holds the status bar configuration (i3bar).
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'.
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)
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory...
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>'.