Background of my question is that I want to use XmCreate{Error|Warning|Info}Dialog to display some message in screen in my SDL based application before its main window is open and any program data is available. So I want the dialog to open, print the intended message, and when the user clicks on the OK button, the dialog plus the top widget I had to create for it should be closed/removed. Now afaik XtAppMainLoop will loop and process top widget messages (a window?) until the user closes it. I want to close it when the dialog returns though. How can I do that?
+1
A:
It's easy, in the XtAppContext that is returned from XtAppMainLoop, just do p->exit_flag = 1;
.
It's also common for applications to simply include their own main loop and do whatever they want. All XtAppMainLoop does is call XtAppNextEvent(app, &event)
and then XtDispatchEvent(&event)
.
DigitalRoss
2009-09-06 19:12:23
Thanks for the info, but it is not possible to access XtAppContext.exit_flag, because XtAppContext has been turned into some opaque data type with some include file and forward declaration trickery, and I cannot determine which (X11) include files I need to include to make it work. I think I can achieve what I want by calling XtDestroyApplicationContext, which will hopefully take care of its event loop too.
karx11erx
2009-09-07 09:52:52
A:
After hours and hours of googling and reading I have found out that you can use XtAppSetExitFlag (XtAppContext).
karx11erx
2009-09-07 12:23:25
Actually, I thought of another way. You could fork() and do the status window in the child, then just exit the child. Too late! Sorry!BTW, I was thinking about something else. Are you using motif just because that example code from the other question happened to include Xm/Xm.h? Now, there is nothing wrong with motif, but it's kind of overkill if all you wanted was a splash screen. Let me know...
DigitalRoss
2009-09-08 02:22:05
I am not looking for a splash screen, but for a message box. Well, actually a bit more than that. I want to be able to print long, multi-line diagnostic messages, so I need something like a dialog with a text widget. I have finally found something useable in the Motif programming manual though and have adapted it to my needs. I will post code, or a link to code when I am done with it. Btw, to avoid the app loop terminating the program it is possible to intercept the window managers close signal and set the app's exit flag instead with XtAppSetExitFlag. That will just end the event loop.
karx11erx
2009-09-08 14:36:07