Module: wine Branch: master Commit: 304ab65dbf0f143df5c92923c3b93cbeecb40d1a URL: http://source.winehq.org/git/wine.git/?a=commit;h=304ab65dbf0f143df5c92923c3...
Author: Ken Thomases ken@codeweavers.com Date: Thu Dec 12 16:49:44 2013 -0600
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.
---
dlls/user32/misc.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/misc.c b/dlls/user32/misc.c index 732d11c..eb2631f 100644 --- a/dlls/user32/misc.c +++ b/dlls/user32/misc.c @@ -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) {