summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2012-10-18 13:25:56 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-18 21:50:27 +0200
commit0221d769c76e50d8b331c2cdf527110b62cb3e66 (patch)
treef0b59dfaedfaf67078714bd4441f14136aff907b /src/plugins/platforms
parentf45afd71551a6cd1553952ea003e9356651809b5 (diff)
Cocoa: fix frameStrutMouseEvents
It turns out that the calculation of mouse pos over the frame strut (title bar) was wrong. When outside the content view, the nsevent coordinates are negative, so to get this correct, we need to calculate the height of the window above the content view and use this information to get the mouse pos in positive coordinates with origin window top left. This bug was especially apperent with QDockWidget, as it became almost impossible to dock a window under such circumstances. Change-Id: I2faf6aab5e2aa0b4e217ea087ceec8c1b1e978bb Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index f4ba8154ca..33d0fb4bae 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -358,11 +358,15 @@ static QTouchDevice *touchDevice = 0;
}
NSWindow *window = [self window];
- int windowHeight = [window frame].size.height;
NSPoint windowPoint = [theEvent locationInWindow];
+
+ int windowScreenY = [window frame].origin.y + [window frame].size.height;
+ int viewScreenY = [window convertBaseToScreen:[self convertPoint:[self frame].origin toView:nil]].y;
+ int titleBarHeight = windowScreenY - viewScreenY;
+
NSPoint nsViewPoint = [self convertPoint: windowPoint fromView: nil];
- QPoint qtWindowPoint = QPoint(nsViewPoint.x, windowHeight - nsViewPoint.y);
- NSPoint screenPoint = [window convertBaseToScreen : windowPoint];
+ QPoint qtWindowPoint = QPoint(nsViewPoint.x, titleBarHeight + nsViewPoint.y);
+ NSPoint screenPoint = [window convertBaseToScreen:windowPoint];
QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
ulong timestamp = [theEvent timestamp] * 1000;