[gtk/wip/otte/geometry: 1/4] gdk: Remove base_size and increment from GdkGeometry




commit 3641252c383f3eba2234d70dc84adfce47745444
Author: Benjamin Otte <otte redhat com>
Date:   Thu Jul 30 04:42:11 2020 +0200

    gdk: Remove base_size and increment from GdkGeometry
    
    It's unused.

 gdk/gdkinternals.h               |  6 ---
 gdk/gdksurface.c                 | 61 +++------------------------
 gdk/macos/gdkmacossurface.c      |  8 ----
 gdk/wayland/gdksurface-wayland.c |  3 --
 gdk/win32/gdkevents-win32.c      | 89 ----------------------------------------
 gdk/win32/gdksurface-win32.c     | 12 ------
 gdk/x11/gdksurface-x11.c         | 23 +----------
 gtk/gtkwindow.c                  | 54 ++----------------------
 8 files changed, 9 insertions(+), 247 deletions(-)
---
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index b21c74a55d..a208e9c568 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -299,9 +299,7 @@ typedef enum
   GDK_HINT_POS         = 1 << 0,
   GDK_HINT_MIN_SIZE    = 1 << 1,
   GDK_HINT_MAX_SIZE    = 1 << 2,
-  GDK_HINT_BASE_SIZE   = 1 << 3,
   GDK_HINT_ASPECT      = 1 << 4,
-  GDK_HINT_RESIZE_INC  = 1 << 5,
   GDK_HINT_WIN_GRAVITY = 1 << 6,
   GDK_HINT_USER_POS    = 1 << 7,
   GDK_HINT_USER_SIZE   = 1 << 8
@@ -333,10 +331,6 @@ struct _GdkGeometry
   int min_height;
   int max_width;
   int max_height;
