else
search_direction = D_DOWN;
- bool res = resize_find_tiling_participants(&first, &second, search_direction);
+ bool res = resize_find_tiling_participants(&first, &second, search_direction, false);
if (!res) {
LOG("No second container in this direction found.\n");
ysuccess(false);
static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *way, const char *direction, int ppt) {
LOG("width/height resize\n");
- /* get the appropriate current container (skip stacked/tabbed cons) */
- 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, "width") == 0 ? HORIZ : VERT);
- while (current->type != CT_WORKSPACE &&
- current->type != CT_FLOATING_CON &&
- (con_orientation(current->parent) != search_orientation || con_num_children(current->parent) == 1))
- current = current->parent;
+ /* get the appropriate current container (skip stacked/tabbed cons) */
+ Con *dummy = NULL;
+ direction_t search_direction = (strcmp(direction, "width") == 0 ? D_LEFT : D_DOWN);
+ bool search_result = resize_find_tiling_participants(¤t, &dummy, search_direction, true);
+ if (search_result == false) {
+ ysuccess(false);
+ return false;
+ }
/* get the default percentage */
int children = con_num_children(current->parent);
double percentage = 1.0 / children;
LOG("default percentage = %f\n", percentage);
- orientation_t orientation = con_orientation(current->parent);
-
- if ((orientation == HORIZ &&
- strcmp(direction, "height") == 0) ||
- (orientation == VERT &&
- strcmp(direction, "width") == 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 (children == 1) {
- LOG("This is the only container, cannot resize.\n");
- ysuccess(false);
- return false;
- }
-
/* Ensure all the other children have a percentage set. */
Con *child;
TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) {
xcb_flush(conn);
}
-bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction) {
+bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction, bool both_sides) {
DLOG("Find two participants for resizing container=%p in direction=%i\n", other, direction);
Con *first = *current;
Con *second = NULL;
/* get the counterpart for this resizement */
if (dir_backwards) {
second = TAILQ_PREV(first, nodes_head, nodes);
+ if (second == NULL && both_sides == true) {
+ second = TAILQ_NEXT(first, nodes);
+ }
} else {
second = TAILQ_NEXT(first, nodes);
+ if (second == NULL && both_sides == true) {
+ second = TAILQ_PREV(first, nodes_head, nodes);
+ }
}
if (second == NULL) {