Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c96887

Browse files
committed
Handle systemclicks ourselves, in stead of passing them to Sioux. This
fixes (or masks?) a bug with Python becoming unreactive during time.sleep() if you have already switched applications before.
1 parent 0cdb887 commit 0c96887

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

Mac/Python/macglue.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9292
** handle them). Note that we don't know who has windows open, so
9393
** even handing updates off to SIOUX under MW isn't going to work.
9494
*/
95-
#define MAINLOOP_EVENTMASK (mDownMask|keyDownMask|osMask)
95+
#define MAINLOOP_EVENTMASK (mDownMask|keyDownMask|osMask|activMask)
9696

9797
#include <signal.h>
9898

@@ -476,6 +476,14 @@ void
476476
PyMac_HandleEventIntern(evp)
477477
EventRecord *evp;
478478
{
479+
if ( evp->what == mouseDown ) {
480+
WindowPtr wp;
481+
482+
if ( FindWindow(evp->where, &wp) == inSysWindow ) {
483+
SystemClick(evp, wp);
484+
return;
485+
}
486+
}
479487
#ifdef __MWERKS__
480488
{
481489
int siouxdidit;
@@ -486,15 +494,7 @@ PyMac_HandleEventIntern(evp)
486494
return;
487495
}
488496
#else
489-
/* Other compilers are just unlucky: we only weed out clicks in other applications */
490-
if ( evp->what == mouseDown ) {
491-
WindowPtr wp;
492-
493-
if ( FindWindow(evp->where, &wp) == inSysWindow ) {
494-
SystemClick(evp, wp);
495-
return;
496-
}
497-
}
497+
/* Other compilers are just unlucky... */
498498
#endif /* !__MWERKS__ */
499499
}
500500

@@ -557,6 +557,11 @@ PyMac_DoYield(int maxsleep, int maycallpython)
557557
} else {
558558
latest_time_ready = LMGetTicks() + maxsleep;
559559
while ( maxsleep >= 0 ) {
560+
/* XXXX Hack by Jack.
561+
** In time.sleep() you can click to another application
562+
** once only. If you come back to Python you cannot get away
563+
** again.
564+
**/
560565
gotone = WaitNextEvent(schedparams.process_events, &ev, maxsleep, NULL);
561566
/* Get out quickly if nothing interesting is happening */
562567
if ( !gotone || ev.what == nullEvent )

0 commit comments

Comments
 (0)