-  int base_width;
-  int base_height;
-  int width_inc;
-  int height_inc;
   double min_aspect;
   double max_aspect;
   GdkGravity win_gravity;
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 62fc8196f6..82761c3af2 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -1588,33 +1588,11 @@ gdk_surface_constrain_size (GdkGeometry    *geometry,
    */
   int min_width = 0;
   int min_height = 0;
-  int base_width = 0;
-  int base_height = 0;
-  int xinc = 1;
-  int yinc = 1;
   int max_width = G_MAXINT;
   int max_height = G_MAXINT;
 
-#define FLOOR(value, base)      ( ((int) ((value) / (base))) * (base) )
-
-  if ((flags & GDK_HINT_BASE_SIZE) && (flags & GDK_HINT_MIN_SIZE))
-    {
-      base_width = geometry->base_width;
-      base_height = geometry->base_height;
-      min_width = geometry->min_width;
-      min_height = geometry->min_height;
-    }
-  else if (flags & GDK_HINT_BASE_SIZE)
+  if (flags & GDK_HINT_MIN_SIZE)
     {
-      base_width = geometry->base_width;
-      base_height = geometry->base_height;
-      min_width = geometry->base_width;
-      min_height = geometry->base_height;
-    }
-  else if (flags & GDK_HINT_MIN_SIZE)
-    {
-      base_width = geometry->min_width;
-      base_height = geometry->min_height;
       min_width = geometry->min_width;
       min_height = geometry->min_height;
     }
@@ -1625,22 +1603,11 @@ gdk_surface_constrain_size (GdkGeometry    *geometry,
       max_height = geometry->max_height;
     }
 
-  if (flags & GDK_HINT_RESIZE_INC)
-    {
-      xinc = MAX (xinc, geometry->width_inc);
-      yinc = MAX (yinc, geometry->height_inc);
-    }
-
   /* clamp width and height to min and max values
    */
   width = CLAMP (width, min_width, max_width);
   height = CLAMP (height, min_height, max_height);
 
-  /* shrink to base + N * inc
-   */
-  width = base_width + FLOOR (width - base_width, xinc);
-  height = base_height + FLOOR (height - base_height, yinc);
-
   /* constrain aspect ratio, according to:
    *
    *                width
@@ -1654,24 +1621,14 @@ gdk_surface_constrain_size (GdkGeometry    *geometry,
     {
       int delta;
 
-      if (flags & GDK_HINT_BASE_SIZE)
-        {
-          width -= base_width;
-          height -= base_height;
-          min_width -= base_width;
-          min_height -= base_height;
-          max_width -= base_width;
-          max_height -= base_height;
-        }
-
       if (geometry->min_aspect * height > width)
         {
-          delta = FLOOR (height - width / geometry->min_aspect, yinc);
+          delta = height - width / geometry->min_aspect;
           if (height - delta >= min_height)
             height -= delta;
           else
             {
-              delta = FLOOR (height * geometry->min_aspect - width, xinc);
+              delta = height * geometry->min_aspect - width;
               if (width + delta <= max_width)
                 width += delta;
             }
@@ -1679,26 +1636,18 @@ gdk_surface_constrain_size (GdkGeometry    *geometry,
 
       if (geometry->max_aspect * height < width)
         {
-          delta = FLOOR (width - height * geometry->max_aspect, xinc);
+          delta = width - height * geometry->max_aspect;
           if (width - delta >= min_width)
             width -= delta;
           else
             {
-              delta = FLOOR (width / geometry->max_aspect - height, yinc);
+              delta = width / geometry->max_aspect - height;
               if (height + delta <= max_height)
                 height += delta;
             }
         }
-
-      if (flags & GDK_HINT_BASE_SIZE)
-        {
-          width += base_width;
-          height += base_height;
-        }
     }
 
-#undef FLOOR
-
   *new_width = width;
   *new_height = height;
 }
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index 1c0cdc12e9..4e8dad5473 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -639,14 +639,6 @@ _gdk_macos_surface_set_geometry_hints (GdkMacosSurface   *self,
     min_size = NSMakeSize (1, 1);
   [self->window setContentMinSize:min_size];
 
-  if (geom_mask & GDK_HINT_BASE_SIZE) { /* TODO */ }
-
-  if (geom_mask & GDK_HINT_RESIZE_INC)
-    {
-      NSSize size = NSMakeSize (geometry->width_inc, geometry->height_inc);
-      [self->window setContentResizeIncrements:size];
-    }
-
   if (geom_mask & GDK_HINT_ASPECT)
     {
       NSSize size;
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 2883b61947..d30d7a8a12 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -1306,9 +1306,6 @@ gdk_wayland_surface_configure_toplevel (GdkSurface *surface)
     {
       GdkSurfaceHints geometry_mask = impl->geometry_mask;
 
-      /* Ignore size increments for maximized/fullscreen surfaces */
-      if (fixed_size)
-        geometry_mask &= ~GDK_HINT_RESIZE_INC;
       if (!saved_size)
         {
           /* Do not reapply constrains if we are restoring original size */
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 67a52e69b1..e028684def 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -3175,95 +3175,6 @@ gdk_event_translate (MSG *msg,
 
       impl = GDK_WIN32_SURFACE (window);
       orig_drag = *drag;
-      if (impl->hint_flags & GDK_HINT_RESIZE_INC)
-       {
-         GDK_NOTE (EVENTS, g_print (" (RESIZE_INC)"));
-         if (impl->hint_flags & GDK_HINT_BASE_SIZE)
-           {
-             /* Resize in increments relative to the base size */
-             rect.left = rect.top = 0;
-             rect.right = impl->hints.base_width * impl->surface_scale;
-             rect.bottom = impl->hints.base_height * impl->surface_scale;
-             _gdk_win32_adjust_client_rect (window, &rect);
-             point.x = rect.left;
-             point.y = rect.top;
-             ClientToScreen (GDK_SURFACE_HWND (window), &point);
-             rect.left = point.x;
-             rect.top = point.y;
-             point.x = rect.right;
-             point.y = rect.bottom;
-             ClientToScreen (GDK_SURFACE_HWND (window), &point);
-             rect.right = point.x;
-             rect.bottom = point.y;
-
-             GDK_NOTE (EVENTS, g_print (" (also BASE_SIZE, using %s)",
-                                        _gdk_win32_rect_to_string (&rect)));
-           }
-
-         switch (msg->wParam)
-           {
-           case WMSZ_BOTTOM:
-             if (drag->bottom == rect.bottom)
-               break;
-        adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc * impl->surface_scale);
-             break;
-
-           case WMSZ_BOTTOMLEFT:
-             if (drag->bottom == rect.bottom && drag->left == rect.left)
-               break;
-             adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc * impl->surface_scale);
-             adjust_drag (&drag->left, rect.left, impl->hints.width_inc * impl->surface_scale);
-             break;
-
-           case WMSZ_LEFT:
-             if (drag->left == rect.left)
-               break;
-             adjust_drag (&drag->left, rect.left, impl->hints.width_inc * impl->surface_scale);
-             break;
-
-           case WMSZ_TOPLEFT:
-             if (drag->top == rect.top && drag->left == rect.left)
-               break;
-             adjust_drag (&drag->top, rect.top, impl->hints.height_inc * impl->surface_scale);
-             adjust_drag (&drag->left, rect.left, impl->hints.width_inc * impl->surface_scale);
-             break;
-
-           case WMSZ_TOP:
-             if (drag->top == rect.top)
-               break;
-             adjust_drag (&drag->top, rect.top, impl->hints.height_inc * impl->surface_scale);
-             break;
-
-           case WMSZ_TOPRIGHT:
-             if (drag->top == rect.top && drag->right == rect.right)
-               break;
-             adjust_drag (&drag->top, rect.top, impl->hints.height_inc * impl->surface_scale);
-             adjust_drag (&drag->right, rect.right, impl->hints.width_inc * impl->surface_scale);
-             break;
-
-           case WMSZ_RIGHT:
-             if (drag->right == rect.right)
-               break;
-             adjust_drag (&drag->right, rect.right, impl->hints.width_inc * impl->surface_scale);
-             break;
-
-           case WMSZ_BOTTOMRIGHT:
-             if (drag->bottom == rect.bottom && drag->right == rect.right)
-               break;
-             adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc * impl->surface_scale);
-             adjust_drag (&drag->right, rect.right, impl->hints.width_inc * impl->surface_scale);
-             break;
-           }
-
-         if (drag->bottom != orig_drag.bottom || drag->left != orig_drag.left ||
-             drag->top != orig_drag.top || drag->right != orig_drag.right)
-           {
-             *ret_valp = TRUE;
-             return_val = TRUE;
-             GDK_NOTE (EVENTS, g_print (" (handled RESIZE_INC: %s)",
-                                        _gdk_win32_rect_to_string (drag)));
-           }
-       }
 
       /* WM_GETMINMAXINFO handles min_size and max_size hints? */
 
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index 4ae96c7c62..a28c8a1049 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -1509,18 +1509,6 @@ gdk_win32_surface_set_geometry_hints (GdkSurface         *window,
                               geometry->max_width, geometry->max_height));
     }
 
