summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMorten Johan Sorvig <morten.sorvig@nokia.com>2011-12-12 10:32:03 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-15 21:04:27 +0100
commitc13b223979833327fc70f65ae6a847ef7142c847 (patch)
tree3c0844bbfe4c07148c6e49e13bc0f8f63c42140d /src/plugins
parent92667d14a48cb8d32290d2845eb5519645109fdc (diff)
Cocoa: Add version check for convertRectToScreen.
convertRectToScreen was added in 10.7, use convertBaseToScreen on 10.6 Change-Id: Ica1ee0f62e1fc9b0d5ccf463419496684da779b7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 1a1e02d2fd..567e893a55 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -229,14 +229,19 @@ static QTouchDevice *touchDevice = 0;
QPoint qtWindowPoint(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates
QPoint qtScreenPoint;
-#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6
- NSRect screenRect = [[self window] convertRectToScreen : NSMakeRect(nsWindowPoint.x, nsWindowPoint.y, 0, 0)]; // OS X screen coordinates
- qtScreenPoint = QPoint(screenRect.origin.x, qt_mac_flipYCoordinate(screenRect.origin.y)); // Qt screen coordinates
-#else
- NSPoint screenPoint = [[self window] convertBaseToScreen : NSMakePoint(nsWindowPoint.x, nsWindowPoint.y)];
- qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
-#endif
+ NSWindow *window = [self window];
+ // Use convertRectToScreen if available (added in 10.7).
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+ if ([window respondsToSelector:@selector(convertRectToScreen:)]) {
+ NSRect screenRect = [window convertRectToScreen : NSMakeRect(nsWindowPoint.x, nsWindowPoint.y, 0, 0)]; // OS X screen coordinates
+ qtScreenPoint = QPoint(screenRect.origin.x, qt_mac_flipYCoordinate(screenRect.origin.y)); // Qt screen coordinates
+ } else
+#endif
+ {
+ NSPoint screenPoint = [window convertBaseToScreen : NSMakePoint(nsWindowPoint.x, nsWindowPoint.y)];
+ qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
+ }
ulong timestamp = [theEvent timestamp] * 1000;
QWindowSystemInterface::handleMouseEvent(m_window, timestamp, qtWindowPoint, qtScreenPoint, m_buttons);