Commit: a93e15aee37cad718fc2a2a53606bc2a35d60802
Author: Campbell Barton
Date:   Tue Sep 8 23:35:49 2015 +1000
Branches: master
https://developer.blender.org/rBa93e15aee37cad718fc2a2a53606bc2a35d60802

Fix T45771: Walk mode fails on OSX

===================================================================

M       source/blender/editors/space_view3d/view3d_walk.c
M       source/blender/windowmanager/WM_api.h
M       source/blender/windowmanager/intern/wm_window.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_walk.c 
b/source/blender/editors/space_view3d/view3d_walk.c
index e2fbbf5..8bb1020 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -62,6 +62,9 @@
 
 #define USE_TABLET_SUPPORT
 
+/* ensure the target position is one we can reach, see: T45771 */
+#define USE_PIXELSIZE_NATIVE_SUPPORT
+
 /* prototypes */
 static float getVelocityZeroTime(const float gravity, const float velocity);
 
@@ -578,6 +581,16 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, 
wmOperator *op)
        walk->center_mval[0] = walk->ar->winx * 0.5f;
        walk->center_mval[1] = walk->ar->winy * 0.5f;
 
+#ifdef USE_PIXELSIZE_NATIVE_SUPPORT
+       walk->center_mval[0] += walk->ar->winrct.xmin;
+       walk->center_mval[1] += walk->ar->winrct.ymin;
+
+       WM_cursor_comaptible_xy(win, &walk->center_mval[0], 
&walk->center_mval[1]);
+
+       walk->center_mval[0] -= walk->ar->winrct.xmin;
+       walk->center_mval[1] -= walk->ar->winrct.ymin;
+#endif
+
        copy_v2_v2_int(walk->prev_mval, walk->center_mval);
 
        WM_cursor_warp(win,
diff --git a/source/blender/windowmanager/WM_api.h 
b/source/blender/windowmanager/WM_api.h
index a4c4dbf..a21886c 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -130,6 +130,7 @@ void                WM_paint_cursor_end(struct 
wmWindowManager *wm, void *handle);
 void           WM_paint_cursor_tag_redraw(struct wmWindow *win, struct ARegion 
*ar);
 
 void           WM_cursor_warp          (struct wmWindow *win, int x, int y);
+void           WM_cursor_comaptible_xy(wmWindow *win, int *x, int *y);
 float          WM_cursor_pressure      (const struct wmWindow *win);
 
                        /* event map */
diff --git a/source/blender/windowmanager/intern/wm_window.c 
b/source/blender/windowmanager/intern/wm_window.c
index af7e9c8..c2209b2 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -1557,6 +1557,18 @@ void WM_cursor_warp(wmWindow *win, int x, int y)
 }
 
 /**
+ * Set x, y to values we can actually position the cursor to.
+ */
+void WM_cursor_comaptible_xy(wmWindow *win, int *x, int *y)
+{
+       float f = GHOST_GetNativePixelSize(win->ghostwin);
+       if (f != 1.0f) {
+               *x = (int)(*x / f) * f;
+               *y = (int)(*y / f) * f;
+       }
+}
+
+/**
  * Get the cursor pressure, in most cases you'll want to use wmTabletData from 
the event
  */
 float WM_cursor_pressure(const struct wmWindow *win)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to