Fix the choice of the right containers for resizing.

Also fixes #311, which was an assertion failure that uncovered
this problem. Thanks mseed, Merovius.
This commit is contained in:
Fernando Tarlá Cardoso Lemos 2011-01-29 14:32:44 -02:00 committed by Michael Stapelberg
parent b078957cff
commit 8f4b9ddaa4
1 changed files with 36 additions and 21 deletions

View File

@ -329,38 +329,48 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
DLOG("BORDER x = %d, y = %d for con %p, window 0x%08x, border_click = %d, clicked_into = %p\n", DLOG("BORDER x = %d, y = %d for con %p, window 0x%08x, border_click = %d, clicked_into = %p\n",
event->event_x, event->event_y, con, event->event, border_click, clicked_into); event->event_x, event->event_y, con, event->event, border_click, clicked_into);
DLOG("checks for right >= %d\n", con->window_rect.x + con->window_rect.width); DLOG("checks for right >= %d\n", con->window_rect.x + con->window_rect.width);
Con *first = NULL, *second = NULL; char way = '\0';
int orientation;
if (clicked_into) { if (clicked_into) {
DLOG("BORDER top\n"); DLOG("BORDER top\n");
if ((first = con_get_next(clicked_into, 'p', VERT)) != NULL) { way = 'p';
/* instead of setting second = clicked_into we get the container orientation = VERT;
* below the one which con_get_next returned. This way, if
* clicked_into is inside another split-con, we get the correct
* parent to work with. */
second = TAILQ_NEXT(first, nodes);
resize_graphical_handler(first, second, VERT, event);
}
} else if (event->event_x >= 0 && event->event_x <= bsr.x && } else if (event->event_x >= 0 && event->event_x <= bsr.x &&
event->event_y >= bsr.y && event->event_y <= con->rect.height + bsr.height) { event->event_y >= bsr.y && event->event_y <= con->rect.height + bsr.height) {
DLOG("BORDER left\n"); DLOG("BORDER left\n");
second = con; way = 'p';
if ((first = con_get_next(con, 'p', HORIZ)) != NULL) orientation = HORIZ;
resize_graphical_handler(first, second, HORIZ, event);
} else if (event->event_x >= (con->window_rect.x + con->window_rect.width) && } else if (event->event_x >= (con->window_rect.x + con->window_rect.width) &&
event->event_y >= bsr.y && event->event_y <= con->rect.height + bsr.height) { event->event_y >= bsr.y && event->event_y <= con->rect.height + bsr.height) {
DLOG("BORDER right\n"); DLOG("BORDER right\n");
first = con; way = 'n';
if ((second = con_get_next(con, 'n', HORIZ)) != NULL) orientation = HORIZ;
resize_graphical_handler(first, second, HORIZ, event);
} else if (event->event_y >= (con->window_rect.y + con->window_rect.height)) { } else if (event->event_y >= (con->window_rect.y + con->window_rect.height)) {
DLOG("BORDER bottom\n"); DLOG("BORDER bottom\n");
way = 'n';
orientation = VERT;
}
first = con; /* look for a parent container with the right orientation */
if ((second = con_get_next(con, 'n', VERT)) != NULL) Con *first = NULL, *second = NULL;
resize_graphical_handler(first, second, VERT, event); if (way != '\0') {
} else { Con *resize_con = clicked_into ? clicked_into : con;
/* Set first and second to NULL to trigger a replay of the event */ while (resize_con->type != CT_WORKSPACE &&
first = second = NULL; resize_con->parent->orientation != orientation)
resize_con = resize_con->parent;
if (resize_con->type != CT_WORKSPACE &&
resize_con->parent->orientation == orientation) {
first = resize_con;
second = (way == 'n') ? TAILQ_NEXT(first, nodes) : TAILQ_PREV(first, nodes_head, nodes);
if (second == TAILQ_END(&(first->nodes_head))) {
second = NULL;
}
else if (way == 'p') {
Con *tmp = first;
first = second;
second = tmp;
}
}
} }
if (first == NULL || second == NULL) { if (first == NULL || second == NULL) {
@ -370,6 +380,11 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
xcb_flush(conn); xcb_flush(conn);
return 0; return 0;
} }
else {
assert(first != second);
assert(first->parent == second->parent);
resize_graphical_handler(first, second, orientation, event);
}
DLOG("After resize handler, rendering\n"); DLOG("After resize handler, rendering\n");
tree_render(); tree_render();