void WM_cursor_set(wmWindow *win, int curs) { if (win == NULL || G.background) { return; /* Can't set custom cursor before Window init */ } if (curs == CURSOR_NONE) { GHOST_SetCursorVisibility(win->ghostwin, 0); return; } #ifdef _WIN32 /* the default win32 cross cursor is barely visible, * only 1 pixel thick, use another one instead */ if (curs == CURSOR_EDIT) curs = BC_CROSSCURSOR; #else /* in case of large cursor, also use custom cursor because * large cursors don't work for system cursors */ if (U.curssize && curs == CURSOR_EDIT) curs = BC_CROSSCURSOR; #endif GHOST_SetCursorVisibility(win->ghostwin, 1); if (curs == CURSOR_STD && win->modalcursor) curs = win->modalcursor; win->cursor = curs; /* detect if we use system cursor or Blender cursor */ if (curs >= BC_GHOST_CURSORS) { GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs)); } else { if ((curs < SYSCURSOR) || (curs >= BC_NUMCURSORS)) return; if (curs == SYSCURSOR) { /* System default Cursor */ GHOST_SetCursorShape(win->ghostwin, convert_cursor(CURSOR_STD)); } else if ((U.curssize == 0) || (BlenderCursor[curs]->big_bm == NULL)) { window_set_custom_cursor_ex(win, BlenderCursor[curs], 0); } else { window_set_custom_cursor_ex(win, BlenderCursor[curs], 1); } } }
static void mainwindow_do_key(MainWindow *mw, GHOST_TKey key, int press) { switch(key) { case GHOST_kKeyC: if (press) GHOST_SetCursorShape(mw->win, (GHOST_TStandardCursor) (rand()%(GHOST_kStandardCursorNumCursors))); break; case GHOST_kKeyLeftBracket: if (press) GHOST_SetCursorVisibility(mw->win, 0); break; case GHOST_kKeyRightBracket: if (press) GHOST_SetCursorVisibility(mw->win, 1); break; case GHOST_kKeyE: if (press) multitestapp_toggle_extra_window(mw->app); break; case GHOST_kKeyQ: if (press) multitestapp_exit(mw->app); break; case GHOST_kKeyT: if (press) mainwindow_log(mw, "TextTest~|`hello`\"world\",<>/"); break; case GHOST_kKeyR: if (press) { int i; mainwindow_log(mw, "Invalidating window 10 times"); for (i=0; i<10; i++) GHOST_InvalidateWindow(mw->win); } break; case GHOST_kKeyF11: if (press) { GHOST_SetWindowOrder(mw->win, GHOST_kWindowOrderBottom); } break; } }
int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData) { int handled = 1; int cursor; int visibility; GHOST_TEventKeyData *keyData = NULL; GHOST_TEventWheelData *wheelData = NULL; GHOST_DisplaySetting setting; GHOST_WindowHandle window = GHOST_GetEventWindow(hEvent); switch (GHOST_GetEventType(hEvent)) { #if 0 case GHOST_kEventUnknown: break; case GHOST_kEventCursorButton: break; case GHOST_kEventCursorMove: break; #endif case GHOST_kEventWheel: { wheelData = (GHOST_TEventWheelData *)GHOST_GetEventData(hEvent); if (wheelData->z > 0) { view_rotz += 5.f; } else { view_rotz -= 5.f; } } break; case GHOST_kEventKeyUp: break; case GHOST_kEventKeyDown: { keyData = (GHOST_TEventKeyData *)GHOST_GetEventData(hEvent); switch (keyData->key) { case GHOST_kKeyC: { cursor = sCursor; cursor++; if (cursor >= GHOST_kStandardCursorNumCursors) { cursor = GHOST_kStandardCursorFirstCursor; } sCursor = (GHOST_TStandardCursor)cursor; GHOST_SetCursorShape(window, sCursor); } break; case GHOST_kKeyF: if (!GHOST_GetFullScreen(shSystem)) { /* Begin fullscreen mode */ setting.bpp = 24; setting.frequency = 85; setting.xPixels = 640; setting.yPixels = 480; /* * setting.bpp = 16; * setting.frequency = 75; * setting.xPixels = 640; * setting.yPixels = 480; */ sFullScreenWindow = GHOST_BeginFullScreen(shSystem, &setting, FALSE /* stereo flag */); } else { GHOST_EndFullScreen(shSystem); sFullScreenWindow = 0; } break; case GHOST_kKeyH: { visibility = GHOST_GetCursorVisibility(window); GHOST_SetCursorVisibility(window, !visibility); } break; case GHOST_kKeyQ: if (GHOST_GetFullScreen(shSystem)) { GHOST_EndFullScreen(shSystem); sFullScreenWindow = 0; } sExitRequested = 1; case GHOST_kKeyT: if (!sTestTimer) { sTestTimer = GHOST_InstallTimer(shSystem, 0, 1000, testTimerProc, NULL); } else { GHOST_RemoveTimer(shSystem, sTestTimer); sTestTimer = 0; } break; case GHOST_kKeyW: { if (sMainWindow) { char *title = GHOST_GetTitle(sMainWindow); char *ntitle = malloc(strlen(title) + 2); sprintf(ntitle, "%s-", title); GHOST_SetTitle(sMainWindow, ntitle); free(ntitle); free(title); } } break; default: break; } } break; case GHOST_kEventWindowClose: { GHOST_WindowHandle window2 = GHOST_GetEventWindow(hEvent); if (window2 == sMainWindow) { sExitRequested = 1; } else { if (sGearsTimer) { GHOST_RemoveTimer(shSystem, sGearsTimer); sGearsTimer = 0; } GHOST_DisposeWindow(shSystem, window2); } } break; case GHOST_kEventWindowActivate: handled = 0; break; case GHOST_kEventWindowDeactivate: handled = 0; break; case GHOST_kEventWindowUpdate: { GHOST_WindowHandle window2 = GHOST_GetEventWindow(hEvent); if (!GHOST_ValidWindow(shSystem, window2)) break; setViewPortGL(window2); drawGL(); GHOST_SwapWindowBuffers(window2); } break; default: handled = 0; break; } return handled; }