From 5bfe0f69d129be26a140aaba2c86f747111b1d8e Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 22 Jul 2010 10:32:57 +0200 Subject: [PATCH] Improve aspect size handling The window is now no longer enlarged to make it fit into its aspect ratio, but only ever made lower. This was verified with a small test app that sets a min aspect ratio of 0.5 and max aspect ratio of 2. Signed-off-by: Uli Schlachter --- objects/client.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/objects/client.c b/objects/client.c index 2db5f7ef..69554f7f 100644 --- a/objects/client.c +++ b/objects/client.c @@ -606,15 +606,16 @@ client_geometry_hints(client_t *c, area_t geometry) { if(ratio < min) { - dy = (dx * min + dy) / (min * min + 1); - dx = dy * min; + /* dx is lower than allowed, make dy lower to compensate this + * (+ 0.5 to force proper rounding). */ + dy = dx / min + 0.5; geometry.width = (int) dx + real_basew; geometry.height = (int) dy + real_baseh; } else if(ratio > max) { - dy = (dx * min + dy) / (max * max + 1); - dx = dy * min; + /* dx is too high, lower it (+0.5 for proper rounding) */ + dx = dy * max + 0.5; geometry.width = (int) dx + real_basew; geometry.height = (int) dy + real_baseh; }