From: Michael Stapelberg Date: Sat, 28 Feb 2009 14:47:51 +0000 (+0100) Subject: Bugfix: Correctly reconfigure clients when it’s necessary X-Git-Tag: 3.a~131 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4ad7f8fb1a60fa3dccc6b61bd7e74a315966e7fb;p=i3%2Fi3 Bugfix: Correctly reconfigure clients when it’s necessary --- diff --git a/src/layout.c b/src/layout.c index fd9c7904..635e020c 100644 --- a/src/layout.c +++ b/src/layout.c @@ -193,23 +193,25 @@ void render_container(xcb_connection_t *connection, Container *container) { num_clients++; if (container->mode == MODE_DEFAULT) { + /* This macro copies the old value of the given variable, changes the variable to contain + th new one and returns true if it changed */ + #define HAS_CHANGED(value, new) (old_value = value, old_value != (value = new)) + printf("got %d clients in this default container.\n", num_clients); CIRCLEQ_FOREACH(client, &(container->clients), clients) { /* 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 */ + int old_value; if (client->force_reconfigure | - (client->rect.x != (client->rect.x = container->x)) | - (client->rect.y != (client->rect.y = container->y + - (container->height / num_clients) * current_client))) { + HAS_CHANGED(client->rect.x, container->x) | + HAS_CHANGED(client->rect.y, container->y + + (container->height / num_clients) * current_client)) reposition_client(connection, client); - } - printf("before client->rect.width = %d, client->rect.height = %d\n", client->rect.width, - client->rect.height); /* TODO: vertical default layout */ if (client->force_reconfigure | - (client->rect.width != (client->rect.width = container->width)) | - (client->rect.height != (client->rect.height = container->height / num_clients))) { + HAS_CHANGED(client->rect.width, container->width) | + HAS_CHANGED(client->rect.height, container->height / num_clients)) { resize_client(connection, client); } else printf("no reconfigure necessary\n"); printf("after client->rect.width = %d, client->rect.height = %d\n", client->rect.width,