From bc795694198a700aeb6283741da2a4ed515a70c3 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 9 Dec 2009 04:51:35 +0000 Subject: grabcursor attribute stores full grab mode so we can better differentiate when it needs to wrap around cursor draw. Also add cocoa exception to wm_get_cursor_position (this should be fixed at the ghost level) --- source/blender/makesdna/DNA_windowmanager_types.h | 2 +- source/blender/windowmanager/intern/wm_cursors.c | 4 ++-- source/blender/windowmanager/intern/wm_draw.c | 5 ++++- source/blender/windowmanager/intern/wm_window.c | 5 +++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 24374720232..714dc853419 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -141,7 +141,7 @@ typedef struct wmWindow { int winid; /* winid also in screens, is for retrieving this window after read */ - short grabcursor; /* 1 if cursor is grabbed */ + short grabcursor; /* cursor grab mode */ short pad; struct bScreen *screen; /* active screen */ diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index cec5886014a..dfcc1fcd227 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -181,7 +181,7 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds) else if (tabletdata->Active == GHOST_kTabletModeNone) GHOST_SetCursorGrab(win->ghostwin, mode, bounds); - win->grabcursor = 1; + win->grabcursor = mode; } } } @@ -191,7 +191,7 @@ void WM_cursor_ungrab(wmWindow *win) if ((G.f & G_DEBUG) == 0) { if(win && win->ghostwin) { GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL); - win->grabcursor = 0; + win->grabcursor = GHOST_kGrabDisable; } } } diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 96aea760e20..3335efeb166 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -41,6 +41,9 @@ #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_utildefines.h" + +#include "GHOST_C-api.h" #include "ED_screen.h" @@ -74,7 +77,7 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar) for(pc= wm->paintcursors.first; pc; pc= pc->next) { if(pc->poll == NULL || pc->poll(C)) { ARegion *ar= CTX_wm_region(C); - if (win->grabcursor) { + if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) { int x = 0, y = 0; wm_get_cursor_position(win, &x, &y); pc->draw(C, x - ar->winrct.xmin, y - ar->winrct.ymin, pc->customdata); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 31ad8cdcc63..6ae320da912 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -977,7 +977,12 @@ void wm_get_cursor_position(wmWindow *win, int *x, int *y) { GHOST_GetCursorPosition(g_system, x, y); GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y); +#if defined(__APPLE__) && defined(GHOST_COCOA) + //Cocoa has silly exception that should be fixed at the ghost level + //(ghost is an allegory for an invisible system specific code) +#else *y = (win->sizey-1) - *y; +#endif } /* ******************* exported api ***************** */ -- cgit v1.2.3