Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2015-10-03 04:37:41 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2015-10-03 14:08:37 +0300
commitd9d3a2a5009c76f68fd2e6456db7dac61c4d2e49 (patch)
treed2972c9e650261ad5f95e80d3c4c8f1f46666844 /source/blender/windowmanager
parentffe03cd264f39d27047393d4db745ea8dae19d5f (diff)
Fix T44605: OS X continuous grab issues.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c18
-rw-r--r--source/blender/windowmanager/intern/wm_window.c25
-rw-r--r--source/blender/windowmanager/wm_window.h4
3 files changed, 29 insertions, 18 deletions
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index d84b65847ca..d9466cbd035 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -199,14 +199,10 @@ void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4])
* It helps not to get a stuck WM when hitting a breakpoint
* */
GHOST_TGrabCursorMode mode = GHOST_kGrabNormal;
- float fac = GHOST_GetNativePixelSize(win->ghostwin);
- /* in case pixel coords differ from window/mouse coords */
if (bounds) {
- bounds[0] /= fac;
- bounds[1] /= fac;
- bounds[2] /= fac;
- bounds[3] /= fac;
+ wm_cursor_position_to_ghost(win, &bounds[0], &bounds[1]);
+ wm_cursor_position_to_ghost(win, &bounds[2], &bounds[3]);
}
if (hide) {
@@ -234,7 +230,15 @@ void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2])
{
if ((G.debug & G_DEBUG) == 0) {
if (win && win->ghostwin) {
- GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL, mouse_ungrab_xy);
+ if (mouse_ungrab_xy) {
+ int mouse_xy[2] = {mouse_ungrab_xy[0], mouse_ungrab_xy[1]};
+ wm_cursor_position_to_ghost(win, &mouse_xy[0], &mouse_xy[1]);
+ GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL, mouse_xy);
+ }
+ else {
+ GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL, NULL);
+ }
+
win->grabcursor = GHOST_kGrabDisable;
}
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 0b0cedf5825..030399a9c7d 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -676,7 +676,7 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
/* ************ events *************** */
-static void wm_convert_cursor_position(wmWindow *win, int *x, int *y)
+void wm_cursor_position_from_ghost(wmWindow *win, int *x, int *y)
{
float fac = GHOST_GetNativePixelSize(win->ghostwin);
@@ -687,11 +687,21 @@ static void wm_convert_cursor_position(wmWindow *win, int *x, int *y)
*y *= fac;
}
+void wm_cursor_position_to_ghost(wmWindow *win, int *x, int *y)
+{
+ float fac = GHOST_GetNativePixelSize(win->ghostwin);
+
+ *x /= fac;
+ *y /= fac;
+ *y = win->sizey - *y - 1;
+
+ GHOST_ClientToScreen(win->ghostwin, *x, *y, x, y);
+}
void wm_get_cursor_position(wmWindow *win, int *x, int *y)
{
GHOST_GetCursorPosition(g_system, x, y);
- wm_convert_cursor_position(win, x, y);
+ wm_cursor_position_from_ghost(win, x, y);
}
typedef enum {
@@ -1118,7 +1128,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
{
GHOST_TEventTrackpadData *pd = data;
- wm_convert_cursor_position(win, &pd->x, &pd->y);
+ wm_cursor_position_from_ghost(win, &pd->x, &pd->y);
wm_event_add_ghostevent(wm, win, type, time, data);
break;
}
@@ -1126,7 +1136,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
{
GHOST_TEventCursorData *cd = data;
- wm_convert_cursor_position(win, &cd->x, &cd->y);
+ wm_cursor_position_from_ghost(win, &cd->x, &cd->y);
wm_event_add_ghostevent(wm, win, type, time, data);
break;
}
@@ -1541,14 +1551,9 @@ void WM_init_native_pixels(bool do_it)
void WM_cursor_warp(wmWindow *win, int x, int y)
{
if (win && win->ghostwin) {
- float f = GHOST_GetNativePixelSize(win->ghostwin);
int oldx = x, oldy = y;
- x = x / f;
- y = y / f;
- y = win->sizey - y - 1;
-
- GHOST_ClientToScreen(win->ghostwin, x, y, &x, &y);
+ wm_cursor_position_to_ghost(win, &x, &y);
GHOST_SetCursorPosition(g_system, x, y);
win->eventstate->prevx = oldx;
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index a104f6aba39..8633f297dda 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -64,7 +64,9 @@ bool wm_window_get_swap_interval(wmWindow *win, int *intervalOut);
float wm_window_pixelsize(wmWindow *win);
-void wm_get_cursor_position (wmWindow *win, int *x, int *y);
+void wm_get_cursor_position (wmWindow *win, int *x, int *y);
+void wm_cursor_position_from_ghost (wmWindow *win, int *x, int *y);
+void wm_cursor_position_to_ghost (wmWindow *win, int *x, int *y);
void wm_window_testbreak (void);