diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-06-23 23:55:47 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-06-23 23:55:47 +0400 |
commit | c518aa13838d43e7311d65aeb9e3745e5057b806 (patch) | |
tree | 9db683e80a00dcdccb7de1a8ff7d5ee344ae5a96 /source/blender | |
parent | a014886c5793ae99ecf2b1fc860314b0257e9db2 (diff) |
GHOST Cocoa: move y origin top/bottom conversions out of windowmanager module
and into GHOST. Also fixes a problem where e.g. the user preferences window
would not open under the mouse cursor correctly.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 25 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 21 |
2 files changed, 8 insertions, 38 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 2613cb8f14f..83ef46d109c 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2365,18 +2365,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U if(win->active) { GHOST_TEventCursorData *cd= customdata; wmEvent *lastevent= win->queue.last; - -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom, and returns inwindow coordinates on mouse moved event - evt->x= cd->x; - evt->y= cd->y; -#else int cx, cy; GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy); evt->x= cx; evt->y= (win->sizey-1) - cy; -#endif event.x= evt->x; event.y= evt->y; @@ -2423,21 +2416,17 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.type= MOUSEPAN; break; } -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom, and returns inwindow coordinates on mouse moved event - event.x= evt->x = pd->x; - event.y = evt->y = pd->y; -#else + { - int cx, cy; - GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy); - event.x= evt->x= cx; - event.y= evt->y= (win->sizey-1) - cy; + int cx, cy; + GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy); + event.x= evt->x= cx; + event.y= evt->y= (win->sizey-1) - cy; } -#endif + // Use prevx/prevy so we can calculate the delta later event.prevx= event.x - pd->deltaX; - event.prevy= event.y - pd->deltaY; + event.prevy= event.y - (-pd->deltaY); update_tablet_data(win, &event); wm_event_add(win, &event); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 9ee39132521..9b1695be67a 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -673,13 +673,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy); win->eventstate->x= cx; - -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom - win->eventstate->y= cy; -#else win->eventstate->y= (win->sizey-1) - cy; -#endif win->addmousemove= 1; /* enables highlighted buttons */ @@ -796,20 +790,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) wmEvent event; GHOST_TEventDragnDropData *ddd= GHOST_GetEventData(evt); int cx, cy, wx, wy; - /* entering window, update mouse pos */ GHOST_GetCursorPosition(g_system, &wx, &wy); GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy); win->eventstate->x= cx; - -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom - win->eventstate->y= cy; -#else win->eventstate->y= (win->sizey-1) - cy; -#endif event= *(win->eventstate); /* copy last state, like mouse coords */ @@ -1149,12 +1136,7 @@ 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 ***************** */ @@ -1187,9 +1169,8 @@ void WM_cursor_warp(wmWindow *win, int x, int y) if (win && win->ghostwin) { int oldx=x, oldy=y; -#if !defined(__APPLE__) || !defined(GHOST_COCOA) y= win->sizey -y - 1; -#endif + GHOST_ClientToScreen(win->ghostwin, x, y, &x, &y); GHOST_SetCursorPosition(g_system, x, y); |