]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
- Raise console window on input. Fixes Carbon hang.
authorJack Jansen <jack.jansen@cwi.nl>
Wed, 25 Apr 2001 22:07:27 +0000 (22:07 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Wed, 25 Apr 2001 22:07:27 +0000 (22:07 +0000)
- Better handling of menu bar save/restore.
- Override abort() so it honours the "keep console window" flag.

Mac/Python/macglue.c
Mac/Python/macmain.c
Mac/Python/pyGUSISIOUX.cp

index 52bc22584ee00b88ca14a4acebdd2cd6d3dec88d..5579735b1a9a0ed73b15b5971f36ca3d4badb9da 100644 (file)
@@ -685,11 +685,13 @@ PyMac_DoYield(int maxsleep, int maycallpython)
        */
        if( in_here > 1 || !schedparams.process_events || 
            (python_event_handler && !maycallpython) ) {
-#if !TARGET_API_MAC_CARBON
                if ( maxsleep >= 0 ) {
+#if !TARGET_API_MAC_CARBON
                        SystemTask();
-               }
+#else
+                       int xxx = 0;
 #endif
+               }
        } else {
                latest_time_ready = LMGetTicks() + maxsleep;
                do {
@@ -768,6 +770,7 @@ PyMac_InitMenuBar()
 {
        MenuHandle applemenu;
        
+       if ( sioux_mbar ) return;
        if ( (sioux_mbar=GetMenuBar()) == NULL )  {
                /* Sioux menu not installed yet. Do so */
                SIOUXSetupMenus();
@@ -784,7 +787,7 @@ PyMac_InitMenuBar()
 void
 PyMac_RestoreMenuBar()
 {
-#if 0
+#if 1
        /* This doesn't seem to work anymore? Or only for Carbon? */
        MenuBarHandle curmenubar;
        
@@ -799,6 +802,19 @@ PyMac_RestoreMenuBar()
 #endif
 }
 
+void
+PyMac_RaiseConsoleWindow()
+{
+       /* Note: this is a hack. SIOUXTextWindow is SIOUX's internal structure
+       ** and we happen to know that the first entry is the window pointer.
+       */
+       extern WindowRef *SIOUXTextWindow;
+
+       if ( SIOUXTextWindow == NULL || *SIOUXTextWindow == NULL )
+               return;
+       if ( FrontWindow() != *SIOUXTextWindow )
+               BringToFront(*SIOUXTextWindow);
+}
 
 /*
 ** Our replacement about box
index bb798f2b993282e1f450ff41a04e8a886b9c2875..1d5500f483d029400f37510ce013674119a846db 100644 (file)
@@ -567,7 +567,16 @@ PyMac_OutputNotSeen()
                PyMac_InitMenuBar();
        console_output_state = STATE_LASTWRITE;
 }
-       
+
+/*
+** Override abort() - The default one is not what we want.
+*/
+void
+abort()
+{
+       console_output_state = STATE_LASTWRITE;
+       PyMac_Exit(1);
+}
 
 /*
 ** Terminate application
@@ -605,6 +614,7 @@ PyMac_Exit(status)
                SIOUXSettings.standalone = 1;
                SIOUXSettings.autocloseonquit = 0;
                SIOUXSetTitle("\p\307terminated\310");
+               PyMac_RaiseConsoleWindow();
                PyMac_RestoreMenuBar();
 #ifdef USE_MSL
                /*
index 795e10e0e47b0a88017450fd073b39eb93940f6d..f26216b83ae5a0b8a4411ce472164c45c1b980b6 100644 (file)
@@ -102,6 +102,7 @@ GUSISIOUXSocket::Initialize()
        GUSISetHook(GUSI_EventHook+diskEvt,     (GUSIHook)SIOUXHandleOneEvent);
        GUSISetHook(GUSI_EventHook+activateEvt, (GUSIHook)SIOUXHandleOneEvent);
        GUSISetHook(GUSI_EventHook+osEvt,               (GUSIHook)SIOUXHandleOneEvent);
+       PyMac_InitMenuBar();
 }
 GUSISIOUXSocket::~GUSISIOUXSocket()
 {
@@ -113,6 +114,7 @@ ssize_t GUSISIOUXSocket::read(const GUSIScatterer & buffer)
        if ( !initialized ) Initialize();
        GUSIStdioFlush();
        PyMac_OutputSeen();
+       PyMac_RaiseConsoleWindow();
        return buffer.SetLength(
                ReadCharsFromConsole((char *) buffer.Buffer(), (int)buffer.Length()));
        GUSIContext::Yield(kGUSIPoll);