mikew@neptune.fx.COM (03/22/90)
VERSION:
R3/R4
I tested this on with OSF's R3 Xt Intrinsics, but the R4 code
doesn't appear to fix this problem.
CLIENT MACHINE and OPERATING SYSTEM:
Sun SparcStation, SunOS 4.0.3
DISPLAY TYPE:
CG6
WINDOW MANAGER:
mwm
AREA:
Xt/X Protocol
SYNOPSIS:
XtManageChild followed quickly by XtUnmanageChild fails.
DESCRIPTION:
When XtManageChild(shell) is called and the XtUnmanageChild(shell) is
called before the window manager has processed the MapRequest, the
window remains mapped.
REPEAT BY:
Here is a sample program complete with a work around that
demonstrates this failure. Although this program use Motif widgets
a very similar program should demonstrate the failure with any widget
set.
#include <Xm/Xm.h>
#include <Xm/PushB.h>
#include <Xm/Label.h>
#include <Xm/Form.h>
static Widget popup;
static Widget form;
static
void
callback(w, clientData, callData)
Widget w;
caddr_t clientData;
caddr_t callData;
{
XtManageChild(form);
XtUnmanageChild(form);
return;
}
void
mapNotify(w, clientData, event)
Widget w;
caddr_t clientData;
XEvent *event;
{
if (event->type != MapNotify)
return;
if (XtIsManaged(w))
return;
XtUnmapWidget(w);
return;
}
main(argc, argv)
int argc;
char **argv;
{
Widget shell;
Arg args[10];
Cardinal n;
Widget w;
n = 0;
shell = XtInitialize("test", "Test", args, n, &argc, argv);
n = 0;
w = XmCreatePushButton(shell, "Press Me", args, n);
XtAddCallback(w, XmNactivateCallback, callback, (caddr_t) NULL);
XtManageChild(w);
n = 0;
form = XmCreateFormDialog(shell, "form", args, n);
#ifdef WORK_AROUND
XtAddEventHandler(XtParent(form), StructureNotifyMask,
False, mapNotify, form);
#endif
n = 0;
w = XmCreateLabel(form, "label", args, n);
XtManageChild(w);
XtRealizeWidget(shell);
XtMainLoop();
return;
}
SAMPLE FIX:
I can think of two possible fixes. Code similar to the above
MapNotify funciton can be added to the Shell Widget's EventHandler
function or an X extension could be designed, speced, reviewed,
coded, approved and distributed. The X extension would support
a UnmapWindow request that doesn't get thrown away if the window is
already unmapped and the requests are being redirectred with
SubStructureRedirect. Also a corresponding MapWindow request could
also be added. I would suggest the former as a short term fix and
the latter as a long term fix.