Popmenu opens at wrong display - multiscreen setup

Hi Jules,

i’m using the latest version from SVN. I opening a popup menu in my plugin ( with show and showAt ). When i click on the first monitor, it appears on the second.

That was not the case with an earlier version.

With the old version of Desktop::getMonitorAreaContaining (changed on 15.Nov) the problem does not happen.

[code]/* !new version

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));
    const double distance = juce_hypot ((double) (rect.getCentreX() - cx), 
                                        (double) (rect.getCentreY() - cy));

    if (distance < bestDistance)
    {
        bestDistance = distance;
        best = rect;
    }
}

return best;

}*/

const Rectangle Desktop::getMonitorAreaContaining (int cx, int cy, const bool clippedToWorkArea) const throw()
{

for (int i = getNumDisplayMonitors(); --i > 0;)
{
    const Rectangle rect (getDisplayMonitorCoordinates (i, clippedToWorkArea));



    if (rect.contains (cx, cy))
        return rect;



}

return getMainMonitorArea (clippedToWorkArea);

}[/code]

Oh sorry, I was trying something out there… What I meant was this:

[code] 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;
    }
}[/code]

mmmh, does not work

did you mean:

instead of

:wink:

well done, you spotted my deliberate mistake there…