Fix macOS mouse positions inaccuracy

Don't use the current mouse position at the time the event is handled, but
rather the position at the time of the event. This should make e.g. brush
stroke paths more accurate.

In addition, this may solve issues with other software that does mouse
position smoothing. Ref T82143.

Use of the current mouse position was added in 12b642062c as part of a
large commit that also made continuous grab work. But it appears to still
work getting the mouse position from the event.
This commit is contained in:
Brecht Van Lommel 2020-10-29 22:15:05 +01:00
parent 4a8146eb8f
commit 9e85812acc
Notes: blender-bot 2023-02-14 11:21:40 +01:00
Referenced by issue #82870, Continuous grab is broken 2.92.0 Alpha macOS
Referenced by issue #82250, Console warnings when accessing subtype and default values of properties with python
Referenced by issue #82143, Hej Stylus! (Tablet configuration tool) and Blender issues
1 changed files with 6 additions and 6 deletions

View File

@ -1589,7 +1589,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
}
case GHOST_kGrabWrap: // Wrap cursor at area/window boundaries
{
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
NSPoint mousePos = [event locationInWindow];
GHOST_TInt32 x_mouse = mousePos.x;
GHOST_TInt32 y_mouse = mousePos.y;
GHOST_Rect bounds, windowBounds, correctedBounds;
@ -1639,7 +1639,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
}
default: {
// Normal cursor operation: send mouse position in window
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
NSPoint mousePos = [event locationInWindow];
GHOST_TInt32 x, y;
window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
@ -1699,7 +1699,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
pushEvent(new GHOST_EventWheel([event timestamp] * 1000, window, delta));
}
else {
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
NSPoint mousePos = [event locationInWindow];
GHOST_TInt32 x, y;
double dx;
double dy;
@ -1722,7 +1722,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
} break;
case NSEventTypeMagnify: {
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
NSPoint mousePos = [event locationInWindow];
GHOST_TInt32 x, y;
window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000,
@ -1735,7 +1735,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
} break;
case NSEventTypeSmartMagnify: {
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
NSPoint mousePos = [event locationInWindow];
GHOST_TInt32 x, y;
window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
pushEvent(new GHOST_EventTrackpad(
@ -1743,7 +1743,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
} break;
case NSEventTypeRotate: {
NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
NSPoint mousePos = [event locationInWindow];
GHOST_TInt32 x, y;
window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000,