diff options
| author | Carl Olsson | 2015-02-15 18:21:35 +1000 |
|---|---|---|
| committer | Carl Olsson | 2015-02-15 18:21:35 +1000 |
| commit | 196185d0be3ea7c05335c03d7e2db3e7c17d7a49 (patch) | |
| tree | 572596c4261ed5e520ba1628661261ea0d5ee620 /platform | |
| parent | 6a38ab1b43e4a107a28c52ba2036a4886794f625 (diff) | |
| parent | 2185c018f6593e6d64b2beb62202d2291e2e008e (diff) | |
| download | godot-196185d0be3ea7c05335c03d7e2db3e7c17d7a49.tar.gz godot-196185d0be3ea7c05335c03d7e2db3e7c17d7a49.tar.zst godot-196185d0be3ea7c05335c03d7e2db3e7c17d7a49.zip | |
Merge branch 'master' of https://github.com/okamstudio/godot
Conflicts:
scene/2d/tile_map.cpp
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 5bc47a74c..af2552496 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 086b4d7d1..13f2c32e7 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 a40af8d2a..ac1818d20 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); } } |
