forked from AuroraMiddleware/gtk
Remove aspect ratio from GdkGeometry
It's unused.
This commit is contained in:
parent
ebcef256ab
commit
11db6ad574
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */ }
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user