Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.5.0
-
OS X 10.10.4, two displays with different screen resolutions
Description
Found this issue during testing full screen mode on system with 2 displays.
Switching back from full screen mode on 2nd display leads to wrong window position (window title bar overlapped by OS X menu bar). Full screen mode is a game like - no Qt::WindowFullscreenButtonHint flag set.
Screens have different resolutions and bottom lines are not aligned one to another (this is important).
In the code below QPlatformScreen *onScreen has width and height as the sum of widths and heights of all screens (empiric finding). In case bottom lines of both screens are not aligned the calculated "flippedY" contains wrong value.
QCocoaWindow.mm
// Returns the current global screen geometry for the nswindow associated with this window. QRect QCocoaWindow::windowGeometry() const { if (!m_nsWindow || m_isNSWindowChild) return geometry(); NSRect rect = [m_nsWindow frame]; QPlatformScreen *onScreen = PlatformScreen::platformScreenForWindow(window()); int flippedY = onScreen->geometry().height() - rect.origin.y - rect.size.height; // account for nswindow inverted y. QRect qRect = QRect(rect.origin.x, flippedY, rect.size.width, rect.size.height); return qRect; }
Replacing code:
QPlatformScreen *onScreen = PlatformScreen::platformScreenForWindow(window()); int flippedY = onScreen->geometry().height() - rect.origin.y - rect.size.height; // account for nswindow inverted y.
with this:
NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0]; int flippedY = [primaryScreen frame].size.height - rect.origin.y - rect.size.height; // account for nswindow inverted y.
Made everything working fine.
Attachments
For Gerrit Dashboard: QTBUG-47462 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
170576,1 | Cocoa: fixed window geometry calculation for multiple screens | dev | qt/qtbase | Status: ABANDONED | +1 | 0 |