Rectangle<int> Desktop::getMonitorAreaContaining (const Point<int>& position, const bool clippedToWorkArea) const { Rectangle<int> best (getMainMonitorArea (clippedToWorkArea)); double bestDistance = 1.0e10; for (int i = getNumDisplayMonitors(); --i >= 0;) { const Rectangle<int> rect (getDisplayMonitorCoordinates (i, clippedToWorkArea)); if (rect.contains (position)) return rect; const double distance = rect.getCentre().getDistanceFrom (position); if (distance < bestDistance) { bestDistance = distance; best = rect; } } return best; }
const Rectangle Desktop::getMonitorAreaContaining (int cx, int cy, const bool clippedToWorkArea) const throw() { Rectangle best (getMainMonitorArea (clippedToWorkArea)); double bestDistance = 1.0e10; for (int i = getNumDisplayMonitors(); --i >= 0;) { const Rectangle rect (getDisplayMonitorCoordinates (i, clippedToWorkArea)); if (rect.contains (cx, cy)) return rect; const double distance = juce_hypot ((double) (rect.getCentreX() - cx), (double) (rect.getCentreY() - cy)); if (distance < bestDistance) { bestDistance = distance; best = rect; } } return best; }