[comp.windows.x.motif] Disabling Window Menu Options?

matt@rs20dev.UUCP (Matt Howland) (03/24/91)

I want to disable or sensitize menu options in the Motif Window Menu for a
client.  Specifically, I want to disable the Close option and force the user
to exit the client via its own Exit Option.  Could someone tell me how to do
this. 

Thanks,

Matt Howland		(matt@rs20dev.uunet)

nazgul@alfalfa.com (Kee Hinckley) (03/25/91)

> I want to disable or sensitize menu options in the Motif Window Menu for a
> client.  Specifically, I want to disable the Close option and force the user
> to exit the client via its own Exit Option.  Could someone tell me how to do
> this. 

The real answer is that this is the wrong question.  (Don't you love answers
like that? :-).

Disabling the menu doesn't disable the function completely, either in Mwm or
any other window manager.  What you really should do is catch the result of
the close and handle it as though they had selected your Exit function.

If you ignore my widget wrapper junk, that will look something like this.


    arglist.add(XmNdeleteResponse, XmDO_NOTHING, NULL);
    w = OmXWidget::create(parent, name, args, argc);

    delWindow = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);
    XmAddWMProtocols(shell, &delWindow, 1);
    XmAddWMProtocolCallback(shell, delWindow, (XtCallbackProc)OmXWidgetDelete, (caddr_t)this);


Alfalfa Software, Inc.          |       Poste:  The EMail for Unix
nazgul@alfalfa.com              |       Send Anything... Anywhere
617/646-7703 (voice/fax)        |       info@alfalfa.com

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

hildjj@MODAL375.ME.VT.EDU (Joe Hildebrand) (03/25/91)

> I want to disable or sensitize menu options in the Motif Window Menu for a
> client.  Specifically, I want to disable the Close option and force the user
> to exit the client via its own Exit Option.  Could someone tell me how to do
> this. 

I just licked this problem last week.  I had a kludge where I set a resource in
the .Xdefaults to prevent the user from using the close option:

Mwm*myprog*clientFunctions: -close

But using a hint from the FAQ, I came up with the answer that nazgul@alfalfa.com
provided.  Unfortunately, that didn't quite work for me.  Try this:

Widget toplevel;
Arg wargs[5];
int n;
Atom wm_delete_window;

toplevel = XtInitialize (argv[0], "myprog", NULL, 0, &argc, argv);