-  if (geom_mask & GDK_HINT_BASE_SIZE)
-    {
-      GDK_NOTE (MISC, g_print ("... BASE_SIZE: %dx%d\n",
-                              geometry->base_width, geometry->base_height));
-    }
-
-  if (geom_mask & GDK_HINT_RESIZE_INC)
-    {
-      GDK_NOTE (MISC, g_print ("... RESIZE_INC: (%d,%d)\n",
-                              geometry->width_inc, geometry->height_inc));
-    }
-
   if (geom_mask & GDK_HINT_ASPECT)
     {
       GDK_NOTE (MISC, g_print ("... ASPECT: %g--%g\n",
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 385a5c0ccd..bccdbc3df7 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -1723,8 +1723,7 @@ _gdk_x11_surface_set_surface_scale (GdkSurface *surface,
   if (toplevel)
     {
       /* These are affected by surface scale: */
-      geom_mask = toplevel->last_geometry_hints_mask &
-        (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC);
+      geom_mask = toplevel->last_geometry_hints_mask & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
       if (geom_mask)
         gdk_x11_surface_set_geometry_hints (surface,
                                             &toplevel->last_geometry_hints,
@@ -2186,19 +2185,6 @@ gdk_x11_surface_set_geometry_hints (GdkSurface         *surface,
       size_hints.max_height = MAX (geometry->max_height, 1) * impl->surface_scale;
     }
   
-  if (geom_mask & GDK_HINT_BASE_SIZE)
-    {
-      size_hints.flags |= PBaseSize;
-      size_hints.base_width = geometry->base_width * impl->surface_scale;
-      size_hints.base_height = geometry->base_height * impl->surface_scale;
-    }
-  
-  if (geom_mask & GDK_HINT_RESIZE_INC)
-    {
-      size_hints.flags |= PResizeInc;
-      size_hints.width_inc = geometry->width_inc * impl->surface_scale;
-      size_hints.height_inc = geometry->height_inc * impl->surface_scale;
-    }
   else if (impl->surface_scale > 1)
     {
       size_hints.flags |= PResizeInc;
@@ -2289,13 +2275,6 @@ gdk_surface_get_geometry_hints (GdkSurface      *surface,
       geometry->max_height = MAX (size_hints->max_height, 1) / impl->surface_scale;
     }
 
-  if (size_hints->flags & PResizeInc)
-    {
-      *geom_mask |= GDK_HINT_RESIZE_INC;
-      geometry->width_inc = size_hints->width_inc / impl->surface_scale;
-      geometry->height_inc = size_hints->height_inc / impl->surface_scale;
-    }
-
   if (size_hints->flags & PAspect)
     {
       *geom_mask |= GDK_HINT_ASPECT;
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 80dde36493..5df8e9abd1 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -416,13 +416,6 @@ static gboolean gtk_window_compare_hints             (GdkGeometry  *geometry_a,
                                                       guint         flags_a,
                                                       GdkGeometry  *geometry_b,
                                                       guint         flags_b);
-static void     gtk_window_constrain_size            (GtkWindow    *window,
-                                                      GdkGeometry  *geometry,
-                                                      guint         flags,
-                                                      int           width,
-                                                      int           height,
-                                                      int          *new_width,
-                                                      int          *new_height);
 static void     gtk_window_update_fixed_size         (GtkWindow    *window,
                                                       GdkGeometry  *new_geometry,
                                                       int           new_width,
@@ -5304,10 +5297,9 @@ gtk_window_compute_configure_request (GtkWindow    *window,
                                              new_flags,
                                              &w, &h);
   gtk_window_update_fixed_size (window, &new_geometry, w, h);
-  gtk_window_constrain_size (window,
-                             &new_geometry, new_flags,
-                             w, h,
-                             &w, &h);
+  gdk_surface_constrain_size (&new_geometry, new_flags,
+                              w, h,
+                              &w, &h);
 
   info = gtk_window_get_geometry_info (window, FALSE);
 
@@ -5659,21 +5651,11 @@ gtk_window_compare_hints (GdkGeometry *geometry_a,
        geometry_a->max_height != geometry_b->max_height))
     return FALSE;
 
-  if ((flags_a & GDK_HINT_BASE_SIZE) &&
-      (geometry_a->base_width != geometry_b->base_width ||
-       geometry_a->base_height != geometry_b->base_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_RESIZE_INC) &&
-      (geometry_a->width_inc != geometry_b->width_inc ||
-       geometry_a->height_inc != geometry_b->height_inc))
-    return FALSE;
-
   if ((flags_a & GDK_HINT_WIN_GRAVITY) &&
       geometry_a->win_gravity != geometry_b->win_gravity)
     return FALSE;
@@ -5681,28 +5663,6 @@ gtk_window_compare_hints (GdkGeometry *geometry_a,
   return TRUE;
 }
 
-static void 
-gtk_window_constrain_size (GtkWindow   *window,
-                          GdkGeometry *geometry,
-                          guint        flags,
-                          int          width,
-                          int          height,
-                          int         *new_width,
-                          int         *new_height)
-{
-  GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
-  guint geometry_flags;
-
-  /* ignore size increments for windows that fit in a fixed space */
-  if (priv->maximized || priv->fullscreen || priv->tiled)
-    geometry_flags = flags & ~GDK_HINT_RESIZE_INC;
-  else
-    geometry_flags = flags;
-
-  gdk_surface_constrain_size (geometry, geometry_flags, width, height,
-                             new_width, new_height);
-}
-
 /* For non-resizable windows, make sure the given width/height fits
  * in the geometry constrains and update the geometry hints to match
  * the given width/height if not.
@@ -5782,14 +5742,6 @@ gtk_window_compute_hints (GtkWindow   *window,
    */
   *new_flags = 0;
   
-  /* For simplicity, we always set the base hint, even when we
-   * don't expect it to have any visible effect.
-   * (Note: geometry_size_to_pixels() depends on this.)
-   */
-  *new_flags |= GDK_HINT_BASE_SIZE;
-  new_geometry->base_width = 0;
-  new_geometry->base_height = 0;
-
   get_shadow_width (window, &shadow);
   *new_flags |= GDK_HINT_MIN_SIZE;
   new_geometry->min_width = requisition.width + shadow.left + shadow.right;


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