/** * \param bounds can be NULL */ void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4]) { /* Only grab cursor when not running debug. * It helps not to get a stuck WM when hitting a breakpoint * */ GHOST_TGrabCursorMode mode = GHOST_kGrabNormal; if (bounds) { wm_cursor_position_to_ghost(win, &bounds[0], &bounds[1]); wm_cursor_position_to_ghost(win, &bounds[2], &bounds[3]); } if (hide) { mode = GHOST_kGrabHide; } else if (wrap) { mode = GHOST_kGrabWrap; } if ((G.debug & G_DEBUG) == 0) { if (win->ghostwin) { const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); /* Note: There is no tabletdata on Windows if no tablet device is connected. */ if (!tabletdata) GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); else if (tabletdata->Active == GHOST_kTabletModeNone) GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); win->grabcursor = mode; } } }
void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2]) { if ((G.debug & G_DEBUG) == 0) { 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]); GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL, mouse_xy); } else { GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL, NULL); } win->grabcursor = GHOST_kGrabDisable; } } }
void WM_cursor_grab_disable(wmWindow *win, 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); win->grabcursor = GHOST_kGrabDisable; } } }
void WM_cursor_ungrab(wmWindow *win) { if ((G.debug & G_DEBUG) == 0) { if (win && win->ghostwin) { GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL); win->grabcursor = GHOST_kGrabDisable; } } }
void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds) { /* Only grab cursor when not running debug. * It helps not to get a stuck WM when hitting a breakpoint * */ GHOST_TGrabCursorMode mode = GHOST_kGrabNormal; if (hide) mode = GHOST_kGrabHide; else if (wrap) mode = GHOST_kGrabWrap; if ((G.debug & G_DEBUG) == 0) { if (win && win->ghostwin) { const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); /* Note: There is no tabletdata on Windows if no tablet device is connected. */ if (!tabletdata) GHOST_SetCursorGrab(win->ghostwin, mode, bounds); else if (tabletdata->Active == GHOST_kTabletModeNone) GHOST_SetCursorGrab(win->ghostwin, mode, bounds); win->grabcursor = mode; } } }
/** * \param bounds can be NULL */ void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4]) { /* Only grab cursor when not running debug. * 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; } if (hide) { mode = GHOST_kGrabHide; } else if (wrap) { mode = GHOST_kGrabWrap; } if ((G.debug & G_DEBUG) == 0) { if (win->ghostwin) { const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); /* Note: There is no tabletdata on Windows if no tablet device is connected. */ if (!tabletdata) GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); else if (tabletdata->Active == GHOST_kTabletModeNone) GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); win->grabcursor = mode; } } }