Exemple #1
0
/**
 * \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;
		}
	}
}
Exemple #2
0
/* This function requires access to the GHOST_SystemHandle (g_system) */
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);

        win->eventstate->prevx = oldx;
        win->eventstate->prevy = oldy;

        win->eventstate->x = oldx;
        win->eventstate->y = oldy;
    }
}
Exemple #3
0
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;
		}
	}
}