summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-06-03 10:55:14 (GMT)
committerGuido van Rossum <guido@python.org>1991-06-03 10:55:14 (GMT)
commit246b9d8258e7d7adbeed152a6377a6b541ad2020 (patch)
treefc16577d48d0979f63130f95f0dca0f1efc199f0 /Modules
parent76ad8ed51d58faa1ab735dbc00e28a3e9ba35883 (diff)
downloadcpython-246b9d8258e7d7adbeed152a6377a6b541ad2020.zip
cpython-246b9d8258e7d7adbeed152a6377a6b541ad2020.tar.gz
cpython-246b9d8258e7d7adbeed152a6377a6b541ad2020.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/stdwinmodule.c75
1 files changed, 47 insertions, 28 deletions
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c
index 32f5f22..494b15e 100644
--- a/Modules/stdwinmodule.c
+++ b/Modules/stdwinmodule.c
@@ -628,8 +628,7 @@ drawing_setfont(self, args)
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 @@ stdwin_open(sw, args)
}
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 @@ stdwin_get_poll_event(poll, args)
err_setstr(RuntimeError, "cannot getevent() while drawing");
return NULL;
}
-/* again: */
+ again:
if (poll) {
if (!wpollevent(&e)) {
INCREF(None);
@@ -1666,10 +1692,6 @@ stdwin_get_poll_event(poll, args)
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 @@ stdwin_get_poll_event(poll, args)
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 @@ stdwin_get_poll_event(poll, args)
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 @@ stdwin_setcutbuffer(self, args)
}
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 @@ static struct methodlist stdwin_methods[] = {
{"askync", stdwin_askync},
{"fetchcolor", stdwin_fetchcolor},
{"fleep", stdwin_fleep},
+ {"getactive", stdwin_getactive},
{"getcutbuffer", stdwin_getcutbuffer},
{"getdefscrollbars", stdwin_getdefscrollbars},
{"getdefwinpos", stdwin_getdefwinpos},