|
From: John M M. <jo...@us...> - 2004-02-19 04:44:45
|
Update of /cvsroot/squeak/squeak/platforms/Mac OS/vm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29784/squeak/platforms/Mac OS/vm Modified Files: sqMacNSPlugin.c Log Message: 3.7.2b1 Changes for NPSqueak and full screen fixes for Safari 1.2(V125). Add unicode values for classic mac instead of returning historical keycode numbers. Index: sqMacNSPlugin.c =================================================================== RCS file: /cvsroot/squeak/squeak/platforms/Mac OS/vm/sqMacNSPlugin.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** sqMacNSPlugin.c 7 Jan 2004 05:24:10 -0000 1.15 --- sqMacNSPlugin.c 19 Feb 2004 04:34:42 -0000 1.16 *************** *** 168,172 **** extern int thisSession; /* from sqFilePrims.c: */ #if defined ( __APPLE__ ) && defined ( __MACH__ ) ! pthread_mutex_t gEventDrawLock; extern pthread_mutex_t gEventQueueLock; extern TMTask gTMTask; --- 168,172 ---- extern int thisSession; /* from sqFilePrims.c: */ #if defined ( __APPLE__ ) && defined ( __MACH__ ) ! pthread_mutex_t gEventDrawLock,gEventNSAccept; extern pthread_mutex_t gEventQueueLock; extern TMTask gTMTask; *************** *** 587,593 **** Boolean windowActive=true; GrafPtr rememberFrontWindow=null; ! Boolean rememberWindowOnce=true; #if defined ( __APPLE__ ) && defined ( __MACH__ ) pthread_mutex_unlock(&gEventDrawLock); #endif --- 587,594 ---- Boolean windowActive=true; GrafPtr rememberFrontWindow=null; ! Boolean rememberWindowOnce=true; #if defined ( __APPLE__ ) && defined ( __MACH__ ) + pthread_mutex_lock(&gEventNSAccept); pthread_mutex_unlock(&gEventDrawLock); #endif *************** *** 611,614 **** --- 612,618 ---- exitRequested = false; ExitCleanup(); + #if defined ( __APPLE__ ) && defined ( __MACH__ ) + pthread_mutex_unlock(&gEventNSAccept); + #endif return false; } *************** *** 616,619 **** --- 620,626 ---- if ((thisInstance == nil) || (eventPtr == NULL)) { /* no instance or no event; do nothing */ + #if defined ( __APPLE__ ) && defined ( __MACH__ ) + pthread_mutex_unlock(&gEventNSAccept); + #endif return false; } *************** *** 691,701 **** break; ! case activateEvt: ! ! ! break; ! ! ! case nullEvent: { if(inputSemaphoreIndex && windowActive) { --- 698,702 ---- break; ! case nullEvent : { if(inputSemaphoreIndex && windowActive) { *************** *** 714,743 **** } break; } } if (needsUpdate && (netscapeWindow != nil) && (memory)) { if (getFullScreenFlag()) { ! BeginUpdate((WindowPtr) eventPtr->message); } ! fullDisplayUpdate(); /* ask VM to call ioShowDisplay */ ! ! if (getFullScreenFlag()) { ! EndUpdate((WindowPtr) eventPtr->message); ! } ! needsUpdate = false; } if(postMessageHook) postMessageHook(eventPtr); ! if (ignoreFirstEvent && getFullScreenFlag()) { ignoreFirstEvent = false; #if defined ( __APPLE__ ) && defined ( __MACH__ ) pthread_mutex_lock(&gEventDrawLock); #endif ! return true; ! } ! if (getFullScreenFlag()) { ok = WaitNextEvent(everyEvent, &theEvent,1,null); eventPtr = &theEvent; SqueakYieldToAnyThread(); --- 715,783 ---- } break; + case activateEvt: + #if defined ( __APPLE__ ) && defined ( __MACH__ ) + { + /* serious hack to show safari after hiding, + issue with safari 1.1.1 not seeing activate when full screen terminates */ + + ProcessSerialNumber psn = { 0, kCurrentProcess }; + OSStatus err; + if (!IsProcessVisible(&psn)) { + err = ShowHideProcess (&psn,true); + SetFrontProcess(&psn); + } + } + pthread_mutex_lock(&gEventDrawLock); + pthread_mutex_unlock(&gEventNSAccept); + #endif + return false; + break; } } if (needsUpdate && (netscapeWindow != nil) && (memory)) { + needsUpdate = false; if (getFullScreenFlag()) { ! //BeginUpdate((WindowPtr) eventPtr->message); ! BeginUpdate(FrontWindow()); ! fullDisplayUpdate(); /* ask VM to call ioShowDisplay */ ! EndUpdate(FrontWindow()); ! //EndUpdate((WindowPtr) eventPtr->message); ! pthread_mutex_lock(&gEventDrawLock); ! pthread_mutex_unlock(&gEventNSAccept); ! return true; } + else { + fullDisplayUpdate(); /* ask VM to call ioShowDisplay */ + } + if (!getFullScreenFlag()) { + ProcessSerialNumber psn = { 0, kCurrentProcess }; + OSStatus err; + err = ShowHideProcess (&psn,true); + waitAFewMilliseconds(); ! #if defined ( __APPLE__ ) && defined ( __MACH__ ) ! pthread_mutex_lock(&gEventDrawLock); ! pthread_mutex_unlock(&gEventNSAccept); ! #endif ! return false; ! } } if(postMessageHook) postMessageHook(eventPtr); ! /* JMM HUH if (ignoreFirstEvent && getFullScreenFlag()) { ignoreFirstEvent = false; #if defined ( __APPLE__ ) && defined ( __MACH__ ) pthread_mutex_lock(&gEventDrawLock); + pthread_mutex_unlock(&gEventNSAccept); #endif ! return false; ! } */ ! if (getFullScreenFlag()) { ! pthread_mutex_lock(&gEventDrawLock); ! pthread_mutex_unlock(&gEventNSAccept); ok = WaitNextEvent(everyEvent, &theEvent,1,null); + pthread_mutex_unlock(&gEventDrawLock); + pthread_mutex_lock(&gEventNSAccept); eventPtr = &theEvent; SqueakYieldToAnyThread(); *************** *** 748,751 **** --- 788,792 ---- #if defined ( __APPLE__ ) && defined ( __MACH__ ) pthread_mutex_lock(&gEventDrawLock); + pthread_mutex_unlock(&gEventNSAccept); #endif return true; *************** *** 1183,1186 **** --- 1224,1228 ---- dominantGDevice = getDominateDevice(stWindow,&windRect); #endif + setFullScreenFlag(true); //JMM Moved before to test BeginFullScreen (&gRestorableStateForScreen, dominantGDevice, *************** *** 1190,1194 **** nil, fullScreenAllowEvents); - setFullScreenFlag(true); stWindow = gAFullscreenWindow; gFullScreenNPPort.port = GetWindowPort(gAFullscreenWindow); --- 1232,1235 ---- *************** *** 1217,1220 **** --- 1258,1264 ---- int ioSetFullScreenRestore() { + ProcessSerialNumber psn = { 0, kCurrentProcess }; + OSErr err; + if (gRestorableStateForScreen != nil) { EndFullScreen(gRestorableStateForScreen,nil); *************** *** 1224,1227 **** --- 1268,1274 ---- netscapeWindow = oldNetscapeWindow; stWindow = oldStWindow; + + err = ShowHideProcess (&psn,false); + waitAFewMilliseconds(); } } *************** *** 1870,1872 **** --- 1917,2006 ---- err = pthread_mutex_unlock(&sleepLock); } + + /* LowRunAppleScript compiles and runs an AppleScript + provided as text in the buffer pointed to by text. textLength + bytes will be compiled from this buffer and run as an AppleScript + using all of the default environment and execution settings. If + resultData is not NULL, then the result returned by the execution + command will be returned as typeChar in this descriptor record + (or typeNull if there is no result information). If the function + returns errOSAScriptError, then resultData will be set to a + descriptive error message describing the error (if one is + available). */ + static OSStatus LowRunAppleScript(const void* text, long textLength, + AEDesc *resultData) { + ComponentInstance theComponent; + AEDesc scriptTextDesc; + OSStatus err; + OSAID scriptID, resultID; + + /* set up locals to a known state */ + theComponent = NULL; + AECreateDesc(typeNull, NULL, 0, &scriptTextDesc); + scriptID = kOSANullScript; + resultID = kOSANullScript; + + /* open the scripting component */ + theComponent = OpenDefaultComponent(kOSAComponentType, + typeAppleScript); + if (theComponent == NULL) { err = paramErr; goto bail; } + + /* put the script text into an aedesc */ + err = AECreateDesc(typeChar, text, textLength, &scriptTextDesc); + if (err != noErr) goto bail; + + /* compile the script */ + err = OSACompile(theComponent, &scriptTextDesc, + kOSAModeNull, &scriptID); + if (err != noErr) goto bail; + + /* run the script */ + err = OSAExecute(theComponent, scriptID, kOSANullScript, + kOSAModeNull, &resultID); + + /* collect the results - if any */ + if (resultData != NULL) { + AECreateDesc(typeNull, NULL, 0, resultData); + if (err == errOSAScriptError) { + OSAScriptError(theComponent, kOSAErrorMessage, + typeChar, resultData); + } else if (err == noErr && resultID != kOSANullScript) { + OSADisplay(theComponent, resultID, typeChar, + kOSAModeNull, resultData); + } + } + bail: + AEDisposeDesc(&scriptTextDesc); + if (scriptID != kOSANullScript) OSADispose(theComponent, scriptID); + if (resultID != kOSANullScript) OSADispose(theComponent, resultID); + if (theComponent != NULL) CloseComponent(theComponent); + return err; + } + + + /* SimpleRunAppleScript compiles and runs the AppleScript in + the c-style string provided as a parameter. The result returned + indicates the success of the operation. */ + static OSStatus SimpleRunAppleScript(const char* theScript) { + return LowRunAppleScript(theScript, strlen(theScript), NULL); + } + + static pokeAtSafari(void) { + SimpleRunAppleScript( + "tell application \"Finder\"\n" + " activate\n" + " select folder \"Documents\" of startup disk\n" + " open selection\n" + "end tell"); + } + + /* example: + SimpleRunAppleScript( + "tell application \"Finder\"\n" + " activate\n" + " select folder \"Documents\" of startup disk\n" + " open selection\n" + "end tell"); + */ + #endif \ No newline at end of file |