diff options
author | Guido van Rossum <guido@python.org> | 1991-01-16 14:06:18 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-01-16 14:06:18 (GMT) |
commit | e8e7cf49c5b8aabaa0e58e163690662769474718 (patch) | |
tree | 6e680a8dbb6e8ef28d99caf4c642ba8120b8015a /Modules/stdwinmodule.c | |
parent | 875eb7d9c2a06118b211b69fee30b5b14fbab9f8 (diff) | |
download | cpython-e8e7cf49c5b8aabaa0e58e163690662769474718.zip cpython-e8e7cf49c5b8aabaa0e58e163690662769474718.tar.gz cpython-e8e7cf49c5b8aabaa0e58e163690662769474718.tar.bz2 |
Added pollevent(); returns None if no event available.
Don't throw away key events with no window.
Diffstat (limited to 'Modules/stdwinmodule.c')
-rw-r--r-- | Modules/stdwinmodule.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c index da511ec..5403fb7 100644 --- a/Modules/stdwinmodule.c +++ b/Modules/stdwinmodule.c @@ -1282,8 +1282,8 @@ stdwin_open(sw, args) } static object * -stdwin_getevent(sw, args) - object *sw; +stdwin_get_poll_event(poll, args) + int poll; object *args; { EVENT e; @@ -1294,15 +1294,24 @@ stdwin_getevent(sw, args) err_setstr(RuntimeError, "cannot getevent() while drawing"); return NULL; } - again: - wgetevent(&e); +/* again: */ + if (poll) { + if (!wpollevent(&e)) { + INCREF(None); + return None; + } + } + else + wgetevent(&e); if (e.type == WE_COMMAND && e.u.command == WC_CANCEL) { /* Turn keyboard interrupts into exceptions */ err_set(KeyboardInterrupt); return NULL; } +/* if (e.window == NULL && (e.type == WE_COMMAND || e.type == WE_CHAR)) goto again; +*/ if (e.type == WE_COMMAND && e.u.command == WC_CLOSE) { /* Turn WC_CLOSE commands into WE_CLOSE events */ e.type = WE_CLOSE; @@ -1323,11 +1332,15 @@ stdwin_getevent(sw, args) w = None; else w = (object *)windowlist[tag]; +#ifdef sgi + /* XXX Trap for unexplained weird bug */ + if ((long)w == (long)0x80000001) { + err_setstr(SystemError, + "bad pointer in stdwin.getevent()"); + return NULL; + } +#endif } -if ((long)w == (long)0x80000001) { -err_setstr(SystemError, "bad pointer in stdwin.getevent()"); -return NULL; -} INCREF(w); settupleitem(v, 1, w); switch (e.type) { @@ -1378,6 +1391,22 @@ return NULL; } static object * +stdwin_getevent(sw, args) + object *sw; + object *args; +{ + return stdwin_get_poll_event(0, args); +} + +static object * +stdwin_pollevent(sw, args) + object *sw; + object *args; +{ + return stdwin_get_poll_event(1, args); +} + +static object * stdwin_setdefwinpos(sw, args) object *sw; object *args; @@ -1584,6 +1613,7 @@ static struct methodlist stdwin_methods[] = { {"menucreate", stdwin_menucreate}, {"message", stdwin_message}, {"open", stdwin_open}, + {"pollevent", stdwin_pollevent}, {"resetselection", stdwin_resetselection}, {"rotatecutbuffers", stdwin_rotatecutbuffers}, {"setcutbuffer", stdwin_setcutbuffer}, |