コード例 #1
0
ファイル: WindowFun.c プロジェクト: fruitsamples/WindowFun
//	Creates an overlay window which will move with its parent.  This technique is typical for doing things like drawing on top of movies,
//	creating selection rectangles, drawing on top of GL windows, etc.
static	void	CreateOverlayWindow( WindowRef window )
{
	OSStatus					err;
	Rect						windowRect;
	WindowStorage				*windowStorage		= (WindowStorage*) GetWRefCon( window );
    WindowAttributes			overlayAttributes	= kWindowNoShadowAttribute | kWindowIgnoreClicksAttribute | kWindowNoActivatesAttribute | kWindowStandardHandlerAttribute;
	static	EventHandlerUPP		overlayWindowEventHandlerUPP;
	const EventTypeSpec	windowEvents[]	=
	    {
			{ kEventClassWindow, kEventWindowBoundsChanged },
			{ kEventClassWindow, kEventWindowShown },
			{ kEventClassWindow, kEventWindowClose }
		};

    SetPortWindowPort( window );
	GetWindowPortBounds( window, &windowRect );
	LocalToGlobalRect( &windowRect );											//	Window to be size of window it lies on
	err	= CreateNewWindow( kOverlayWindowClass, overlayAttributes, &windowRect, &windowStorage->overlayWindow );	
	if ( err != noErr ) goto Bail;

	SetWindowGroup( windowStorage->overlayWindow, GetWindowGroup(window) );		//	Put them in the same group so that their window layers are consistent

	if ( overlayWindowEventHandlerUPP == NULL ) overlayWindowEventHandlerUPP	= NewEventHandlerUPP( OverlayWindowEventHandlerProc );
	err	= InstallWindowEventHandler( windowStorage->overlayWindow, overlayWindowEventHandlerUPP, GetEventTypeCount(windowEvents), windowEvents, windowStorage, NULL );

	ShowWindow( windowStorage->overlayWindow );
Bail:
	return;
}
コード例 #2
0
ファイル: overlay.cpp プロジェクト: EdgarTx/wx
OSStatus wxOverlayImpl::CreateOverlayWindow()
{
    OSStatus err;

    WindowAttributes overlayAttributes  = kWindowIgnoreClicksAttribute;

    if ( m_window )
    {
        m_overlayParentWindow =(WindowRef) m_window->MacGetTopLevelWindowRef();

        Rect bounds ;
        MacGetBounds(&bounds);
        err  = CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, &m_overlayWindow );
        if ( err == noErr )
        {
            SetWindowGroup( m_overlayWindow, GetWindowGroup(m_overlayParentWindow));    //  Put them in the same group so that their window layers are consistent
        }
    }
    else
    {
        m_overlayParentWindow = NULL ;
        CGRect cgbounds ;
        cgbounds = CGDisplayBounds(CGMainDisplayID());
        Rect bounds;
        bounds.top = (short)cgbounds.origin.y;
        bounds.left = (short)cgbounds.origin.x;
        bounds.bottom = (short)(bounds.top + cgbounds.size.height);
        bounds.right = (short)(bounds.left  + cgbounds.size.width);
        err  = CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, &m_overlayWindow );
    }
    ShowWindow(m_overlayWindow);
    return err;
}
コード例 #3
0
QtToaster::QtToaster(QWidget * toaster, QFrame * toasterWindowFrame)
	: QObject(toaster) {

	_timer = NULL;
	_show = true;

	_toaster = toaster;
	
	QString backgroundImagePath = QString(":pics/toaster/toaster-background.png");
#ifdef OS_MACOSX
	_toaster->setParent(_toaster->parentWidget(), Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
	// Make sure the other windows of the application are not raised when the
	// toaster appears
	WId wid = _toaster->winId();
	SetWindowGroup((WindowRef)wid, NULL);
#else
	_toaster->setParent(_toaster->parentWidget(), Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::ToolTip);
#endif

	
	QPixmap p = QPixmap(backgroundImagePath);
	_toaster->setMask( p.mask() );
	toasterWindowFrame->setStyleSheet("QFrame{background-color:#0c0b0b;}");

}
コード例 #4
0
ファイル: WindowFun.c プロジェクト: fruitsamples/WindowFun
static	void	DisplaySimpleWindow( void )
{
	OSErr					err;
	WindowRef				window;
	WindowStorage			*windowStorage;
	WindowGroupRef			windowGroup;
	static	EventHandlerUPP	simpleWindowEventHandlerUPP;
	const EventTypeSpec	windowEvents[]	=
	    {
			{ kEventClassCommand, kEventCommandProcess },
			{ kEventClassWindow, kEventWindowClickContentRgn },
			{ kEventClassWindow, kEventWindowBoundsChanging },
			{ kEventClassWindow, kEventWindowBoundsChanged },
			{ kEventClassWindow, kEventWindowClose }
		};
	
	err	= CreateWindowFromNib( g.mainNib, CFSTR("MainWindow"), &window );
	if ( (err != noErr) || (window == NULL) )	goto Bail;
	
	if ( simpleWindowEventHandlerUPP == NULL ) simpleWindowEventHandlerUPP	= NewEventHandlerUPP( SimpleWindowEventHandlerProc );
	err	= InstallWindowEventHandler( window, simpleWindowEventHandlerUPP, GetEventTypeCount(windowEvents), windowEvents, window, NULL );

	windowStorage	= (WindowStorage*) NewPtrClear( sizeof(WindowStorage) );
	SetWRefCon( window, (long) windowStorage );

	err	= CreateWindowGroup( kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse, &windowGroup );
	if ( err == noErr )	err	= SetWindowGroupParent( windowGroup, g.windowGroups[1] );		//	Default group
	if ( err == noErr )	err	= SetWindowGroup( window, windowGroup );

	ShowWindow( window );

Bail:
	return;
}
コード例 #5
0
ファイル: slplugin.cpp プロジェクト: mmorciegov/emeraldviewer
int main(int argc, char **argv)
#endif
{
	ll_init_apr();

	// Set up llerror logging
	{
		LLError::initForApplication(".");
		LLError::setDefaultLevel(LLError::LEVEL_INFO);
//		LLError::setTagLevel("Plugin", LLError::LEVEL_DEBUG);
//		LLError::logToFile("slplugin.log");
	}

#if LL_WINDOWS
	if( strlen( lpCmdLine ) == 0 )
	{
		LL_ERRS("slplugin") << "usage: " << "SLPlugin" << " launcher_port" << LL_ENDL;
	};

	U32 port = 0;
	if(!LLStringUtil::convertToU32(lpCmdLine, port))
	{
		LL_ERRS("slplugin") << "port number must be numeric" << LL_ENDL;
	};

	// Insert our exception handler into the system so this plugin doesn't
	// display a crash message if something bad happens. The host app will
	// see the missing heartbeat and log appropriately.
	initExceptionHandler();
#elif LL_DARWIN || LL_LINUX
	if(argc < 2)
	{
		LL_ERRS("slplugin") << "usage: " << argv[0] << " launcher_port" << LL_ENDL;
	}

	U32 port = 0;
	if(!LLStringUtil::convertToU32(argv[1], port))
	{
		LL_ERRS("slplugin") << "port number must be numeric" << LL_ENDL;
	}

	// Catch signals that most kinds of crashes will generate, and exit cleanly so the system crash dialog isn't shown.
	signal(SIGILL, &crash_handler);		// illegal instruction
# if LL_DARWIN
	signal(SIGEMT, &crash_handler);		// emulate instruction executed
# endif // LL_DARWIN
	signal(SIGFPE, &crash_handler);		// floating-point exception
	signal(SIGBUS, &crash_handler);		// bus error
	signal(SIGSEGV, &crash_handler);	// segmentation violation
	signal(SIGSYS, &crash_handler);		// non-existent system call invoked
#endif

#if LL_DARWIN
	setupCocoa();
	createAutoReleasePool();
#endif

	LLPluginProcessChild *plugin = new LLPluginProcessChild();

	plugin->init(port);

#if LL_DARWIN
		deleteAutoReleasePool();
#endif

	LLTimer timer;
	timer.start();

#if LL_WINDOWS
	checkExceptionHandler();
#endif

#if LL_DARWIN
	// If the plugin opens a new window (such as the Flash plugin's fullscreen player), we may need to bring this plugin process to the foreground.
	// Use this to track the current frontmost window and bring this process to the front if it changes.
	WindowRef front_window = NULL;
	WindowGroupRef layer_group = NULL;
	int window_hack_state = 0;
	CreateWindowGroup(kWindowGroupAttrFixedLevel, &layer_group);
	if(layer_group)
	{
		// Start out with a window layer that's way out in front (fixes the problem with the menubar not getting hidden on first switch to fullscreen youtube)
		SetWindowGroupName(layer_group, CFSTR("SLPlugin Layer"));
		SetWindowGroupLevel(layer_group, kCGOverlayWindowLevel);		
	}
#endif

#if LL_DARWIN
	EventTargetRef event_target = GetEventDispatcherTarget();
#endif
	while(!plugin->isDone())
	{
#if LL_DARWIN
		createAutoReleasePool();
#endif
		timer.reset();
		plugin->idle();
#if LL_DARWIN
		{
			// Some plugins (webkit at least) will want an event loop.  This qualifies.
			EventRef event;
			if(ReceiveNextEvent(0, 0, kEventDurationNoWait, true, &event) == noErr)
			{
				SendEventToEventTarget (event, event_target);
				ReleaseEvent(event);
			}
			
			// Check for a change in this process's frontmost window.
			if(FrontWindow() != front_window)
			{
				ProcessSerialNumber self = { 0, kCurrentProcess };
				ProcessSerialNumber parent = { 0, kNoProcess };
				ProcessSerialNumber front = { 0, kNoProcess };
				Boolean this_is_front_process = false;
				Boolean parent_is_front_process = false;
				{
					// Get this process's parent
					ProcessInfoRec info;
					info.processInfoLength = sizeof(ProcessInfoRec);
					info.processName = NULL;
					info.processAppSpec = NULL;
					if(GetProcessInformation( &self, &info ) == noErr)
					{
						parent = info.processLauncher;
					}
					
					// and figure out whether this process or its parent are currently frontmost
					if(GetFrontProcess(&front) == noErr)
					{
						(void) SameProcess(&self, &front, &this_is_front_process);
						(void) SameProcess(&parent, &front, &parent_is_front_process);
					}
				}
								
				if((FrontWindow() != NULL) && (front_window == NULL))
				{
					// Opening the first window
					
					if(window_hack_state == 0)
					{
						// Next time through the event loop, lower the window group layer
						window_hack_state = 1;
					}

					if(layer_group)
					{
						SetWindowGroup(FrontWindow(), layer_group);
					}
					
					if(parent_is_front_process)
					{
						// Bring this process's windows to the front.
						(void) SetFrontProcess( &self );
					}

					ActivateWindow(FrontWindow(), true);					
				}
				else if((FrontWindow() == NULL) && (front_window != NULL))
				{
					// Closing the last window
					
					if(this_is_front_process)
					{
						// Try to bring this process's parent to the front
						(void) SetFrontProcess(&parent);
					}
				}
				else if(window_hack_state == 1)
				{
					if(layer_group)
					{
						// Set the window group level back to something less extreme
						SetWindowGroupLevel(layer_group, kCGNormalWindowLevel);
					}
					window_hack_state = 2;
				}

				front_window = FrontWindow();

			}
		}
#endif
		F64 elapsed = timer.getElapsedTimeF64();
		F64 remaining = plugin->getSleepTime() - elapsed;

		if(remaining <= 0.0f)
		{
			// We've already used our full allotment.
//			LL_INFOS("slplugin") << "elapsed = " << elapsed * 1000.0f << " ms, remaining = " << remaining * 1000.0f << " ms, not sleeping" << LL_ENDL;

			// Still need to service the network...
			plugin->pump();
		}
		else
		{

//			LL_INFOS("slplugin") << "elapsed = " << elapsed * 1000.0f << " ms, remaining = " << remaining * 1000.0f << " ms, sleeping for " << remaining * 1000.0f << " ms" << LL_ENDL;
//			timer.reset();

			// This also services the network as needed.
			plugin->sleep(remaining);

//			LL_INFOS("slplugin") << "slept for "<< timer.getElapsedTimeF64() * 1000.0f << " ms" <<  LL_ENDL;
		}

#if LL_WINDOWS
	// More agressive checking of interfering exception handlers.
	// Doesn't appear to be required so far - even for plugins
	// that do crash with a single call to the intercept
	// exception handler such as QuickTime.
	//checkExceptionHandler();
#endif

#if LL_DARWIN
		deleteAutoReleasePool();
#endif
	}

	delete plugin;

	ll_cleanup_apr();

	return 0;
}
コード例 #6
0
ファイル: carbon_gui.cpp プロジェクト: dyne/MuSE
/* Constructor for CARBON_GUI class. */
CARBON_GUI::CARBON_GUI(int argc, char **argv, Stream_mixer *mix) 
 : GUI(argc,argv,mix) 
{
	/* initialization stuff */
  	jmix = mix;
	memset(myLcd,0,sizeof(myLcd));
	memset(myPos,0,sizeof(myPos));
	vumeter=0;
	vuband=0;
	selectedChannel=NULL;
	memset(channel,0,sizeof(channel));
	playlistManager=new PlaylistManager();
	msgList=new Linklist();
	
	/* init mutex used when accessing the statusbox buffer ...
	 * this is needed because other threads can try to write status messages concurrently
	 */
	if(pthread_mutex_init(&_statusLock,NULL) == -1) {
		error("error initializing POSIX thread mutex creating a new CarbonChannel");
		QuitApplicationEventLoop();
	}
	
	// Create a Nib reference 
    err = CreateNibReference(CFSTR("main"), &nibRef);
	if(err != noErr) error("Can't get NIB reference to obtain gui controls!!");
    
	// Create the MainWindow using nib resource file
    err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window);
	if(err != noErr) {
		error("Can't create MainWindow!!");
		QuitApplicationEventLoop();
	}
	else {
		msg = new CarbonMessage(nibRef);
		/* make the main window also the frontmost one */
		BringToFront(window);
		init_controls();
		
		/* now create the menu to use for the menubar ... it's stored in nib */
		err=CreateMenuFromNib(nibRef,CFSTR("MenuBar"),&mainMenu);
		if(err!=noErr) {
			msg->error("Can't create main menu (%d)!!",err);
		}
		
		/* install vumeter controls */
		setupVumeters();
		/* and the status box */
		setupStatusWindow();
		
		bufferInspector = new BufferInspector(window,nibRef,jmix);
		
		/* now we have to group windows together so if all are visible they will also be layered together */
		err=CreateWindowGroup(kWindowGroupAttrLayerTogether,&mainGroup);
		err=SetWindowGroup(window,mainGroup);
		err=SetWindowGroup(vumeterWindow,mainGroup);
		err=SetWindowGroup(statusWindow,mainGroup);
		err=SetWindowGroup(bufferInspector->window,mainGroup);
		SetWindowGroupOwner(mainGroup,window);
		/* let's create a channel window for each active input channel */
		unsigned int i;
		bool cc=false;
		for (i=0;i<MAX_CHANNELS;i++) {
			strcpy(ch_lcd[i],"00:00:00");
			if(jmix->chan[i]) { 
					CarbonChannel *newChan = new CarbonChannel(jmix,this,nibRef,i);
					channel[i] = newChan;
				/*	
					if(i > 0) {
						RepositionWindow(channel[i]->window,channel[i-1]->window,kWindowCascadeOnParentWindow);
					}
					else {
						RepositionWindow(channel[i],window,kWindowCascadeOnParentWindow);
					}
				*/
					cc=true;
			}
			else {
				channel[i] = NULL;
			}
		}
		/* Ok, once MainWindow has been created and we have instantiated all acrive input channels,
		* we need an instance of CarbonStream to control the stream option window */
		streamHandler = new CarbonStream(jmix,window,nibRef);
		/* by default we want at leat one active channel */
		if(!cc) new_channel();
	
		aboutWindow = new AboutWindow(window,nibRef);
		
		// The window was created hidden so show it.
		ShowWindow( window );
	}
}
コード例 #7
0
ファイル: WindowFun.c プロジェクト: fruitsamples/WindowFun
void	LineTool( WindowRef window )
{
	OSStatus			err;
	Point				endPt;
	MouseTrackingResult	trackingResult;
	Point				beginPt;
	Rect				windowRect;
	WindowRef			overlayWindow;
	CGRect				cgRect;
	CGContextRef		cgContext;
	Boolean				isStillDown		= true;

	SetThemeCursor( kThemeCrossCursor );
	
	SetPortWindowPort( window );
	GetWindowPortBounds( window, &windowRect );
	LocalToGlobalRect( &windowRect );

	(void) CreateNewWindow( kOverlayWindowClass, kWindowHideOnSuspendAttribute | kWindowIgnoreClicksAttribute, &windowRect, &overlayWindow );
	SetPortWindowPort( overlayWindow );
	SetWindowGroup( overlayWindow, GetWindowGroup(window) );					//	This assures we draw into the same layer as the window
	ShowWindow( overlayWindow );

	GetMouse( &beginPt );
	cgRect	= CGRectMake( 0, 0, windowRect.right - windowRect.left+1, windowRect.bottom - windowRect.top+1 );
	CreateCGContextForPort( GetWindowPort(overlayWindow), &cgContext );
	
	CGContextSetLineWidth( cgContext, 3 );										//	Line is 3 pixels wide
	CGContextSetRGBStrokeColor( cgContext, 1.0, .45, .3, .4 );					//	Make it orange with alpha = 0.4
	SyncCGContextOriginWithPort( cgContext, GetWindowPort(overlayWindow) );
	CGContextTranslateCTM( cgContext, 0, windowRect.bottom - windowRect.top );	//	Flip & rotate the context to use QD coordinates
	CGContextScaleCTM( cgContext, 1.0, -1.0 );
    do
	{
		err	= TrackMouseLocation( GetWindowPort(window), &endPt, &trackingResult );
		
		switch ( trackingResult )
		{
			case kMouseTrackingMouseDragged:
				CGContextClearRect( cgContext, cgRect );						//	"Erase" the window
				#if ( 1 )
					CGContextMoveToPoint( cgContext, beginPt.h, beginPt.v );	//	Draw the line
					CGContextAddLineToPoint( cgContext, endPt.h, endPt.v );
					CGContextStrokePath( cgContext );
				#else
					MoveTo( beginPt.h, beginPt.v );								//	We could use QuickDraw and draw opaque lines
					LineTo( endPt.h, endPt.v );
				#endif
				CGContextFlush( cgContext );									//	Flush our drawing to the screen
				break;
			case kMouseTrackingMouseDown:
				break;
			case kMouseTrackingMouseUp:
			case kMouseTrackingUserCancelled:
				isStillDown	= false;
				break;
		}
	} while( isStillDown == true );
	
	CGContextRelease( cgContext );
	DisposeWindow( overlayWindow );
	SetThemeCursor( kThemeArrowCursor );
	return;
}
コード例 #8
0
ファイル: WindowFun.c プロジェクト: fruitsamples/WindowFun
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 );
}
コード例 #9
0
GLboolean
renderspu_SystemVBoxCreateWindow(VisualInfo *visual, GLboolean showIt,
                                 WindowInfo *window)
{
    CRASSERT(visual);
    CRASSERT(window);

    WindowAttributes winAttr = kWindowNoShadowAttribute | kWindowCompositingAttribute | kWindowIgnoreClicksAttribute | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute;
    WindowClass winClass = kOverlayWindowClass;
    Rect windowRect;
    OSStatus status = noErr;

    window->visual = visual;
    window->nativeWindow = NULL;

    if(window->window && IsValidWindowPtr(window->window))
    {
        EventRef evt;
        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxDisposeWindow, 0, kEventAttributeNone, &evt);
        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateEvent Failed", false);
        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): SetEventParameter Failed", false);
        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): PostEventToQueue Failed", false);
    }

    windowRect.left = window->x;
    windowRect.top = window->y;
    windowRect.right = window->x + window->BltInfo.width;
    windowRect.bottom = window->y + window->BltInfo.height;

    status = CreateNewWindow(winClass, winAttr, &windowRect, &window->window);
    CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateNewWindow Failed", GL_FALSE);

    /* We set a title for debugging purposes */
    CFStringRef title_string;
    title_string = CFStringCreateWithCStringNoCopy(NULL, window->title,
                                                   kCFStringEncodingMacRoman, NULL);
    SetWindowTitleWithCFString(window->BltInfo.window, title_string);
    CFRelease(title_string);

    /* The parent has to be in its own group */
    WindowRef parent = NULL;
    if (render_spu_parent_window_id)
    {
        parent = HIViewGetWindow ((HIViewRef)render_spu_parent_window_id);
        SetWindowGroup (parent, render_spu.pParentGroup);

    }

    /* Add the new window to the master group */
    SetWindowGroup(window->window, render_spu.pMasterGroup);

    /* This will be initialized on the first attempt to attach the global
     * context to this new window */
    window->bufferName = -1;
    window->dummyContext = NULL;
    window->hVisibleRegion = 0;

    if(showIt)
        renderspu_SystemShowWindow(window, GL_TRUE);

    crDebug("Render SPU (renderspu_SystemVBoxCreateWindow): actual window (x, y, width, height): %d, %d, %d, %d",
            window->x, window->y, window->BltInfo.width, window->BltInfo.height);

    return GL_TRUE;
}