void enter_mouse( short type) { (void) (type); snapshot_delta_yaw= snapshot_delta_pitch= snapshot_delta_velocity= false; for(int i = 0; i < MAX_BUTTONS; i++) snapshot_button_state[i] = false; snapshot_delta_scrollwheel = 0; // JTP: Install our Carbon Event mouse handler and create the critical region for safe value sharing static EventTypeSpec mouseEvents[] = { {kEventClassMouse, kEventMouseDown}, {kEventClassMouse, kEventMouseUp}, {kEventClassMouse, kEventMouseWheelMoved}, {kEventClassMouse, kEventMouseMoved}, {kEventClassMouse, kEventMouseDragged} }; _CEMouseTrackerUPP = NewEventHandlerUPP(CEvtHandleApplicationMouseEvents); InstallApplicationEventHandler (_CEMouseTrackerUPP, 5, mouseEvents, NULL, &_CEMouseTracker); MPCreateCriticalRegion(&CE_MouseLock); // Fallback in case the lock cannot be allocated (possible with Classic): if (!CE_MouseLock) GetGlobalMouse(&PrevPosition); #ifndef __MACH__ LoadCGMouseFunctions(); #endif }
scoped_critical_region::scoped_critical_region(): m_pCriticalRegionID(kInvalidID) { static bool bIgnored = thread_init(); OSStatus lStatus = MPCreateCriticalRegion(&m_pCriticalRegionID); if(lStatus != noErr || m_pCriticalRegionID == kInvalidID) throw(thread_resource_error()); }
CriticalSection::CriticalSection() : self( new CriticalSection::Context ) { #if defined(_WIN32) InitializeCriticalSectionAndSpinCount( &self->criticalSection, 0x400 ); #elif defined(__APPLE__) MPCreateCriticalRegion( &self->criticalSection ); #elif defined(__linux__) pthread_mutex_init( &self->criticalSection, 0 ); #endif }
wxMutexInternal::wxMutexInternal(wxMutexType mutexType ) { m_isOk = false ; m_critRegion = kInvalidID ; verify_noerr( MPCreateCriticalRegion( & m_critRegion) ); m_isOk = ( m_critRegion != kInvalidID ) ; if ( !IsOk() ) wxFAIL_MSG(wxT("Error when creating mutex") ) ; }
CFSMutex::CFSMutex() { #if defined (WINRT) InitializeCriticalSectionEx(&m_hMutex, 0, 0); #elif defined (WIN32) InitializeCriticalSection(&m_hMutex); #elif defined (UNIX) pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutex_init(&m_hMutex, &attr); pthread_mutexattr_destroy(&attr); #elif defined (MAC) MPCreateCriticalRegion(&m_hMutex); #endif }
wxCriticalSection::wxCriticalSection( wxCriticalSectionType WXUNUSED(critSecType) ) { MPCreateCriticalRegion( (MPCriticalRegionID*) &m_critRegion ); }
wxCriticalSection::wxCriticalSection() { MPCreateCriticalRegion( (MPCriticalRegionID*) &m_critRegion ); }
// Note that this function has to be called once. To recreate textures, call the renewTex() member function. int appleMultiContext::init(struct sageDisplayConfig &cfg) { // Make this a "faceful app" that can receive input events: ProcessSerialNumber psn; OSStatus s; s = GetCurrentProcess(&psn); assert(s == noErr); s = TransformProcessType(&psn,kProcessTransformToForegroundApplication); assert(s == noErr); s = SetFrontProcess(&psn); assert(s == noErr); singleContext = false; configStruct = cfg; tileNum = cfg.dimX * cfg.dimY; if (tileNum > MAX_TILES_PER_NODE) { sage::printLog("displayContext::init() : The tile number exceeds the maximum"); return -1; } if (!winCreatFlag) { // // Set up us the OpenGL: // Choose global pixel format: static GLint agl_fmt_list[] = { AGL_RGBA, AGL_RED_SIZE, 8, AGL_GREEN_SIZE, 8, AGL_BLUE_SIZE, 8, AGL_ALPHA_SIZE, 8, AGL_DEPTH_SIZE, 24, AGL_DOUBLEBUFFER, AGL_NONE }; agl_fmt = aglChoosePixelFormat(0,0,agl_fmt_list); if (agl_fmt == 0) { fprintf(stderr,"failed to choose OpenGL pixel format\n"); abort(); } // The critical region object MPCreateCriticalRegion(&cr); // Install event handlers // EventTargetRef target = GetApplicationEventTarget(); EventTypeSpec eventTypes[] = { { kEventClassKeyboard, kEventRawKeyDown } }; InstallEventHandler(target,NewEventHandlerUPP(keyboard_handler), sizeof(eventTypes) / sizeof(EventTypeSpec),eventTypes, 0,0); // Create Windows for (int k = 0; k < tileNum; k++) { int tileX = (k % cfg.dimX) * cfg.tileRect[k].width; int tileY = (k / cfg.dimX) * cfg.tileRect[k].height; Rect wrect; wrect.left = tileX; // cfg.tileRect[k].x; wrect.top = tileY; // cfg.tileRect[k].y; wrect.right = wrect.left + cfg.tileRect[k].width; wrect.bottom = wrect.top + cfg.tileRect[k].height; //fprintf(stderr,"Create window %d at %i,%i,%i,%i\n",k, wrect.left,wrect.top,wrect.right,wrect.bottom); windows[k] = new Window(wrect, configStruct.fullScreenFlag); windows[k]->beginGL(); glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); } winCreatFlag = true; } return 0; } // End of appleMultiContext::init()