Cocoa: Get mouse position from the event
We want the coordinates for a mouse event to be the position at the time of event generation, not the current position. This is a followup to 39be577c which fixed this for some cases. This commit replaces all usages of [NSEvent mouseLocation] with code that gets the location from the event. Change-Id: I691a46a61ce65e2b33335453b5b22de01f76d767 Task-id: QTBUG-54399 Task-id: QTBUG-37926 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
6af82fe9fd
commit
e3cbf0f196
@ -1134,7 +1134,7 @@ QT_WARNING_POP
|
|||||||
|
|
||||||
QPointF windowPoint;
|
QPointF windowPoint;
|
||||||
QPointF screenPoint;
|
QPointF screenPoint;
|
||||||
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
[self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||||
m_platformWindow->m_enterLeaveTargetWindow = m_platformWindow->childWindowAt(windowPoint.toPoint());
|
m_platformWindow->m_enterLeaveTargetWindow = m_platformWindow->childWindowAt(windowPoint.toPoint());
|
||||||
QWindowSystemInterface::handleEnterEvent(m_platformWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
|
QWindowSystemInterface::handleEnterEvent(m_platformWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
|
||||||
}
|
}
|
||||||
@ -1176,7 +1176,7 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash)
|
|||||||
|
|
||||||
QPointF windowPoint;
|
QPointF windowPoint;
|
||||||
QPointF screenPoint;
|
QPointF screenPoint;
|
||||||
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint: &windowPoint andScreenPoint: &screenPoint];
|
[self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint: &windowPoint andScreenPoint: &screenPoint];
|
||||||
|
|
||||||
uint deviceId = [theEvent deviceID];
|
uint deviceId = [theEvent deviceID];
|
||||||
if (!tabletDeviceDataHash->contains(deviceId)) {
|
if (!tabletDeviceDataHash->contains(deviceId)) {
|
||||||
@ -1391,7 +1391,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
const NSTimeInterval timestamp = [event timestamp];
|
const NSTimeInterval timestamp = [event timestamp];
|
||||||
QPointF windowPoint;
|
QPointF windowPoint;
|
||||||
QPointF screenPoint;
|
QPointF screenPoint;
|
||||||
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||||
QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::ZoomNativeGesture,
|
QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::ZoomNativeGesture,
|
||||||
[event magnification], windowPoint, screenPoint);
|
[event magnification], windowPoint, screenPoint);
|
||||||
}
|
}
|
||||||
@ -1404,7 +1404,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
const NSTimeInterval timestamp = [event timestamp];
|
const NSTimeInterval timestamp = [event timestamp];
|
||||||
QPointF windowPoint;
|
QPointF windowPoint;
|
||||||
QPointF screenPoint;
|
QPointF screenPoint;
|
||||||
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||||
QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::SmartZoomNativeGesture,
|
QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::SmartZoomNativeGesture,
|
||||||
zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint);
|
zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint);
|
||||||
zoomIn = !zoomIn;
|
zoomIn = !zoomIn;
|
||||||
@ -1419,7 +1419,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
const NSTimeInterval timestamp = [event timestamp];
|
const NSTimeInterval timestamp = [event timestamp];
|
||||||
QPointF windowPoint;
|
QPointF windowPoint;
|
||||||
QPointF screenPoint;
|
QPointF screenPoint;
|
||||||
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||||
QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::RotateNativeGesture,
|
QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::RotateNativeGesture,
|
||||||
-[event rotation], windowPoint, screenPoint);
|
-[event rotation], windowPoint, screenPoint);
|
||||||
}
|
}
|
||||||
@ -1430,7 +1430,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
const NSTimeInterval timestamp = [event timestamp];
|
const NSTimeInterval timestamp = [event timestamp];
|
||||||
QPointF windowPoint;
|
QPointF windowPoint;
|
||||||
QPointF screenPoint;
|
QPointF screenPoint;
|
||||||
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||||
|
|
||||||
qreal angle = 0.0f;
|
qreal angle = 0.0f;
|
||||||
if ([event deltaX] == 1)
|
if ([event deltaX] == 1)
|
||||||
@ -1451,7 +1451,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
const NSTimeInterval timestamp = [event timestamp];
|
const NSTimeInterval timestamp = [event timestamp];
|
||||||
QPointF windowPoint;
|
QPointF windowPoint;
|
||||||
QPointF screenPoint;
|
QPointF screenPoint;
|
||||||
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||||
qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint;
|
qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint;
|
||||||
QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::BeginNativeGesture,
|
QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::BeginNativeGesture,
|
||||||
windowPoint, screenPoint);
|
windowPoint, screenPoint);
|
||||||
@ -1463,7 +1463,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
const NSTimeInterval timestamp = [event timestamp];
|
const NSTimeInterval timestamp = [event timestamp];
|
||||||
QPointF windowPoint;
|
QPointF windowPoint;
|
||||||
QPointF screenPoint;
|
QPointF screenPoint;
|
||||||
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||||
QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::EndNativeGesture,
|
QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::EndNativeGesture,
|
||||||
windowPoint, screenPoint);
|
windowPoint, screenPoint);
|
||||||
}
|
}
|
||||||
@ -1507,7 +1507,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
|
|
||||||
QPointF qt_windowPoint;
|
QPointF qt_windowPoint;
|
||||||
QPointF qt_screenPoint;
|
QPointF qt_screenPoint;
|
||||||
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&qt_windowPoint andScreenPoint:&qt_screenPoint];
|
[self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&qt_windowPoint andScreenPoint:&qt_screenPoint];
|
||||||
NSTimeInterval timestamp = [theEvent timestamp];
|
NSTimeInterval timestamp = [theEvent timestamp];
|
||||||
ulong qt_timestamp = timestamp * 1000;
|
ulong qt_timestamp = timestamp * 1000;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user