From: Christian Heller Date: Wed, 22 Jan 2014 13:46:22 +0000 (+0100) Subject: Client: Changed window sizing algorithm to fix bug of too large negative window X-Git-Tag: tce~878 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/static/process?a=commitdiff_plain;h=1befe1034a6330301d4af2df80aaa98430a6e8c9;p=plomrogue Client: Changed window sizing algorithm to fix bug of too large negative window width values wrapping into super-large positive width values if pad size is too small. --- diff --git a/src/client/windows.c b/src/client/windows.c index ff57399..0ebe56d 100644 --- a/src/client/windows.c +++ b/src/client/windows.c @@ -461,21 +461,23 @@ extern void init_win(struct Win ** wp, char * title, int16_t height, w->draw = func; w->center.y = 0; w->center.x = 0; - if (0 < width) + w->framesize.y = world.wmeta.padsize.y - 1; + if (0 < height && height <= world.wmeta.padsize.y - 1) { - w->framesize.x = width; + w->framesize.y = height; } - else if (0 >= width) + else if (0 > height && world.wmeta.padsize.y + (height - 1) > 0) { - w->framesize.x = world.wmeta.padsize.x + width; + w->framesize.y = world.wmeta.padsize.y + (height - 1); } - if (0 < height && height <= world.wmeta.padsize.y - 1) + w->framesize.x = world.wmeta.padsize.x; + if (0 < width) { - w->framesize.y = height; + w->framesize.x = width; } - else if (0 >= height && world.wmeta.padsize.y + (height - 1) > 0) + else if (0 > width && world.wmeta.padsize.x + width > 0) { - w->framesize.y = world.wmeta.padsize.y + (height - 1); + w->framesize.x = world.wmeta.padsize.x + width; } *wp = w; } diff --git a/src/client/windows.h b/src/client/windows.h index 7c0ef77..5e99343 100644 --- a/src/client/windows.h +++ b/src/client/windows.h @@ -78,9 +78,9 @@ extern void init_win_meta(); * Pass 0 for "width" to make the window as wide as the terminal screen. Pass 0 * for "height" for the maximum allowed height: one cell smaller than that of * the terminal screen. Pass negative values for either of them to make the - * window width/height so many cells smaller than what 0 would set. The maximum - * allowed height is also applied for positive height values that exceed it or - * negative values that would reduce the window height to less than 1 cell. + * window width/height so many cells smaller than what 0 would set. Values that + * that would reduce the window height or width to less than 1 cell according to + * the aforementioned rules set the height/width as if they were set to 0. */ extern void init_win(struct Win ** wp, char * title, int16_t height, int16_t width, void * func);