diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/os_osx.mm | 13 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 8 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 6 |
3 files changed, 23 insertions, 4 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 5bc47a74c1..af2552496b 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1093,8 +1093,19 @@ void OS_OSX::warp_mouse_pos(const Point2& p_to) { mouse_y = p_to.y; } else{ //set OS position - CGPoint lMouseWarpPos = {p_to.x, p_to.y}; + /* this code has not been tested, please be a kind soul and fix it if it fails! */ + + //local point in window coords + NSPoint localPoint = { p_to.x, p_to.y }; + + NSPoint pointInWindow = [window_view convertPoint:localPoint toView:nil]; + NSPoint pointOnScreen = [[window_view window] convertRectToScreen:(CGRect){.origin=pointInWindow}]; + + //point in scren coords + CGPoint lMouseWarpPos = { pointOnScreen.x, pointOnScreen.y}; + + //do the warping CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0); CGAssociateMouseAndMouseCursorPosition(false); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 086b4d7d12..13f2c32e77 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1432,9 +1432,13 @@ void OS_Windows::warp_mouse_pos(const Point2& p_to) { old_y=p_to.y; } else { - SetCursorPos(p_to.x, p_to.y); - } + POINT p; + p.x=p_to.x; + p.y=p_to.y; + ClientToScreen(hWnd,&p); + SetCursorPos(p.x,p.y); + } } Point2 OS_Windows::get_mouse_pos() const { diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index a40af8d2a9..ac1818d200 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -479,8 +479,12 @@ void OS_X11::warp_mouse_pos(const Point2& p_to) { last_mouse_pos=p_to; } else { + /*XWindowAttributes xwa; + XGetWindowAttributes(x11_display, x11_window, &xwa); + printf("%d %d\n", xwa.x, xwa.y); needed? */ + XWarpPointer(x11_display, None, x11_window, - 0,0,0,0, (int)p_to.x, (int)p_to.y); + 0,0,0,0, (int)p_to.x , (int)p_to.y); } } |