- /* get the appropriate current container (skip stacked/tabbed cons) */
- Con *other = NULL;
- double percentage = 0;
- while (current->parent->layout == L_STACKED ||
- current->parent->layout == L_TABBED)
- current = current->parent;
-
- /* Then further go up until we find one with the matching orientation. */
- orientation_t search_orientation =
- (strcmp(direction, "left") == 0 || strcmp(direction, "right") == 0 ? HORIZ : VERT);
-
- do {
- if (con_orientation(current->parent) != search_orientation) {
- current = current->parent;
- continue;
- }
-
- /* get the default percentage */
- int children = con_num_children(current->parent);
- LOG("ins. %d children\n", children);
- percentage = 1.0 / children;
- LOG("default percentage = %f\n", percentage);
-
- orientation_t orientation = con_orientation(current->parent);
-
- if ((orientation == HORIZ &&
- (strcmp(direction, "up") == 0 || strcmp(direction, "down") == 0)) ||
- (orientation == VERT &&
- (strcmp(direction, "left") == 0 || strcmp(direction, "right") == 0))) {
- LOG("You cannot resize in that direction. Your focus is in a %s split container currently.\n",
- (orientation == HORIZ ? "horizontal" : "vertical"));
- ysuccess(false);
- return false;
- }
-
- if (strcmp(direction, "up") == 0 || strcmp(direction, "left") == 0) {
- other = TAILQ_PREV(current, nodes_head, nodes);
- } else {
- other = TAILQ_NEXT(current, nodes);
- }
- if (other == TAILQ_END(workspaces)) {
- LOG("No other container in this direction found, trying to look further up in the tree...\n");
- current = current->parent;
- continue;
- }
- break;
- } while (current->type != CT_WORKSPACE &&
- current->type != CT_FLOATING_CON);
+ Con *second = NULL;
+ Con *first = current;
+ direction_t search_direction;
+ if (!strcmp(direction, "left"))
+ search_direction = D_LEFT;
+ else if (!strcmp(direction, "right"))
+ search_direction = D_RIGHT;
+ else if (!strcmp(direction, "up"))
+ search_direction = D_UP;
+ else
+ search_direction = D_DOWN;