user32: Fix distance calculation for MONITOR_DEFAULTTONEAREST.

If the target rect is outside a monitor rect but is between its extremes in
one dimension, that dimension should contribute 0 to the distance, rather than
some arbitrary amount.
This commit is contained in:
Ken Thomases 2013-12-12 16:49:44 -06:00 committed by Alexandre Julliard
parent 09b817aaf8
commit 304ab65dbf

View File

@ -321,12 +321,14 @@ static BOOL CALLBACK monitor_enum( HMONITOR monitor, HDC hdc, LPRECT rect, LPARA
else if (!info->max_area) /* if not intersecting, check for min distance */
{
UINT distance;
INT x, y;
UINT x, y;
if (rect->left >= info->rect.right) x = info->rect.right - rect->left;
else x = rect->right - info->rect.left;
if (rect->top >= info->rect.bottom) y = info->rect.bottom - rect->top;
else y = rect->bottom - info->rect.top;
if (info->rect.right <= rect->left) x = rect->left - info->rect.right;
else if (rect->right <= info->rect.left) x = info->rect.left - rect->right;
else x = 0;
if (info->rect.bottom <= rect->top) y = rect->top - info->rect.bottom;
else if (rect->bottom <= info->rect.top) y = info->rect.top - rect->bottom;
else y = 0;
distance = x * x + y * y;
if (distance < info->min_distance)
{