From cb66ab5a87251b21c3f807474022a0b74dba8808 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 10 Nov 2014 15:49:06 -0800 Subject: [PATCH] constraints: Fix up aspect ratio math for frame rect conversion --- src/core/constraints.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/core/constraints.c b/src/core/constraints.c index d0ac4fab0..12d258364 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -1017,6 +1017,7 @@ constrain_aspect_ratio (MetaWindow *window, double best_width, best_height; double alt_width, alt_height; MetaRectangle *start_rect; + MetaRectangle client_rect; if (priority > PRIORITY_ASPECT_RATIO) return TRUE; @@ -1068,15 +1069,18 @@ constrain_aspect_ratio (MetaWindow *window, fudge = 1; break; } + + meta_window_frame_rect_to_client_rect (window, &info->current, &client_rect); + constraint_already_satisfied = - info->current.width - (info->current.height * minr ) > -minr*fudge && - info->current.width - (info->current.height * maxr ) < maxr*fudge; + client_rect.width - (client_rect.height * minr ) > -minr*fudge && + client_rect.width - (client_rect.height * maxr ) < maxr*fudge; if (check_only || constraint_already_satisfied) return constraint_already_satisfied; /*** Enforce constraint ***/ - new_width = info->current.width; - new_height = info->current.height; + new_width = client_rect.width; + new_height = client_rect.height; switch (info->resize_gravity) { @@ -1123,6 +1127,14 @@ constrain_aspect_ratio (MetaWindow *window, break; } + { + client_rect.width = new_width; + client_rect.height = new_height; + meta_window_client_rect_to_frame_rect (window, &client_rect, &client_rect); + new_width = client_rect.width; + new_height = client_rect.height; + } + /* Figure out what original rect to pass to meta_rectangle_resize_with_gravity * See bug 448183 */