[gtk/wip/otte/geometry: 2/4] Remove aspect ratio from GdkGeometry




commit 11db6ad5742999c6e20a9f2c042dc1d8da7a98a0
Author: Benjamin Otte <otte redhat com>
Date:   Thu Jul 30 04:50:46 2020 +0200

    Remove aspect ratio from GdkGeometry
    
    It's unused.

 gdk/gdkinternals.h           |   3 --
 gdk/gdksurface.c             |  40 -----------------
 gdk/macos/gdkmacossurface.c  |  13 ------
 gdk/win32/gdkevents-win32.c  | 105 -------------------------------------------
 gdk/win32/gdksurface-win32.c |   6 ---
 gdk/x11/gdksurface-x11.c     |  33 --------------
 gtk/gtkwindow.c              |   5 ---
 7 files changed, 205 deletions(-)
---
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index e241403e5d..3489455aef 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -299,7 +299,6 @@ typedef enum
   GDK_HINT_POS         = 1 << 0,
   GDK_HINT_MIN_SIZE    = 1 << 1,
   GDK_HINT_MAX_SIZE    = 1 << 2,
-  GDK_HINT_ASPECT      = 1 << 4,
   GDK_HINT_WIN_GRAVITY = 1 << 6,
 } GdkSurfaceHints;
 
@@ -329,8 +328,6 @@ struct _GdkGeometry
   int min_height;
   int max_width;
   int max_height;
