[comp.windows.x] Application Modal Dialogs

chan@hpfcmgw.HP.COM (Chan Benson) (09/17/90)

There's been some recent questions on how to do application-modal 
dialogs in Motif. I'd rather not debate the merit of application 
modality, I just want to know if what I'm doing is legit. 

Anyway, here's what I've done to implement application-modal dialogs
in Motif that do not rely on mwm. If there's something wrong with my 
approach, please let me know ASAP.


void  popupModalDialog (dialog)
Widget   dialog;
{
    XtManageChild(dialog);
    XtAddGrab(XtParent(dialog), TRUE, FALSE);
}


void  popdownModalDialog (dialog)
Widget   dialog;
{
    XtRemoveGrab(XtParent(dialog));
    XtUnmanageChild(dialog);
}


The main thing here to be wary of is that any button that can popdown
the dialog must call popdownModalDialog in one of its callbacks so that
the grab can be removed. For dialogs with autoUnmanage set to be true,
you might forget to do this and then you'll be hosed.

			-- Chan Benson
			HP Fort Collins
			chan@hpfcmi.hp.com
			(303) 229-3892