/** * \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; } } }
/** * Get the cursor pressure, in most cases you'll want to use wmTabletData from the event */ float WM_cursor_pressure(const struct wmWindow *win) { const GHOST_TabletData *td = GHOST_GetTabletData(win->ghostwin); /* if there's tablet data from an active tablet device then add it */ if ((td != NULL) && td->Active != GHOST_kTabletModeNone) { return td->Pressure; } else { return -1.0f; } }
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; } } }