Bounds and Two Screens


#1

Hello,

I have an issue when two screens are connected to my MacbookPro. I will try to be as accurate as possible.

MacbookPro (1280x800)
Other Screen (1900x1600)

The mainWindow Application is normally set to x = 0 and y = 0 .

Setting bounds of the mainWindow calls constrainFrameRect:NSRect toScreen: NSScreen, which is overriden by JuceNSWindow.

The issue here is with the checkBounds function and with the area where bounds are limited :

            constrainer->checkBounds (pos, original,
                                      Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(),
                                      pos.getY() != original.getY() && pos.getBottom() == original.getBottom(),
                                      pos.getX() != original.getX() && pos.getRight() == original.getRight(),
                                      pos.getY() == original.getY() && pos.getBottom() != original.getBottom(),
                                      pos.getX() == original.getX() && pos.getRight() != original.getRight());

In this call, you set the limits by considering all the MonitorDisplayAreas. For One screen, there is no problem since y = 0 will be considered as the top left edge of the main screen.
But with my two screens connected, this will not be the case and the mainWindow will be set Behind the Mac native menu bar.

I identified this issue in both Juce 1.53 and Juce 2.0, do you have a trick to avoid this ?

Thanks in advance

Nordhal


#2

The current code is completely different to what you’ve posted there - did you check the latest version?


#3

Ok, I just Gitted (pretty verb, isn’t it? ) the last Juce Repo, and I have the same issue.

In NSVIewComponentPeer : constrainRect (NSRect)

            const Rectangle<int> screenBounds (Desktop::getInstance().getDisplays().getTotalBounds (true));

Seems to retrieve the total Rectangle of the two screens, whereas the topLeft position of each screen is not at the same y coordinate.

IMPORTANT: I did not know why in your juceDemo, the window (if I set bounds at (0,0) ) really was at the top left of the screen, regardless the menu bar (i.e. behind the menu bar), even if I have one screen. (It was because it does not use the native title bar)
To have an automatic call to constrainFramRect: ToScreen , you need to set the native title bar.
In this case, when your mainWindow is bounded to (0,0, w, h), it appears just below the menuBar (for one screen), and behind the menuBar (with two screens at different Resolution)


#4

Yeah… I guess it really needs a smarter algorithm than just clipping to the union of all the monitor rectangles. It’s quite a tricky problem, actually… I’ll have a think.