Bugfix: Fix display/resizing of colspanned containers

This commit is contained in:
Michael Stapelberg 2009-05-09 18:43:02 +02:00
parent 8e1990f058
commit 3ccc0d7794
4 changed files with 46 additions and 37 deletions

View File

@ -21,7 +21,7 @@ typedef enum { O_HORIZONTAL, O_VERTICAL } resize_orientation_t;
* the table column/row. * the table column/row.
* *
*/ */
int resize_graphical_handler(xcb_connection_t *conn, Container *first, Container *second, int resize_graphical_handler(xcb_connection_t *conn, Workspace *ws, int first, int second,
resize_orientation_t orientation, xcb_button_press_event_t *event); resize_orientation_t orientation, xcb_button_press_event_t *event);
#endif #endif

View File

@ -304,9 +304,8 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
/* Lets see if this was on the borders (= resize). If not, were done */ /* Lets see if this was on the borders (= resize). If not, were done */
LOG("press button on x=%d, y=%d\n", event->event_x, event->event_y); LOG("press button on x=%d, y=%d\n", event->event_x, event->event_y);
resize_orientation_t orientation = O_VERTICAL; resize_orientation_t orientation = O_VERTICAL;
Container *con = client->container, Container *con = client->container;
*first = NULL, int first, second;
*second = NULL;
if (con == NULL) { if (con == NULL) {
LOG("dock. done.\n"); LOG("dock. done.\n");
@ -335,31 +334,38 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
/* This was a press on the top border */ /* This was a press on the top border */
if (con->row == 0) if (con->row == 0)
return 1; return 1;
first = con->workspace->table[con->col][con->row-1]; first = con->row - 1;
second = con; second = con->row;
orientation = O_HORIZONTAL; orientation = O_HORIZONTAL;
} else if (event->event_y >= (client->rect.height - 2)) { } else if (event->event_y >= (client->rect.height - 2)) {
/* …bottom border */ /* …bottom border */
if (con->row == (con->workspace->rows-1)) first = con->row + (con->rowspan - 1);
if (!cell_exists(con->col, first) ||
(first == (con->workspace->rows-1)))
return 1; return 1;
first = con;
second = con->workspace->table[con->col][con->row+1]; second = first + 1;
orientation = O_HORIZONTAL; orientation = O_HORIZONTAL;
} else if (event->event_x <= 2) { } else if (event->event_x <= 2) {
/* …left border */ /* …left border */
if (con->col == 0) if (con->col == 0)
return 1; return 1;
first = con->workspace->table[con->col-1][con->row];
second = con; first = con->col - 1;
second = con->col;
} else if (event->event_x > 2) { } else if (event->event_x > 2) {
/* …right border */ /* …right border */
if (con->col == (con->workspace->cols-1)) first = con->col + (con->colspan - 1);
LOG("column %d\n", first);
if (!cell_exists(first, con->row) ||
(first == (con->workspace->cols-1)))
return 1; return 1;
first = con;
second = con->workspace->table[con->col+1][con->row]; second = first + 1;
} }
return resize_graphical_handler(conn, first, second, orientation, event); return resize_graphical_handler(conn, con->workspace, first, second, orientation, event);
} }
/* /*

View File

@ -520,12 +520,14 @@ void render_workspace(xcb_connection_t *conn, i3Screen *screen, Workspace *r_ws)
container->col = cols; container->col = cols;
container->x = xoffset[rows]; container->x = xoffset[rows];
container->y = yoffset[cols]; container->y = yoffset[cols];
container->width = 0;
if (r_ws->width_factor[cols] == 0) for (int c = 0; c < container->colspan; c++) {
container->width = (width / r_ws->cols); if (r_ws->width_factor[cols+c] == 0)
else container->width = get_unoccupied_x(r_ws) * r_ws->width_factor[cols]; container->width += (width / r_ws->cols);
else container->width += get_unoccupied_x(r_ws) * r_ws->width_factor[cols+c];
}
single_width = container->width; single_width = container->width;
container->width *= container->colspan;
//if (container->height_factor == 0) //if (container->height_factor == 0)
container->height = (height / r_ws->rows); container->height = (height / r_ws->rows);

View File

@ -30,7 +30,7 @@
* the table column/row. * the table column/row.
* *
*/ */
int resize_graphical_handler(xcb_connection_t *conn, Container *first, Container *second, int resize_graphical_handler(xcb_connection_t *conn, Workspace *ws, int first, int second,
resize_orientation_t orientation, xcb_button_press_event_t *event) { resize_orientation_t orientation, xcb_button_press_event_t *event) {
int new_position; int new_position;
xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root; xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root;
@ -132,7 +132,6 @@ int resize_graphical_handler(xcb_connection_t *conn, Container *first, Container
xcb_destroy_window(conn, grabwin); xcb_destroy_window(conn, grabwin);
xcb_flush(conn); xcb_flush(conn);
Workspace *ws = first->workspace;
if (orientation == O_VERTICAL) { if (orientation == O_VERTICAL) {
LOG("Resize was from X = %d to X = %d\n", event->root_x, new_position); LOG("Resize was from X = %d to X = %d\n", event->root_x, new_position);
if (event->root_x == new_position) { if (event->root_x == new_position) {
@ -150,10 +149,10 @@ int resize_graphical_handler(xcb_connection_t *conn, Container *first, Container
if (old_unoccupied_x == 0) if (old_unoccupied_x == 0)
old_unoccupied_x = ws->rect.width; old_unoccupied_x = ws->rect.width;
if (ws->width_factor[first->col] == 0) if (ws->width_factor[first] == 0)
new_unoccupied_x += default_width; new_unoccupied_x += default_width;
if (ws->width_factor[second->col] == 0) if (ws->width_factor[second] == 0)
new_unoccupied_x += default_width; new_unoccupied_x += default_width;
LOG("\n\n\n"); LOG("\n\n\n");
@ -173,24 +172,26 @@ int resize_graphical_handler(xcb_connection_t *conn, Container *first, Container
LOG("old_unoccupied_x = %d\n", old_unoccupied_x); LOG("old_unoccupied_x = %d\n", old_unoccupied_x);
LOG("Updating first (before = %f)\n", ws->width_factor[first->col]); LOG("Updating first (before = %f)\n", ws->width_factor[first]);
/* Convert 0 (for default width_factor) to actual numbers */ /* Convert 0 (for default width_factor) to actual numbers */
if (ws->width_factor[first->col] == 0) if (ws->width_factor[first] == 0)
ws->width_factor[first->col] = ((float)ws->rect.width / ws->cols) / new_unoccupied_x; ws->width_factor[first] = ((float)ws->rect.width / ws->cols) / new_unoccupied_x;
LOG("middle = %f\n", ws->width_factor[first->col]); LOG("middle = %f\n", ws->width_factor[first]);
LOG("first->width = %d, new_position = %d, event->root_x = %d\n", first->width, new_position, event->root_x); int old_width = ws->width_factor[first] * old_unoccupied_x;
ws->width_factor[first->col] *= (float)(first->width + (new_position - event->root_x)) / first->width; LOG("first->width = %d, new_position = %d, event->root_x = %d\n", old_width, new_position, event->root_x);
LOG("-> %f\n", ws->width_factor[first->col]); ws->width_factor[first] *= (float)(old_width + (new_position - event->root_x)) / old_width;
LOG("-> %f\n", ws->width_factor[first]);
LOG("Updating second (before = %f)\n", ws->width_factor[second->col]); LOG("Updating second (before = %f)\n", ws->width_factor[second]);
if (ws->width_factor[second->col] == 0) if (ws->width_factor[second] == 0)
ws->width_factor[second->col] = ((float)ws->rect.width / ws->cols) / new_unoccupied_x; ws->width_factor[second] = ((float)ws->rect.width / ws->cols) / new_unoccupied_x;
LOG("middle = %f\n", ws->width_factor[second->col]); LOG("middle = %f\n", ws->width_factor[second]);
LOG("second->width = %d, new_position = %d, event->root_x = %d\n", second->width, new_position, event->root_x); old_width = ws->width_factor[second] * old_unoccupied_x;
ws->width_factor[second->col] *= (float)(second->width - (new_position - event->root_x)) / second->width; LOG("second->width = %d, new_position = %d, event->root_x = %d\n", old_width, new_position, event->root_x);
LOG("-> %f\n", ws->width_factor[second->col]); ws->width_factor[second] *= (float)(old_width - (new_position - event->root_x)) / old_width;
LOG("-> %f\n", ws->width_factor[second]);
LOG("new unoccupied_x = %d\n", get_unoccupied_x(ws)); LOG("new unoccupied_x = %d\n", get_unoccupied_x(ws));