static int renderSPUCleanup(void) { renderspuVBoxCompositorClearAll(); if (render_spu.blitterTable) { crFreeHashtable(render_spu.blitterTable, DeleteBlitterCallback); render_spu.blitterTable = NULL; } else { crHashtableWalk(render_spu.windowTable, renderspuBlitterCleanupCB, NULL); crHashtableWalk(render_spu.dummyWindowTable, renderspuBlitterCleanupCB, NULL); } renderspuSetDefaultSharedContext(NULL); crFreeHashtable(render_spu.contextTable, DeleteContextCallback); render_spu.contextTable = NULL; crFreeHashtable(render_spu.windowTable, DeleteWindowCallback); render_spu.windowTable = NULL; crFreeHashtable(render_spu.dummyWindowTable, DeleteWindowCallback); render_spu.dummyWindowTable = NULL; crFreeHashtable(render_spu.barrierHash, crFree); render_spu.barrierHash = NULL; #ifdef RT_OS_DARWIN # ifndef VBOX_WITH_COCOA_QT render_spu.fInit = false; DisposeEventHandlerUPP(render_spu.hParentEventHandler); ReleaseWindowGroup(render_spu.pMasterGroup); ReleaseWindowGroup(render_spu.pParentGroup); if (render_spu.hRootVisibleRegion) { DisposeRgn(render_spu.hRootVisibleRegion); render_spu.hRootVisibleRegion = 0; } render_spu.currentBufferName = 1; render_spu.uiDockUpdateTS = 0; RTSemFastMutexDestroy(render_spu.syncMutex); # else /* VBOX_WITH_COCOA_QT */ # endif /* VBOX_WITH_COCOA_QT */ #endif /* RT_OS_DARWIN */ #ifdef RT_OS_WINDOWS if (render_spu.dwWinThreadId) { HANDLE hNative; hNative = OpenThread(SYNCHRONIZE|THREAD_QUERY_INFORMATION|THREAD_TERMINATE, false, render_spu.dwWinThreadId); if (!hNative) { crWarning("Failed to get handle for window thread(%#x)", GetLastError()); } if (PostThreadMessage(render_spu.dwWinThreadId, WM_QUIT, 0, 0)) { WaitForSingleObject(render_spu.hWinThreadReadyEvent, INFINITE); /*wait for os thread to actually finish*/ if (hNative && WaitForSingleObject(hNative, 3000)==WAIT_TIMEOUT) { crDebug("Wait failed, terminating"); if (!TerminateThread(hNative, 1)) { crWarning("TerminateThread failed"); } } } if (hNative) { CloseHandle(hNative); } } CloseHandle(render_spu.hWinThreadReadyEvent); render_spu.hWinThreadReadyEvent = NULL; #endif crUnloadOpenGL(); #ifdef CHROMIUM_THREADSAFE crFreeTSD(&_RenderTSD); #endif return 1; }
static pascal OSStatus SimpleWindowEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) { #pragma unused ( inCallRef ) HICommand command; Point pt; SInt16 value; Rect r; WindowGroupRef windowGroup; WindowGroupAttributes windowGroupAttributes; UInt32 eventKind = GetEventKind( inEvent ); UInt32 eventClass = GetEventClass( inEvent ); WindowRef window = (WindowRef) inUserData; OSStatus err = eventNotHandledErr; WindowStorage *windowStorage = (WindowStorage*) GetWRefCon( window ); switch ( eventClass ) { case kEventClassWindow: if ( eventKind == kEventWindowClose ) // Dispose extra window storage here { if ( windowStorage->overlayWindow != NULL ) SendWindowCloseEvent( windowStorage->overlayWindow ); DisposePtr( (Ptr) windowStorage ); } else if ( eventKind == kEventWindowClickContentRgn ) { if ( GetControlValueByID( window, 'Butn', 0 ) == 1 ) // If the "Line Tool" button is depressed { LineTool( window ); SetControlValueByID( window, 'Butn', 0, 0 ); // Pop the button back up err = noErr; } } else if ( (eventKind == kEventWindowBoundsChanging) || (eventKind == kEventWindowBoundsChanged) ) { if ( windowStorage->overlayWindow != NULL ) // Resize the overlay window as well { (void) GetEventParameter( inEvent, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &r ); SizeWindow( windowStorage->overlayWindow, r.right-r.left, r.bottom-r.top, false ); } } break; case kEventClassCommand: if ( eventKind == kEventCommandProcess ) { GetEventParameter( inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &command ); if ( command.commandID == kHICommandOK ) // Change the window layering and attributes { value = GetControlValueByID( window, 'Rdio', 0 ); // Which group was chosen windowGroupAttributes = 0; // Now set the attributes for the parent group if ( GetControlValueByID( window, 'Chek', 0 ) == 1 ) windowGroupAttributes |= kWindowGroupAttrMoveTogether; ChangeWindowGroupAttributes( g.windowGroups[value-1], windowGroupAttributes, ~windowGroupAttributes ); windowGroupAttributes = kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse; err = CreateWindowGroup( windowGroupAttributes, &windowGroup ); // We can only call SetWindowGroupParent() on an empty group, so create a new one if ( err == noErr ) err = SetWindowGroupParent( windowGroup, g.windowGroups[value-1] ); // Set the new parent if ( (err == noErr) && (windowStorage->overlayWindow != NULL) ) err = SetWindowGroup( windowStorage->overlayWindow, windowGroup ); // FIRST add the overlay window so that it is on top of the "normal" window if ( err == noErr ) { ReleaseWindowGroup( GetWindowGroup(window) ); // Release the old group err = SetWindowGroup( window, windowGroup ); // Add the window to the new group } } else if ( command.commandID == 'GAtr' ) // Get the window attributes { windowGroup = GetWindowGroupParent( GetWindowGroup(window) ); GetWindowGroupAttributes( windowGroup, &windowGroupAttributes ); SetControlValueByID( window, 'Chek', 0, ((windowGroupAttributes & kWindowGroupAttrMoveTogether) != 0) ); if ( windowGroup == g.windowGroups[0] ) SetControlValueByID( window, 'Rdio', 0, 1 ); else if ( windowGroup == g.windowGroups[1] ) SetControlValueByID( window, 'Rdio', 0, 2 ); else SetControlValueByID( window, 'Rdio', 0, 3 ); } else if ( command.commandID == 'Poof' ) { SetPortWindowPort( window ); GetMouse( &pt ); LocalToGlobal( &pt ); pt.v -= 50; // Draw the Poof 50 pixels above the mouse PoofItGood( pt ); } else if ( command.commandID == 'Over' ) { if ( windowStorage->overlayWindow == NULL ) { CreateOverlayWindow( window ); } else { SendWindowCloseEvent( windowStorage->overlayWindow ); } } } break; } return( err ); }