[cig-commits] commit: adding in a hack to the Carbon windowing so that it works when you turn interactivity off half-way through.
Mercurial
hg at geodynamics.org
Mon Nov 24 11:29:19 PST 2008
changeset: 49:057c33e289f9
user: RobertTurnbull
date: Thu Mar 13 06:46:13 2008 +0000
files: Windowing/src/CarbonWindow.c Windowing/src/CarbonWindow.h
description:
adding in a hack to the Carbon windowing so that it works when you turn interactivity off half-way through.
rob
diff -r 3ad1e6f94108 -r 057c33e289f9 Windowing/src/CarbonWindow.c
--- a/Windowing/src/CarbonWindow.c Thu Mar 06 07:14:04 2008 +0000
+++ b/Windowing/src/CarbonWindow.c Thu Mar 13 06:46:13 2008 +0000
@@ -254,9 +254,15 @@ void _lucCarbonWindow_ExecuteInteractive
}
/* Broadcast information about loop */
- MPI_Bcast( &self->quitEventLoop, 1, MPI_INT, MASTER, context->communicator );
- MPI_Bcast( &self->interactive, 1, MPI_INT, MASTER, context->communicator );
- MPI_Bcast( &self->windowIsVisible, 1, MPI_INT, MASTER, context->communicator );
+ MPI_Bcast( &self->quitEventLoop, 1, MPI_INT, MASTER, context->communicator );
+ MPI_Bcast( &self->interactive, 1, MPI_INT, MASTER, context->communicator );
+ MPI_Bcast( &self->windowIsVisible, 1, MPI_INT, MASTER, context->communicator );
+ MPI_Bcast( &self->hackNonInteractive, 1, MPI_INT, MASTER, context->communicator );
+
+ if (self->hackNonInteractive) {
+ lucCarbonWindow_Draw(self);
+ break;
+ }
if (self->windowIsVisible) {
lucCarbonWindow_Draw(self);
@@ -385,18 +391,23 @@ void lucCarbonWindow_CreateInteractiveWi
thandler = NewEventLoopTimerUPP((void (*)(EventLoopTimerRef, void *)) lucCarbonWindow_IdleFunc );
InstallEventLoopTimer(GetMainEventLoop(), 0, 0, thandler, 0, &timer);
- GetCurrentProcess(&psn);
- /* this is a secret undocumented Mac function that allows code that isn't part of a bundle to be a foreground operation */
- CPSEnableForegroundOperation( &psn );
- SetFrontProcess( &psn );
-
- /* Window operations - Not all of these are nessesary */
- DrawGrowIcon(window);
- ShowWindow(window);
- SetUserFocusWindow( window );
- BringToFront( window );
- ActivateWindow( window, true );
- SelectWindow(window);
+ /* This hack with the 'if' condition is to make the CarbonWindowing code not crash if it starts with an interactive window then starts to use a non-interactive window - if it was originally interactive it must continue to use the same windowing code, but we will just arrange so that it doesn't show up for the user */
+ if ( ! self->hackNonInteractive ) {
+ GetCurrentProcess(&psn);
+ /* this is a secret undocumented Mac function that allows code that isn't part of a bundle to be a foreground operation */
+ CPSEnableForegroundOperation( &psn );
+ SetFrontProcess( &psn );
+
+ /* Window operations - Not all of these are nessesary */
+ DrawGrowIcon(window);
+ ShowWindow(window);
+ SetUserFocusWindow( window );
+ BringToFront( window );
+ ActivateWindow( window, true );
+ SelectWindow(window);
+
+ lucWindow_InteractionHelpMessage( self, Journal_MyStream( Info_Type, self ) );
+ }
/* Create the OpenGL context and bind it to the window. */
format = aglChoosePixelFormat(NULL, 0, attributes);
@@ -411,9 +422,6 @@ void lucCarbonWindow_CreateInteractiveWi
self->timerHandler = thandler;
self->handler = handler;
self->window = window;
-
- lucWindow_InteractionHelpMessage( self, Journal_MyStream( Info_Type, self ) );
-
}
/* Steps taken from http://gemma.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/OpenGLProg_MacOSX.pdf */
@@ -470,11 +478,15 @@ void lucCarbonWindow_DestroyWindow( void
lucCarbonWindow* self = (lucCarbonWindow*) carbonWindow;
if ( self->windowIsInteractive ) {
- aglDestroyContext( self->graphicsContext );
RemoveEventLoopTimer( self->timer );
DisposeEventLoopTimerUPP( self->timerHandler );
DisposeEventHandlerUPP( self->handler );
DisposeWindow( self->window );
+
+ aglSetDrawable( self->graphicsContext, 0 );
+ aglSetCurrentContext( 0 );
+ aglDestroyContext( self->graphicsContext );
+ self->graphicsContext = NULL;
}
else {
CGLContextObj contextObj = (CGLContextObj) self->graphicsContext;
@@ -551,6 +563,12 @@ static pascal OSStatus lucCarbonWindow_E
lucCarbonWindow_GetPixelIndicies( self, &point, &xPos, &yPos );
lucWindow_KeyboardEvent( self, key, xPos, yPos );
+ /* HACK */
+ if ( key == 'i' ) {
+ self->interactive = true;
+ self->hackNonInteractive = true;
+ self->quitEventLoop = true;
+ }
}
}
else if ( eventClass == kEventClassMouse ) {
diff -r 3ad1e6f94108 -r 057c33e289f9 Windowing/src/CarbonWindow.h
--- a/Windowing/src/CarbonWindow.h Thu Mar 06 07:14:04 2008 +0000
+++ b/Windowing/src/CarbonWindow.h Thu Mar 13 06:46:13 2008 +0000
@@ -66,6 +66,7 @@
int fontSize; \
/* Stuff for interactive windows */ \
Bool windowIsInteractive; \
+ Bool hackNonInteractive; \
void* handler; \
void* timerHandler; \
void* timer; \
More information about the CIG-COMMITS
mailing list