diff options
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 32 |
3 files changed, 28 insertions, 21 deletions
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 54636cb57ec..43be87fce39 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -231,8 +231,8 @@ void WM_cursor_grab_enable(wmWindow *win, int wrap, bool hide, int bounds[4]) GHOST_TAxisFlag mode_axis = GHOST_kAxisX | GHOST_kAxisY; if (bounds) { - wm_cursor_position_to_ghost(win, &bounds[0], &bounds[1]); - wm_cursor_position_to_ghost(win, &bounds[2], &bounds[3]); + wm_cursor_position_to_ghost_screen_coords(win, &bounds[0], &bounds[1]); + wm_cursor_position_to_ghost_screen_coords(win, &bounds[2], &bounds[3]); } if (hide) { @@ -266,7 +266,7 @@ void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2]) if (win && win->ghostwin) { 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]); + wm_cursor_position_to_ghost_screen_coords(win, &mouse_xy[0], &mouse_xy[1]); GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, GHOST_kAxisNone, NULL, mouse_xy); } else { diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index baba64b2230..99f117f267a 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -1217,8 +1217,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) GHOST_TEventButtonData *bd = GHOST_GetEventData(evt); int cx, cy, sizex, sizey, inside_window; - GHOST_GetCursorPosition(g_WS.ghost_system, &cx, &cy); - GHOST_ScreenToClient(g_WS.ghost_window, cx, cy, &cx, &cy); + GHOST_GetCursorPosition(g_WS.ghost_system, g_WS.ghost_window, &cx, &cy); playanim_window_get_size(&sizex, &sizey); inside_window = (cx >= 0 && cx < sizex && cy >= 0 && cy <= sizey); @@ -1267,15 +1266,15 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) * however the API currently doesn't support this. */ { int x_test, y_test; - GHOST_GetCursorPosition(g_WS.ghost_system, &x_test, &y_test); - if (x_test != cd->x || y_test != cd->y) { + GHOST_GetCursorPosition(g_WS.ghost_system, g_WS.ghost_window, &cx, &cy); + GHOST_ScreenToClient(g_WS.ghost_window, cd->x, cd->y, &x_test, &y_test); + + if (cx != x_test || cy != y_test) { /* we're not the last event... skipping */ break; } } - GHOST_ScreenToClient(g_WS.ghost_window, cd->x, cd->y, &cx, &cy); - tag_change_frame(ps, cx); } break; diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index baf137e6665..36f91f8414a 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -920,25 +920,33 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) /* ************ events *************** */ -void wm_cursor_position_from_ghost(wmWindow *win, int *x, int *y) +void wm_cursor_position_from_ghost_client_coords(wmWindow *win, int *x, int *y) { float fac = GHOST_GetNativePixelSize(win->ghostwin); - - GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y); *x *= fac; *y = (win->sizey - 1) - *y; *y *= fac; } -void wm_cursor_position_to_ghost(wmWindow *win, int *x, int *y) +void wm_cursor_position_to_ghost_client_coords(wmWindow *win, int *x, int *y) { float fac = GHOST_GetNativePixelSize(win->ghostwin); *x /= fac; *y /= fac; *y = win->sizey - *y - 1; +} + +void wm_cursor_position_from_ghost_screen_coords(wmWindow *win, int *x, int *y) +{ + GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y); + wm_cursor_position_from_ghost_client_coords(win, x, y); +} +void wm_cursor_position_to_ghost_screen_coords(wmWindow *win, int *x, int *y) +{ + wm_cursor_position_to_ghost_client_coords(win, x, y); GHOST_ClientToScreen(win->ghostwin, *x, *y, x, y); } @@ -949,8 +957,8 @@ void wm_cursor_position_get(wmWindow *win, int *r_x, int *r_y) *r_y = win->eventstate->xy[1]; return; } - GHOST_GetCursorPosition(g_system, r_x, r_y); - wm_cursor_position_from_ghost(win, r_x, r_y); + GHOST_GetCursorPosition(g_system, win->ghostwin, r_x, r_y); + wm_cursor_position_from_ghost_client_coords(win, r_x, r_y); } typedef enum { @@ -1418,14 +1426,14 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt case GHOST_kEventTrackpad: { GHOST_TEventTrackpadData *pd = data; - wm_cursor_position_from_ghost(win, &pd->x, &pd->y); + wm_cursor_position_from_ghost_screen_coords(win, &pd->x, &pd->y); wm_event_add_ghostevent(wm, win, type, data); break; } case GHOST_kEventCursorMove: { GHOST_TEventCursorData *cd = data; - wm_cursor_position_from_ghost(win, &cd->x, &cd->y); + wm_cursor_position_from_ghost_screen_coords(win, &cd->x, &cd->y); wm_event_add_ghostevent(wm, win, type, data); break; } @@ -1866,7 +1874,7 @@ wmWindow *WM_window_find_under_cursor(wmWindow *win, const int mval[2], int r_mv { int tmp[2]; copy_v2_v2_int(tmp, mval); - wm_cursor_position_to_ghost(win, &tmp[0], &tmp[1]); + wm_cursor_position_to_ghost_screen_coords(win, &tmp[0], &tmp[1]); GHOST_WindowHandle ghostwin = GHOST_GetWindowUnderCursor(g_system, tmp[0], tmp[1]); @@ -1875,7 +1883,7 @@ wmWindow *WM_window_find_under_cursor(wmWindow *win, const int mval[2], int r_mv } wmWindow *win_other = GHOST_GetWindowUserData(ghostwin); - wm_cursor_position_from_ghost(win_other, &tmp[0], &tmp[1]); + wm_cursor_position_from_ghost_screen_coords(win_other, &tmp[0], &tmp[1]); copy_v2_v2_int(r_mval, tmp); return win_other; } @@ -2015,8 +2023,8 @@ void WM_cursor_warp(wmWindow *win, int x, int y) if (win && win->ghostwin) { int oldx = x, oldy = y; - wm_cursor_position_to_ghost(win, &x, &y); - GHOST_SetCursorPosition(g_system, x, y); + wm_cursor_position_to_ghost_client_coords(win, &x, &y); + GHOST_SetCursorPosition(g_system, win->ghostwin, x, y); win->eventstate->prev_xy[0] = oldx; win->eventstate->prev_xy[1] = oldy; |