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>
This commit is contained in:
parent
f45afd7155
commit
0221d769c7
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user