Distribute rest space between windows as long as possible. (Thanks msi)
When having 8 windows in a container which has 766 px available, you ended up losing 0,75 px per window which would quickly sum up. Now, the rest space (6 px in this example) is distributed in units of one pixel to as many windows as possible.
This commit is contained in:
parent
f87b98e0a7
commit
937048d47b
13
src/layout.c
13
src/layout.c
|
@ -363,6 +363,10 @@ void render_container(xcb_connection_t *conn, Container *container) {
|
||||||
num_clients++;
|
num_clients++;
|
||||||
|
|
||||||
if (container->mode == MODE_DEFAULT) {
|
if (container->mode == MODE_DEFAULT) {
|
||||||
|
int height = (container->height / max(1, num_clients));
|
||||||
|
int rest_pixels = (container->height % max(1, num_clients));
|
||||||
|
LOG("height per client = %d, rest = %d\n", height, rest_pixels);
|
||||||
|
|
||||||
CIRCLEQ_FOREACH(client, &(container->clients), clients) {
|
CIRCLEQ_FOREACH(client, &(container->clients), clients) {
|
||||||
/* If the client is in fullscreen mode, it does not get reconfigured */
|
/* If the client is in fullscreen mode, it does not get reconfigured */
|
||||||
if (container->workspace->fullscreen_client == client) {
|
if (container->workspace->fullscreen_client == client) {
|
||||||
|
@ -370,6 +374,13 @@ void render_container(xcb_connection_t *conn, Container *container) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we have some pixels left to distribute, add one
|
||||||
|
* pixel to each client as long as possible. */
|
||||||
|
int this_height = height;
|
||||||
|
if (rest_pixels > 0) {
|
||||||
|
height++;
|
||||||
|
rest_pixels--;
|
||||||
|
}
|
||||||
/* Check if we changed client->x or client->y by updating it.
|
/* Check if we changed client->x or client->y by updating it.
|
||||||
* Note the bitwise OR instead of logical OR to force evaluation of both statements */
|
* Note the bitwise OR instead of logical OR to force evaluation of both statements */
|
||||||
if (client->force_reconfigure |
|
if (client->force_reconfigure |
|
||||||
|
@ -377,7 +388,7 @@ void render_container(xcb_connection_t *conn, Container *container) {
|
||||||
update_if_necessary(&(client->rect.y), container->y +
|
update_if_necessary(&(client->rect.y), container->y +
|
||||||
(container->height / num_clients) * current_client) |
|
(container->height / num_clients) * current_client) |
|
||||||
update_if_necessary(&(client->rect.width), container->width) |
|
update_if_necessary(&(client->rect.width), container->width) |
|
||||||
update_if_necessary(&(client->rect.height), container->height / num_clients))
|
update_if_necessary(&(client->rect.height), this_height))
|
||||||
resize_client(conn, client);
|
resize_client(conn, client);
|
||||||
|
|
||||||
/* TODO: vertical default layout */
|
/* TODO: vertical default layout */
|
||||||
|
|
Loading…
Reference in New Issue