summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1995-02-02 14:25:56 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1995-02-02 14:25:56 (GMT)
commita76382a6ac56b35def05f23740e55dc064eb15e7 (patch)
tree422f6be5564e54f4d9e9a58a0903d7b2f66606c0 /Mac
parent8828fcf7383aa38539fd331d9b93138c156f8810 (diff)
downloadcpython-a76382a6ac56b35def05f23740e55dc064eb15e7.zip
cpython-a76382a6ac56b35def05f23740e55dc064eb15e7.tar.gz
cpython-a76382a6ac56b35def05f23740e55dc064eb15e7.tar.bz2
Added HandleEvent method to macos, so python programs can hand back
events they don't want to handle to stdio
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Include/macglue.h3
-rw-r--r--Mac/Modules/macosmodule.c14
-rw-r--r--Mac/Python/macglue.c35
3 files changed, 39 insertions, 13 deletions
diff --git a/Mac/Include/macglue.h b/Mac/Include/macglue.h
index b61a78e..7944471 100644
--- a/Mac/Include/macglue.h
+++ b/Mac/Include/macglue.h
@@ -37,7 +37,8 @@ int PyMac_Idle Py_PROTO((void)); /* Idle routine */
void PyMac_Yield Py_PROTO((void)); /* optional idle routine for mainloop */
void PyMac_SetYield Py_PROTO((long, long, long, long)); /* Set timeouts */
PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */
-PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */
+PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */
+void PyMac_HandleEvent Py_PROTO((EventRecord *)); /* Handle one event, if possible */
int PyMac_Idle(void); /* Idle routine */
diff --git a/Mac/Modules/macosmodule.c b/Mac/Modules/macosmodule.c
index 2b98fc6..ceb8a96 100644
--- a/Mac/Modules/macosmodule.c
+++ b/Mac/Modules/macosmodule.c
@@ -202,6 +202,19 @@ MacOS_EnableAppswitch(PyObject *self, PyObject *args)
return Py_None;
}
+
+static PyObject *
+MacOS_HandleEvent(PyObject *self, PyObject *args)
+{
+ EventRecord ev;
+
+ if (!PyArg_ParseTuple(args, "O&", PyMac_GetEventRecord, &ev))
+ return NULL;
+ PyMac_HandleEvent(&ev);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyMethodDef MacOS_Methods[] = {
{"AcceptHighLevelEvent", MacOS_AcceptHighLevelEvent, 1},
{"GetCreatorAndType", MacOS_GetCreatorAndType, 1},
@@ -211,6 +224,7 @@ static PyMethodDef MacOS_Methods[] = {
#endif
{"SetScheduleTimes", MacOS_SetScheduleTimes, 1},
{"EnableAppswitch", MacOS_EnableAppswitch, 1},
+ {"HandleEvent", MacOS_HandleEvent, 1},
{NULL, NULL} /* Sentinel */
};
diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c
index a99023b..98a5c7b 100644
--- a/Mac/Python/macglue.c
+++ b/Mac/Python/macglue.c
@@ -267,13 +267,34 @@ PyMac_SetYield(long fgi, long fgy, long bgi, long bgy)
}
/*
+** Handle an event, either one found in the mainloop eventhandler or
+** one passed back from the python program.
+*/
+void
+PyMac_HandleEvent(evp)
+ EventRecord *evp;
+{
+ WindowPtr wp;
+
+#ifdef __MWERKS__
+ /* If SIOUX wants it we're done */
+ (void)SIOUXHandleOneEvent(evp);
+#else
+ /* Other compilers are just unlucky: we only weed out clicks in other applications */
+ if ( evp->what == mouseDown ) {
+ if ( FindWindow(evp->where, &wp) == inSysWindow )
+ SystemClick(evp, wp);
+ }
+#endif /* !__MWERKS__ */
+}
+
+/*
** Yield the CPU to other tasks.
*/
static
PyMac_DoYield()
{
EventRecord ev;
- WindowPtr wp;
long yield;
static int no_waitnextevent = -1;
int gotone;
@@ -306,17 +327,7 @@ PyMac_DoYield()
/* Get out quickly if nothing interesting is happening */
if ( !gotone || ev.what == nullEvent )
break;
-
-#ifdef __MWERKS__
- /* If SIOUX wants it we're done too */
- (void)SIOUXHandleOneEvent(&ev);
-#else
- /* Other compilers are just unlucky: we only weed out clicks in other applications */
- if ( ev.what == mouseDown ) {
- if ( FindWindow(ev.where, &wp) == inSysWindow )
- SystemClick(&ev, wp);
- }
-#endif /* !__MWERKS__ */
+ PyMac_HandleEvent(&ev);
}
lastyield = TickCount();
}