3 * vim:ts=4:sw=4:expandtab
5 * i3 - an improved dynamic tiling window manager
6 * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
8 * cmdparse.y: the parser for commands you send to i3 (or bind on keys)
11 #include <sys/types.h>
19 /** When the command did not include match criteria (!), we use the currently
20 * focused command. Do not confuse this case with a command which included
21 * criteria but which did not match any windows. This macro has to be called in
24 #define HANDLE_EMPTY_MATCH do { \
25 if (match_is_empty(¤t_match)) { \
26 owindow *ow = smalloc(sizeof(owindow)); \
28 TAILQ_INIT(&owindows); \
29 TAILQ_INSERT_TAIL(&owindows, ow, owindows); \
33 typedef struct yy_buffer_state *YY_BUFFER_STATE;
34 extern int cmdyylex(struct context *context);
35 extern int cmdyyparse(void);
36 extern int cmdyylex_destroy(void);
38 YY_BUFFER_STATE cmdyy_scan_string(const char *);
40 static struct context *context;
41 static Match current_match;
44 * Helper data structure for an operation window (window on which the operation
45 * will be performed). Used to build the TAILQ owindows.
48 typedef struct owindow {
50 TAILQ_ENTRY(owindow) owindows;
52 static TAILQ_HEAD(owindows_head, owindow) owindows;
54 /* Holds the JSON which will be returned via IPC or NULL for the default return
56 static char *json_output;
58 /* We don’t need yydebug for now, as we got decent error messages using
59 * yyerror(). Should you ever want to extend the parser, it might be handy
60 * to just comment it in again, so it stays here. */
63 void cmdyyerror(const char *error_message) {
65 ELOG("CMD: %s\n", error_message);
66 ELOG("CMD: in command:\n");
67 ELOG("CMD: %s\n", context->line_copy);
69 for (int c = 1; c <= context->last_column; c++)
70 if (c >= context->first_column)
75 context->compact_error = sstrdup(error_message);
82 char *parse_cmd(const char *new) {
84 LOG("COMMAND: *%s*\n", new);
85 cmdyy_scan_string(new);
87 match_init(¤t_match);
88 context = scalloc(sizeof(struct context));
89 context->filename = "cmd";
90 if (cmdyyparse() != 0) {
91 fprintf(stderr, "Could not parse command\n");
92 sasprintf(&json_output, "{\"success\":false, \"error\":\"%s at position %d\"}",
93 context->compact_error, context->first_column);
94 FREE(context->line_copy);
95 FREE(context->compact_error);
99 printf("done, json output = %s\n", json_output);
102 FREE(context->line_copy);
103 FREE(context->compact_error);
109 * Returns true if a is definitely greater than b (using the given epsilon)
112 bool definitelyGreaterThan(float a, float b, float epsilon) {
113 return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
119 %lex-param { struct context *context }
127 %token TOK_EXEC "exec"
128 %token TOK_EXIT "exit"
129 %token TOK_RELOAD "reload"
130 %token TOK_RESTART "restart"
131 %token TOK_KILL "kill"
132 %token TOK_WINDOW "window"
133 %token TOK_CLIENT "client"
134 %token TOK_FULLSCREEN "fullscreen"
135 %token TOK_GLOBAL "global"
136 %token TOK_LAYOUT "layout"
137 %token TOK_DEFAULT "default"
138 %token TOK_STACKED "stacked"
139 %token TOK_TABBED "tabbed"
140 %token TOK_BORDER "border"
141 %token TOK_NORMAL "normal"
142 %token TOK_NONE "none"
143 %token TOK_1PIXEL "1pixel"
144 %token TOK_MODE "mode"
145 %token TOK_TILING "tiling"
146 %token TOK_FLOATING "floating"
147 %token TOK_MODE_TOGGLE "mode_toggle"
148 %token TOK_ENABLE "enable"
149 %token TOK_DISABLE "disable"
150 %token TOK_WORKSPACE "workspace"
151 %token TOK_OUTPUT "output"
152 %token TOK_TOGGLE "toggle"
153 %token TOK_FOCUS "focus"
154 %token TOK_MOVE "move"
155 %token TOK_OPEN "open"
156 %token TOK_NEXT "next"
157 %token TOK_PREV "prev"
158 %token TOK_SCRATCHPAD "scratchpad"
159 %token TOK_SHOW "show"
160 %token TOK_SPLIT "split"
161 %token TOK_HORIZONTAL "horizontal"
162 %token TOK_VERTICAL "vertical"
164 %token TOK_DOWN "down"
165 %token TOK_LEFT "left"
166 %token TOK_RIGHT "right"
167 %token TOK_PARENT "parent"
168 %token TOK_CHILD "child"
169 %token TOK_APPEND_LAYOUT "append_layout"
170 %token TOK_MARK "mark"
171 %token TOK_RESIZE "resize"
172 %token TOK_GROW "grow"
173 %token TOK_SHRINK "shrink"
178 %token TOK_BACK_AND_FORTH "back_and_forth"
179 %token TOK_NO_STARTUP_ID "--no-startup-id"
181 %token TOK_CLASS "class"
182 %token TOK_INSTANCE "instance"
183 %token TOK_WINDOW_ROLE "window_role"
185 %token TOK_CON_ID "con_id"
186 %token TOK_TITLE "title"
188 %token <string> STR "<string>"
189 %token <number> NUMBER "<number>"
191 %type <number> direction
192 %type <number> split_direction
193 %type <number> fullscreen_mode
195 %type <number> window_mode
196 %type <number> boolean
197 %type <number> border_style
198 %type <number> layout_mode
199 %type <number> resize_px
200 %type <number> resize_way
201 %type <number> resize_tiling
202 %type <number> optional_kill_mode
203 %type <number> optional_no_startup_id
213 printf("single command completely parsed, dropping state...\n");
214 while (!TAILQ_EMPTY(&owindows)) {
215 current = TAILQ_FIRST(&owindows);
216 TAILQ_REMOVE(&owindows, current, owindows);
219 match_init(¤t_match);
228 | matchstart criteria matchend
230 printf("match parsed\n");
238 match_init(¤t_match);
239 TAILQ_INIT(&owindows);
242 TAILQ_FOREACH(con, &all_cons, all_cons) {
243 owindow *ow = smalloc(sizeof(owindow));
245 TAILQ_INSERT_TAIL(&owindows, ow, owindows);
253 owindow *next, *current;
255 printf("match specification finished, matching...\n");
256 /* copy the old list head to iterate through it and start with a fresh
257 * list which will contain only matching windows */
258 struct owindows_head old = owindows;
259 TAILQ_INIT(&owindows);
260 for (next = TAILQ_FIRST(&old); next != TAILQ_END(&old);) {
261 /* make a copy of the next pointer and advance the pointer to the
262 * next element as we are going to invalidate the element’s
263 * next/prev pointers by calling TAILQ_INSERT_TAIL later */
265 next = TAILQ_NEXT(next, owindows);
267 printf("checking if con %p / %s matches\n", current->con, current->con->name);
268 if (current_match.con_id != NULL) {
269 if (current_match.con_id == current->con) {
270 printf("matches container!\n");
271 TAILQ_INSERT_TAIL(&owindows, current, owindows);
274 } else if (current_match.mark != NULL && current->con->mark != NULL &&
275 regex_matches(current_match.mark, current->con->mark)) {
276 printf("match by mark\n");
277 TAILQ_INSERT_TAIL(&owindows, current, owindows);
279 if (current->con->window == NULL)
281 if (match_matches_window(¤t_match, current->con->window)) {
282 printf("matches window!\n");
283 TAILQ_INSERT_TAIL(&owindows, current, owindows);
285 printf("doesnt match\n");
291 TAILQ_FOREACH(current, &owindows, owindows) {
292 printf("matching: %p / %s\n", current->con, current->con->name);
306 printf("criteria: class = %s\n", $3);
307 current_match.class = regex_new($3);
310 | TOK_INSTANCE '=' STR
312 printf("criteria: instance = %s\n", $3);
313 current_match.instance = regex_new($3);
316 | TOK_WINDOW_ROLE '=' STR
318 printf("criteria: window_role = %s\n", $3);
319 current_match.role = regex_new($3);
324 printf("criteria: id = %s\n", $3);
326 long parsed = strtol($3, &end, 10);
327 if (parsed == LONG_MIN ||
328 parsed == LONG_MAX ||
330 (end && *end != '\0')) {
331 ELOG("Could not parse con id \"%s\"\n", $3);
333 current_match.con_id = (Con*)parsed;
334 printf("id as int = %p\n", current_match.con_id);
339 printf("criteria: window id = %s\n", $3);
341 long parsed = strtol($3, &end, 10);
342 if (parsed == LONG_MIN ||
343 parsed == LONG_MAX ||
345 (end && *end != '\0')) {
346 ELOG("Could not parse window id \"%s\"\n", $3);
348 current_match.id = parsed;
349 printf("window id as int = %d\n", current_match.id);
354 printf("criteria: mark = %s\n", $3);
355 current_match.mark = regex_new($3);
360 printf("criteria: title = %s\n", $3);
361 current_match.title = regex_new($3);
368 | operations ',' operation
395 TOK_EXEC optional_no_startup_id STR
398 bool no_startup_id = $2;
400 printf("should execute %s, no_startup_id = %d\n", command, no_startup_id);
401 start_application(command, no_startup_id);
406 optional_no_startup_id:
407 /* empty */ { $$ = false; }
408 | TOK_NO_STARTUP_ID { $$ = true; }
414 printf("exit, bye bye\n");
422 printf("reloading\n");
423 kill_configerror_nagbar(false);
424 load_configuration(conn, NULL, true);
426 /* Send an IPC event just in case the ws names have changed */
427 ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"reload\"}");
434 printf("restarting i3\n");
443 focused->type != CT_WORKSPACE &&
444 focused->fullscreen_mode != CF_NONE) {
445 LOG("Cannot change focus while in fullscreen mode.\n");
451 if (match_is_empty(¤t_match)) {
452 ELOG("You have to specify which window/container should be focused.\n");
453 ELOG("Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
455 sasprintf(&json_output, "{\"success\":false, \"error\":\"You have to "
456 "specify which window/container should be focused\"}");
461 TAILQ_FOREACH(current, &owindows, owindows) {
462 Con *ws = con_get_workspace(current->con);
463 /* If no workspace could be found, this was a dock window.
464 * Just skip it, you cannot focus dock windows. */
468 /* If the container is not on the current workspace,
469 * workspace_show() will switch to a different workspace and (if
470 * enabled) trigger a mouse pointer warp to the currently focused
471 * container (!) on the target workspace.
473 * Therefore, before calling workspace_show(), we make sure that
474 * 'current' will be focused on the workspace. However, we cannot
475 * just con_focus(current) because then the pointer will not be
476 * warped at all (the code thinks we are already there).
478 * So we focus 'current' to make it the currently focused window of
479 * the target workspace, then revert focus. */
480 Con *currently_focused = focused;
481 con_focus(current->con);
482 con_focus(currently_focused);
484 /* Now switch to the workspace, then focus */
486 LOG("focusing %p / %s\n", current->con, current->con->name);
487 con_focus(current->con);
492 LOG("WARNING: Your criteria for the focus command matches %d containers, "
493 "while only exactly one container can be focused at a time.\n", count);
497 | TOK_FOCUS direction
500 focused->type != CT_WORKSPACE &&
501 focused->fullscreen_mode != CF_NONE) {
502 LOG("Cannot change focus while in fullscreen mode.\n");
509 LOG("Focusing left\n");
510 tree_next('p', HORIZ);
513 LOG("Focusing right\n");
514 tree_next('n', HORIZ);
517 LOG("Focusing up\n");
518 tree_next('p', VERT);
521 LOG("Focusing down\n");
522 tree_next('n', VERT);
525 ELOG("Invalid focus direction (%d)\n", direction);
531 | TOK_FOCUS window_mode
534 focused->type != CT_WORKSPACE &&
535 focused->fullscreen_mode != CF_NONE) {
536 LOG("Cannot change focus while in fullscreen mode.\n");
540 printf("should focus: ");
542 if ($2 == TOK_TILING)
544 else if ($2 == TOK_FLOATING)
545 printf("floating\n");
546 else printf("mode toggle\n");
548 Con *ws = con_get_workspace(focused);
552 if ($2 == TOK_MODE_TOGGLE) {
553 current = TAILQ_FIRST(&(ws->focus_head));
554 if (current != NULL && current->type == CT_FLOATING_CON)
555 to_focus = TOK_TILING;
556 else to_focus = TOK_FLOATING;
558 TAILQ_FOREACH(current, &(ws->focus_head), focused) {
559 if ((to_focus == TOK_FLOATING && current->type != CT_FLOATING_CON) ||
560 (to_focus == TOK_TILING && current->type == CT_FLOATING_CON))
563 con_focus(con_descend_focused(current));
573 focused->type != CT_WORKSPACE &&
574 focused->fullscreen_mode != CF_NONE) {
575 LOG("Cannot change focus while in fullscreen mode.\n");
579 if ($2 == TOK_PARENT)
588 TOK_TILING { $$ = TOK_TILING; }
589 | TOK_FLOATING { $$ = TOK_FLOATING; }
590 | TOK_MODE_TOGGLE { $$ = TOK_MODE_TOGGLE; }
594 TOK_PARENT { $$ = TOK_PARENT; }
595 | TOK_CHILD { $$ = TOK_CHILD; }
599 TOK_KILL optional_kill_mode
603 printf("killing!\n");
604 /* check if the match is empty, not if the result is empty */
605 if (match_is_empty(¤t_match))
608 TAILQ_FOREACH(current, &owindows, owindows) {
609 printf("matching: %p / %s\n", current->con, current->con->name);
610 tree_close(current->con, $2, false, false);
619 /* empty */ { $$ = KILL_WINDOW; }
620 | TOK_WINDOW { $$ = KILL_WINDOW; }
621 | TOK_CLIENT { $$ = KILL_CLIENT; }
625 TOK_WORKSPACE TOK_NEXT
627 workspace_show(workspace_next());
630 | TOK_WORKSPACE TOK_PREV
632 workspace_show(workspace_prev());
635 | TOK_WORKSPACE TOK_BACK_AND_FORTH
637 workspace_back_and_forth();
642 if (strncasecmp($2, "__i3_", strlen("__i3_")) == 0) {
643 printf("You cannot switch to the i3 internal workspaces.\n");
647 printf("should switch to workspace %s\n", $2);
649 Con *ws = con_get_workspace(focused);
651 /* Check if the command wants to switch to the current workspace */
652 if (strcmp(ws->name, $2) == 0) {
653 printf("This workspace is already focused.\n");
654 if (config.workspace_auto_back_and_forth) {
655 workspace_back_and_forth();
662 workspace_show_by_name($2);
672 printf("opening new container\n");
673 Con *con = tree_open_con(NULL, NULL);
675 sasprintf(&json_output, "{\"success\":true, \"id\":%ld}", (long int)con);
682 TOK_FULLSCREEN fullscreen_mode
684 printf("toggling fullscreen, mode = %s\n", ($2 == CF_OUTPUT ? "normal" : "global"));
689 TAILQ_FOREACH(current, &owindows, owindows) {
690 printf("matching: %p / %s\n", current->con, current->con->name);
691 con_toggle_fullscreen(current->con, $2);
699 /* empty */ { $$ = CF_OUTPUT; }
700 | TOK_GLOBAL { $$ = CF_GLOBAL; }
704 TOK_SPLIT split_direction
706 /* TODO: use matches */
707 printf("splitting in direction %c\n", $2);
708 tree_split(focused, ($2 == 'v' ? VERT : HORIZ));
715 TOK_HORIZONTAL { $$ = 'h'; }
717 | TOK_VERTICAL { $$ = 'v'; }
727 TAILQ_FOREACH(current, &owindows, owindows) {
728 printf("matching: %p / %s\n", current->con, current->con->name);
729 if ($2 == TOK_TOGGLE) {
730 printf("should toggle mode\n");
731 toggle_floating_mode(current->con, false);
733 printf("should switch mode to %s\n", ($2 == TOK_FLOATING ? "floating" : "tiling"));
734 if ($2 == TOK_ENABLE) {
735 floating_enable(current->con, false);
737 floating_disable(current->con, false);
747 TOK_ENABLE { $$ = TOK_ENABLE; }
748 | TOK_DISABLE { $$ = TOK_DISABLE; }
749 | TOK_TOGGLE { $$ = TOK_TOGGLE; }
753 TOK_BORDER border_style
755 printf("border style should be changed to %d\n", $2);
760 TAILQ_FOREACH(current, &owindows, owindows) {
761 printf("matching: %p / %s\n", current->con, current->con->name);
762 int border_style = current->con->border_style;
763 if ($2 == TOK_TOGGLE) {
766 } else border_style = $2;
767 con_set_border_style(current->con, border_style);
775 TOK_NORMAL { $$ = BS_NORMAL; }
776 | TOK_NONE { $$ = BS_NONE; }
777 | TOK_1PIXEL { $$ = BS_1PIXEL; }
778 | TOK_TOGGLE { $$ = TOK_TOGGLE; }
782 TOK_MOVE direction resize_px
787 /* TODO: make 'move' work with criteria. */
788 printf("moving in direction %d\n", direction);
789 if (con_is_floating(focused)) {
790 printf("floating move with %d pixels\n", px);
791 Rect newrect = focused->parent->rect;
792 if (direction == TOK_LEFT) {
794 } else if (direction == TOK_RIGHT) {
796 } else if (direction == TOK_UP) {
798 } else if (direction == TOK_DOWN) {
801 floating_reposition(focused->parent, newrect);
803 tree_move(direction);
807 | TOK_MOVE TOK_WORKSPACE STR
809 if (strncasecmp($3, "__i3_", strlen("__i3_")) == 0) {
810 printf("You cannot switch to the i3 internal workspaces.\n");
816 /* Error out early to not create a non-existing workspace (in
817 * workspace_get()) if we are not actually able to move anything. */
818 if (match_is_empty(¤t_match) && focused->type == CT_WORKSPACE)
821 printf("should move window to workspace %s\n", $3);
822 /* get the workspace */
823 Con *ws = workspace_get($3, NULL);
828 TAILQ_FOREACH(current, &owindows, owindows) {
829 printf("matching: %p / %s\n", current->con, current->con->name);
830 con_move_to_workspace(current->con, ws, true, false);
835 | TOK_MOVE TOK_WORKSPACE TOK_NEXT
839 /* get the workspace */
840 Con *ws = workspace_next();
844 TAILQ_FOREACH(current, &owindows, owindows) {
845 printf("matching: %p / %s\n", current->con, current->con->name);
846 con_move_to_workspace(current->con, ws, true, false);
851 | TOK_MOVE TOK_WORKSPACE TOK_PREV
855 /* get the workspace */
856 Con *ws = workspace_prev();
860 TAILQ_FOREACH(current, &owindows, owindows) {
861 printf("matching: %p / %s\n", current->con, current->con->name);
862 con_move_to_workspace(current->con, ws, true, false);
867 | TOK_MOVE TOK_OUTPUT STR
871 printf("should move window to output %s\n", $3);
876 Output *current_output = NULL;
879 TAILQ_FOREACH(current, &owindows, owindows)
880 current_output = get_output_containing(current->con->rect.x, current->con->rect.y);
882 assert(current_output != NULL);
884 if (strcasecmp($3, "up") == 0)
885 output = get_output_next(D_UP, current_output);
886 else if (strcasecmp($3, "down") == 0)
887 output = get_output_next(D_DOWN, current_output);
888 else if (strcasecmp($3, "left") == 0)
889 output = get_output_next(D_LEFT, current_output);
890 else if (strcasecmp($3, "right") == 0)
891 output = get_output_next(D_RIGHT, current_output);
893 output = get_output_by_name($3);
897 printf("No such output found.\n");
901 /* get visible workspace on output */
903 GREP_FIRST(ws, output_get_content(output->con), workspace_is_visible(child));
907 TAILQ_FOREACH(current, &owindows, owindows) {
908 printf("matching: %p / %s\n", current->con, current->con->name);
909 con_move_to_workspace(current->con, ws, true, false);
914 | TOK_MOVE TOK_SCRATCHPAD
916 printf("should move window to scratchpad\n");
921 TAILQ_FOREACH(current, &owindows, owindows) {
922 printf("matching: %p / %s\n", current->con, current->con->name);
923 scratchpad_move(current->con);
931 TOK_APPEND_LAYOUT STR
933 printf("restoring \"%s\"\n", $2);
934 tree_append_json($2);
941 TOK_LAYOUT layout_mode
943 printf("changing layout to %d\n", $2);
946 /* check if the match is empty, not if the result is empty */
947 if (match_is_empty(¤t_match))
948 con_set_layout(focused->parent, $2);
950 TAILQ_FOREACH(current, &owindows, owindows) {
951 printf("matching: %p / %s\n", current->con, current->con->name);
952 con_set_layout(current->con, $2);
961 TOK_DEFAULT { $$ = L_DEFAULT; }
962 | TOK_STACKED { $$ = L_STACKED; }
963 | TOK_TABBED { $$ = L_TABBED; }
969 printf("Clearing all windows which have that mark first\n");
972 TAILQ_FOREACH(con, &all_cons, all_cons) {
973 if (con->mark && strcmp(con->mark, $2) == 0)
977 printf("marking window with str %s\n", $2);
982 TAILQ_FOREACH(current, &owindows, owindows) {
983 printf("matching: %p / %s\n", current->con, current->con->name);
984 current->con->mark = $2;
994 printf("-------------------------------------------------\n");
995 printf(" NOP: %s\n", $2);
996 printf("-------------------------------------------------\n");
1002 TOK_SCRATCHPAD TOK_SHOW
1004 printf("should show scratchpad window\n");
1007 if (match_is_empty(¤t_match)) {
1008 scratchpad_show(NULL);
1010 TAILQ_FOREACH(current, &owindows, owindows) {
1011 printf("matching: %p / %s\n", current->con, current->con->name);
1012 scratchpad_show(current->con);
1022 TOK_RESIZE resize_way direction resize_px resize_tiling
1024 /* resize <grow|shrink> <direction> [<px> px] [or <ppt> ppt] */
1025 printf("resizing in way %d, direction %d, px %d or ppt %d\n", $2, $3, $4, $5);
1029 if ($2 == TOK_SHRINK) {
1035 if ((floating_con = con_inside_floating(focused))) {
1036 printf("floating resize\n");
1037 if (direction == TOK_UP) {
1038 floating_con->rect.y -= px;
1039 floating_con->rect.height += px;
1040 } else if (direction == TOK_DOWN) {
1041 floating_con->rect.height += px;
1042 } else if (direction == TOK_LEFT) {
1043 floating_con->rect.x -= px;
1044 floating_con->rect.width += px;
1046 floating_con->rect.width += px;
1049 LOG("tiling resize\n");
1050 /* get the appropriate current container (skip stacked/tabbed cons) */
1051 Con *current = focused;
1052 while (current->parent->layout == L_STACKED ||
1053 current->parent->layout == L_TABBED)
1054 current = current->parent;
1056 /* Then further go up until we find one with the matching orientation. */
1057 orientation_t search_orientation =
1058 (direction == TOK_LEFT || direction == TOK_RIGHT ? HORIZ : VERT);
1060 while (current->type != CT_WORKSPACE &&
1061 current->type != CT_FLOATING_CON &&
1062 current->parent->orientation != search_orientation)
1063 current = current->parent;
1065 /* get the default percentage */
1066 int children = con_num_children(current->parent);
1068 LOG("ins. %d children\n", children);
1069 double percentage = 1.0 / children;
1070 LOG("default percentage = %f\n", percentage);
1072 orientation_t orientation = current->parent->orientation;
1074 if ((orientation == HORIZ &&
1075 (direction == TOK_UP || direction == TOK_DOWN)) ||
1076 (orientation == VERT &&
1077 (direction == TOK_LEFT || direction == TOK_RIGHT))) {
1078 LOG("You cannot resize in that direction. Your focus is in a %s split container currently.\n",
1079 (orientation == HORIZ ? "horizontal" : "vertical"));
1083 if (direction == TOK_UP || direction == TOK_LEFT) {
1084 other = TAILQ_PREV(current, nodes_head, nodes);
1086 other = TAILQ_NEXT(current, nodes);
1088 if (other == TAILQ_END(workspaces)) {
1089 LOG("No other container in this direction found, cannot resize.\n");
1092 LOG("other->percent = %f\n", other->percent);
1093 LOG("current->percent before = %f\n", current->percent);
1094 if (current->percent == 0.0)
1095 current->percent = percentage;
1096 if (other->percent == 0.0)
1097 other->percent = percentage;
1098 double new_current_percent = current->percent + ((double)ppt / 100.0);
1099 double new_other_percent = other->percent - ((double)ppt / 100.0);
1100 LOG("new_current_percent = %f\n", new_current_percent);
1101 LOG("new_other_percent = %f\n", new_other_percent);
1102 /* Ensure that the new percentages are positive and greater than
1103 * 0.05 to have a reasonable minimum size. */
1104 if (definitelyGreaterThan(new_current_percent, 0.05, DBL_EPSILON) &&
1105 definitelyGreaterThan(new_other_percent, 0.05, DBL_EPSILON)) {
1106 current->percent += ((double)ppt / 100.0);
1107 other->percent -= ((double)ppt / 100.0);
1108 LOG("current->percent after = %f\n", current->percent);
1109 LOG("other->percent after = %f\n", other->percent);
1111 LOG("Not resizing, already at minimum size\n");
1135 | TOK_OR NUMBER TOK_PPT
1142 TOK_GROW { $$ = TOK_GROW; }
1143 | TOK_SHRINK { $$ = TOK_SHRINK; }
1147 TOK_UP { $$ = TOK_UP; }
1148 | TOK_DOWN { $$ = TOK_DOWN; }
1149 | TOK_LEFT { $$ = TOK_LEFT; }
1150 | TOK_RIGHT { $$ = TOK_RIGHT; }