[mutter] constraints: Fix up aspect ratio math for frame rect conversion



commit cb66ab5a87251b21c3f807474022a0b74dba8808
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Nov 10 15:49:06 2014 -0800

    constraints: Fix up aspect ratio math for frame rect conversion

 src/core/constraints.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/core/constraints.c b/src/core/constraints.c
index d0ac4fa..12d2583 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
    */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]