-  double min_aspect;
-  double max_aspect;
   GdkGravity win_gravity;
 };
 
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 82761c3af2..99271c6427 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -1608,46 +1608,6 @@ gdk_surface_constrain_size (GdkGeometry    *geometry,
   width = CLAMP (width, min_width, max_width);
   height = CLAMP (height, min_height, max_height);
 
-  /* constrain aspect ratio, according to:
-   *
-   *                width
-   * min_aspect <= -------- <= max_aspect
-   *                height
-   */
-
-  if (flags & GDK_HINT_ASPECT &&
-      geometry->min_aspect > 0 &&
-      geometry->max_aspect > 0)
-    {
-      int delta;
-
-      if (geometry->min_aspect * height > width)
-        {
-          delta = height - width / geometry->min_aspect;
-          if (height - delta >= min_height)
-            height -= delta;
-          else
-            {
-              delta = height * geometry->min_aspect - width;
-              if (width + delta <= max_width)
-                width += delta;
-            }
-        }
-
-      if (geometry->max_aspect * height < width)
-        {
-          delta = width - height * geometry->max_aspect;
-          if (width - delta >= min_width)
-            width -= delta;
-          else
-            {
-              delta = width / geometry->max_aspect - height;
-              if (height + delta <= max_height)
-                height += delta;
-            }
-        }
-    }
-
   *new_width = width;
   *new_height = height;
 }
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index 968153a703..6307d5c841 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -637,19 +637,6 @@ _gdk_macos_surface_set_geometry_hints (GdkMacosSurface   *self,
     min_size = NSMakeSize (1, 1);
   [self->window setContentMinSize:min_size];
 
-  if (geom_mask & GDK_HINT_ASPECT)
-    {
-      NSSize size;
-
-      if (geometry->min_aspect != geometry->max_aspect)
-        g_warning ("Only equal minimum and maximum aspect ratios are supported on Mac OS. Using minimum 
aspect ratio...");
-
-      size.width = geometry->min_aspect;
-      size.height = 1.0;
-
-      [self->window setContentAspectRatio:size];
-    }
-
   if (geom_mask & GDK_HINT_WIN_GRAVITY) { /* TODO */ }
 }
 
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 9371cc552a..bc30da178a 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -3163,111 +3163,6 @@ gdk_event_translate (MSG *msg,
 
       impl = GDK_WIN32_SURFACE (window);
 
-      /* WM_GETMINMAXINFO handles min_size and max_size hints? */
-
-      if (impl->hint_flags & GDK_HINT_ASPECT)
-       {
-         RECT decorated_rect;
-         RECT undecorated_drag;
-         int decoration_width, decoration_height;
-         double drag_aspect;
-         int drag_width, drag_height, new_width, new_height;
-
-         GetClientRect (GDK_SURFACE_HWND (window), &rect);
-         decorated_rect = rect;
-         _gdk_win32_adjust_client_rect (window, &decorated_rect);
-
-         /* Set undecorated_drag to the client area being dragged
-          * out, in screen coordinates.
-          */
-         undecorated_drag = *drag;
-         undecorated_drag.left -= decorated_rect.left - rect.left;
-         undecorated_drag.right -= decorated_rect.right - rect.right;
-         undecorated_drag.top -= decorated_rect.top - rect.top;
-         undecorated_drag.bottom -= decorated_rect.bottom - rect.bottom;
-
-         decoration_width = (decorated_rect.right - decorated_rect.left) - (rect.right - rect.left);
-         decoration_height = (decorated_rect.bottom - decorated_rect.top) - (rect.bottom - rect.top);
-
-         drag_width = undecorated_drag.right - undecorated_drag.left;
-         drag_height = undecorated_drag.bottom - undecorated_drag.top;
-
-         drag_aspect = (double) drag_width / drag_height;
-
-         GDK_NOTE (EVENTS, g_print (" (ASPECT:%g--%g curr: %g)",
-                                    impl->hints.min_aspect, impl->hints.max_aspect, drag_aspect));
-
-         if (drag_aspect < impl->hints.min_aspect)
-           {
-             /* Aspect is getting too narrow */
-             switch (msg->wParam)
-               {
-               case WMSZ_BOTTOM:
-               case WMSZ_TOP:
-                 /* User drags top or bottom edge outward. Keep height, increase width. */
-                 new_width = impl->hints.min_aspect * drag_height;
-                 drag->left -= (new_width - drag_width) / 2;
-                 drag->right = drag->left + new_width + decoration_width;
-                 break;
-               case WMSZ_BOTTOMLEFT:
-               case WMSZ_BOTTOMRIGHT:
-                 /* User drags bottom-left or bottom-right corner down. Adjust height. */
-                 new_height = drag_width / impl->hints.min_aspect;
-                 drag->bottom = drag->top + new_height + decoration_height;
-                 break;
-               case WMSZ_LEFT:
-               case WMSZ_RIGHT:
-                 /* User drags left or right edge inward. Decrease height */
-                 new_height = drag_width / impl->hints.min_aspect;
-                 drag->top += (drag_height - new_height) / 2;
-                 drag->bottom = drag->top + new_height + decoration_height;
-                 break;
-               case WMSZ_TOPLEFT:
-               case WMSZ_TOPRIGHT:
-                 /* User drags top-left or top-right corner up. Adjust height. */
-                 new_height = drag_width / impl->hints.min_aspect;
-                 drag->top = drag->bottom - new_height - decoration_height;
-               }
-           }
-         else if (drag_aspect > impl->hints.max_aspect)
-           {
-             /* Aspect is getting too wide */
-             switch (msg->wParam)
-               {
-               case WMSZ_BOTTOM:
-               case WMSZ_TOP:
-                 /* User drags top or bottom edge inward. Decrease width. */
-                 new_width = impl->hints.max_aspect * drag_height;
-                 drag->left += (drag_width - new_width) / 2;
-                 drag->right = drag->left + new_width + decoration_width;
-                 break;
-               case WMSZ_BOTTOMLEFT:
-               case WMSZ_TOPLEFT:
-                 /* User drags bottom-left or top-left corner left. Adjust width. */
-                 new_width = impl->hints.max_aspect * drag_height;
-                 drag->left = drag->right - new_width - decoration_width;
-                 break;
-               case WMSZ_BOTTOMRIGHT:
-               case WMSZ_TOPRIGHT:
-                 /* User drags bottom-right or top-right corner right. Adjust width. */
-                 new_width = impl->hints.max_aspect * drag_height;
-                 drag->right = drag->left + new_width + decoration_width;
-                 break;
-               case WMSZ_LEFT:
-               case WMSZ_RIGHT:
-                 /* User drags left or right edge outward. Increase height. */
-                 new_height = drag_width / impl->hints.max_aspect;
-                 drag->top -= (new_height - drag_height) / 2;
-                 drag->bottom = drag->top + new_height + decoration_height;
-                 break;
-               }
-           }
-
-         *ret_valp = TRUE;
-         return_val = TRUE;
-         GDK_NOTE (EVENTS, g_print (" (handled ASPECT: %s)",
-                                    _gdk_win32_rect_to_string (drag)));
-       }
       break;
 
     case WM_GETMINMAXINFO:
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index a28c8a1049..0a29c65cce 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -1509,12 +1509,6 @@ gdk_win32_surface_set_geometry_hints (GdkSurface         *window,
                               geometry->max_width, geometry->max_height));
     }
 
