shelljuggler.c

Go to the documentation of this file.
00001 
00002 /*  $Id: shelljuggler.c 1292 2006-04-17 17:52:12Z andreradke $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "memory.h"
00032 #include "cursor.h"
00033 #include "launch.h"
00034 #include "scrap.h"
00035 #include "shell.h"
00036 #include "shellprivate.h"
00037 #include "langinternal.h"
00038 #include "scripts.h"
00039 #include "process.h"
00040 
00041 
00042 
00043 static boolean flshellactive = true; /*under multifinder, are we in the foreground?*/
00044 
00045 
00046 
00047 
00048 boolean shellisactive (void) {
00049     
00050     return (flshellactive);
00051     } /*shellisactive*/
00052 
00053 
00054 boolean shellactivate (void) {
00055     
00056     /*
00057     2/10/92 dmb: added entrypoint for shellsysverbs and dialog operations
00058     
00059     1/22/93 dmb: use langpartialeventloop when a script is running
00060     
00061     2.1b12 dmb: don't return quickly if shellactive is true. we may be 
00062     trying to bring a client process to the front. besided, the overhead 
00063     of activating an already-active application is small, and this isn't 
00064     a performance bottleneck anyway.
00065     */
00066     
00067     /*
00068     if (flshellactive)
00069         return (true);
00070     */
00071     
00072     if (!activateapplication (nil)) /*bring ourselves to the front*/
00073         return (false);
00074     
00075     #ifdef flcomponent
00076     
00077     if (fldisableyield)
00078         return (true);
00079     
00080     #endif
00081 
00082 #ifdef MACVERSION
00083     while (!flshellactive) { /*wait 'till we're actually in front*/
00084         
00085         if (flscriptrunning)
00086             langpartialeventloop (osMask | updateMask | activMask);
00087         else
00088             shellpartialeventloop (osMask | updateMask | activMask);
00089         }
00090 #endif
00091     
00092     return (true);
00093 } /*shellactivate*/
00094 
00095 
00096 static boolean shelljugglervisit (WindowPtr w, ptrvoid refcon) {
00097 #pragma unused (refcon)
00098 
00099     shellpushglobals (w);
00100     
00101     (*shellglobals.resumeroutine) (flshellactive);
00102     
00103     shellpopglobals ();
00104     
00105     return (true);
00106     } /*shelljugglervisit*/
00107     
00108     
00109 void shellhandlejugglerevent (void) {
00110     
00111     /*
00112     7/13/90 DW: deactivate the front window when we're swapped into the
00113     background on a juggler event.  activate it when we're swapped back 
00114     into the foreground.
00115 
00116     2006-04-17 aradke: updated for Intel Macs using endianness-agnostic code
00117     */
00118     
00119     register boolean flresume;
00120     long message = shellevent.message;
00121     
00122     if (((message >> 24) & 0xff) == suspendResumeMessage) { /*suspend or resume subevent*/
00123         
00124         boolean fl;
00125         
00126         flresume = ((message & resumeFlag) != 0); /*copy into register*/
00127         
00128         flshellactive = flresume; /*set global*/
00129         
00130         if (flresume) { /*force update of mouse cursor*/
00131         
00132             setcursortype (cursorisdirty); /*we don't know what state it's in*/
00133             
00134             shellforcecursoradjust (); /*make it appear as if mouse moved*/
00135             }
00136         
00137         fl = shellpushfrontglobals ();
00138         
00139         if (fl)
00140             shellactivatewindow (shellwindow, flshellactive);
00141 
00142         #if defined(TARGET_API_MAC_OS8) && (TARGET_API_MAC_OS8 == 1)
00143             /*
00144             2006-04-17 aradke: convertClipboardFlag is never set on Carbon
00145             */
00146             
00147             if ((message & convertClipboardFlag) != 0) {
00148                 
00149                 if (flresume)
00150                     ; /*shellreadscrap ()*/ /*12/28/90 dmb: see comment in shellreadscrap*/
00151                 else
00152                     shellwritescrap (anyscraptype);
00153                 }
00154         #endif
00155         
00156         if (fl)
00157             shellpopglobals ();
00158         
00159         /* 4.0b7 dmb: new feature, just like startup & shutdown scripts */
00160         if (flresume)
00161             scriptrunresumescripts ();
00162         else
00163             scriptrunsuspendscripts ();
00164         
00165         shellvisittypedwindows (-1, &shelljugglervisit, nil); /*send message to all open windows*/
00166         }
00167     } /*shellhandlejugglerevent*/
00168     
00169     

Generated on Wed May 31 18:20:01 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6