Mercurial > cpython-lru_cache-weakref
diff Modules/stdwinmodule.c @ 252:6811912f672d legacy-trunk
Don't suppress wsetfont("");
Don't report WE_MENU events with None as menu pointer;
Added stdwin.getactie() function;
Moved code to turn WINDOW* into windowobject* to a separate function.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 03 Jun 1991 10:55:14 +0000 |
| parents | 9eb13c67ae6f |
| children | 85bd7dac13f3 |
line wrap: on
line diff
--- a/Modules/stdwinmodule.c Mon Jun 03 10:54:55 1991 +0000 +++ b/Modules/stdwinmodule.c Mon Jun 03 10:55:14 1991 +0000 @@ -628,8 +628,7 @@ err_badarg(); return NULL; } - if (getstringsize(font) != 0) - wsetfont(getstringvalue(font)); + wsetfont(getstringvalue(font)); if (style != NULL) { switch (*getstringvalue(style)) { case 'b': @@ -1640,6 +1639,33 @@ } static object * +window2object(win) + WINDOW *win; +{ + object *w; + if (win == NULL) + w = None; + else { + int tag = wgettag(win); + if (tag < 0 || tag >= MAXNWIN || windowlist[tag] == NULL || + windowlist[tag]->w_win != win) + 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 + } + INCREF(w); + return w; +} + +static object * stdwin_get_poll_event(poll, args) int poll; object *args; @@ -1652,7 +1678,7 @@ err_setstr(RuntimeError, "cannot getevent() while drawing"); return NULL; } -/* again: */ + again: if (poll) { if (!wpollevent(&e)) { INCREF(None); @@ -1666,10 +1692,6 @@ 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; @@ -1682,25 +1704,7 @@ return NULL; } settupleitem(v, 0, w); - if (e.window == NULL) - w = None; - else { - int tag = wgettag(e.window); - if (tag < 0 || tag >= MAXNWIN || windowlist[tag] == NULL) - 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 - } - INCREF(w); - settupleitem(v, 1, w); + settupleitem(v, 1, window2object(e.window)); switch (e.type) { case WE_CHAR: { @@ -1728,8 +1732,14 @@ if (e.u.m.id >= IDOFFSET && e.u.m.id < IDOFFSET+MAXNMENU && menulist[e.u.m.id - IDOFFSET] != NULL) w = (object *)menulist[e.u.m.id - IDOFFSET]; - else - w = None; + else { + /* Ghost menu event. + Can occur only on the Mac if another part + of the aplication has installed a menu; + like the THINK C console library. */ + DECREF(v); + goto again; + } w = makemenu(w, e.u.m.item); break; case WE_LOST_SEL: @@ -1948,6 +1958,14 @@ } static object * +stdwin_getactive(self, args) + object *self; + object *args; +{ + return window2object(wgetactive()); +} + +static object * stdwin_getcutbuffer(self, args) object *self; object *args; @@ -2050,6 +2068,7 @@ {"askync", stdwin_askync}, {"fetchcolor", stdwin_fetchcolor}, {"fleep", stdwin_fleep}, + {"getactive", stdwin_getactive}, {"getcutbuffer", stdwin_getcutbuffer}, {"getdefscrollbars", stdwin_getdefscrollbars}, {"getdefwinpos", stdwin_getdefwinpos},