-  if (geom_mask & GDK_HINT_ASPECT)
-    {
-      GDK_NOTE (MISC, g_print ("... ASPECT: %g--%g\n",
-                              geometry->min_aspect, geometry->max_aspect));
-    }
-
   if (geom_mask & GDK_HINT_WIN_GRAVITY)
     {
       GDK_NOTE (MISC, g_print ("... GRAVITY: %d\n", geometry->win_gravity));
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index f316872d57..8552a183ac 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -2182,31 +2182,6 @@ gdk_x11_surface_set_geometry_hints (GdkSurface         *surface,
       size_hints.height_inc = impl->surface_scale;
     }
 
-  if (geom_mask & GDK_HINT_ASPECT)
-    {
-      size_hints.flags |= PAspect;
-      if (geometry->min_aspect <= 1)
-       {
-         size_hints.min_aspect.x = 65536 * geometry->min_aspect;
-         size_hints.min_aspect.y = 65536;
-       }
-      else
-       {
-         size_hints.min_aspect.x = 65536;
-         size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
-       }
-      if (geometry->max_aspect <= 1)
-       {
-         size_hints.max_aspect.x = 65536 * geometry->max_aspect;
-         size_hints.max_aspect.y = 65536;
-       }
-      else
-       {
-         size_hints.max_aspect.x = 65536;
-         size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
-       }
-    }
-
   if (geom_mask & GDK_HINT_WIN_GRAVITY)
     {
       size_hints.flags |= PWinGravity;
@@ -2265,14 +2240,6 @@ gdk_surface_get_geometry_hints (GdkSurface      *surface,
       geometry->max_height = MAX (size_hints->max_height, 1) / impl->surface_scale;
     }
 
-  if (size_hints->flags & PAspect)
-    {
-      *geom_mask |= GDK_HINT_ASPECT;
-
-      geometry->min_aspect = (double) size_hints->min_aspect.x / (double) size_hints->min_aspect.y;
-      geometry->max_aspect = (double) size_hints->max_aspect.x / (double) size_hints->max_aspect.y;
-    }
-
   if (size_hints->flags & PWinGravity)
     {
       *geom_mask |= GDK_HINT_WIN_GRAVITY;
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 5df8e9abd1..f52986fe03 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5651,11 +5651,6 @@ gtk_window_compare_hints (GdkGeometry *geometry_a,
        geometry_a->max_height != geometry_b->max_height))
     return FALSE;
 
-  if ((flags_a & GDK_HINT_ASPECT) &&
-      (geometry_a->min_aspect != geometry_b->min_aspect ||
-       geometry_a->max_aspect != geometry_b->max_aspect))
-    return FALSE;
-
   if ((flags_a & GDK_HINT_WIN_GRAVITY) &&
       geometry_a->win_gravity != geometry_b->win_gravity)
     return FALSE;


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