From 8e5409a2cde8234952caa1fb8caa11361de2a6fa Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 22 Jul 2010 09:42:04 +0200 Subject: [PATCH] Fix a minor ICCCM incompatibility ICCCM says that the min size should be used for the base size if no base size is specified. The only exception is when calculating the aspect ratio of the window, in that case only the "real" base size may be used. Awesome didn't do this last part before. Signed-off-by: Uli Schlachter --- objects/client.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/objects/client.c b/objects/client.c index 4da66142f..b769299b8 100644 --- a/objects/client.c +++ b/objects/client.c @@ -553,12 +553,15 @@ area_t client_geometry_hints(client_t *c, area_t geometry) { int32_t basew, baseh, minw, minh; + int32_t real_basew = 0, real_baseh = 0; /* base size is substituted with min size if not specified */ if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE) { basew = c->size_hints.base_width; baseh = c->size_hints.base_height; + real_basew = basew; + real_baseh = baseh; } else if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE) { @@ -585,11 +588,17 @@ client_geometry_hints(client_t *c, area_t geometry) if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT && c->size_hints.min_aspect_num > 0 && c->size_hints.min_aspect_den > 0 - && geometry.height - baseh > 0 - && geometry.width - basew > 0) + && geometry.height - real_baseh > 0 + && geometry.width - real_basew > 0) { - double dx = (double) (geometry.width - basew); - double dy = (double) (geometry.height - baseh); + /* ICCCM mandates: + * If a base size is provided along with the aspect ratio fields, the + * base size should be subtracted from the window size prior to checking + * that the aspect ratio falls in range. If a base size is not provided, + * nothing should be subtracted from the window size. (The minimum size + * is not to be used in place of the base size for this purpose.) */ + double dx = (double) (geometry.width - real_basew); + double dy = (double) (geometry.height - real_baseh); double min = (double) c->size_hints.min_aspect_num / (double) c->size_hints.min_aspect_den; double max = (double) c->size_hints.max_aspect_num / (double) c->size_hints.min_aspect_den; double ratio = dx / dy; @@ -599,15 +608,15 @@ client_geometry_hints(client_t *c, area_t geometry) { dy = (dx * min + dy) / (min * min + 1); dx = dy * min; - geometry.width = (int) dx + basew; - geometry.height = (int) dy + baseh; + 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; - geometry.width = (int) dx + basew; - geometry.height = (int) dy + baseh; + geometry.width = (int) dx + real_basew; + geometry.height = (int) dy + real_baseh; } } }