Commit 304ab65d authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

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.
parent 09b817aa
......@@ -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;
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;
UINT x, y;
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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment