#include #include #include #include #include #include #include "MsgShell.h" #include "xlocale.h" #include "frame.h" Atom wm_protocols[2]; void QuitMsg(Widget w, XEvent *e, String *p, Cardinal *n) { if (e->xclient.data.l[0] == wm_protocols[0] || e->xclient.data.l[0] == wm_protocols[1]) { exit(1); /* XtDestroyWidget(w); */ } } /* command-line options */ static XrmOptionDescRec options[] = {}; /* actions */ static XtActionsRec actions[] = { {"quitmsg", QuitMsg}, }; String trans_top = "WM_PROTOCOLS: quitmsg()\n"; int main(int argc, char **argv) { const char *usage = "usage: %s filename\n"; XtAppContext app; Widget top; mysetlocale(0); /* for my locale lib */ #if 1 top = XtVaOpenApplication(&app, "AnimTest", options, XtNumber(options), &argc, argv, NULL, msgShellWidgetClass, NULL); #else top = XtVaOpenApplication(&app, "AnimTest", options, XtNumber(options), &argc, argv, NULL, msgShellWidgetClass, XtNoverrideRedirect, True, XtNsaveUnder, True, NULL); #endif if (!argv[1]) { fprintf(stderr, usage, argv[0]); exit(1); } XtAppAddActions(app, actions, XtNumber(actions)); XtOverrideTranslations(top, XtParseTranslationTable(trans_top)); XtVaSetValues(top, XtNwidth,(Dimension)600, XtNheight,(Dimension)500, XtNfile, argv[1], NULL); XtSetMappedWhenManaged(top, False); XtRealizeWidget(top); wm_protocols[0] = XInternAtom(XtDisplay(top), "WM_DELETE_WINDOW", False); wm_protocols[1] = XInternAtom(XtDisplay(top), "WM_SAVEYOURSELF", False); XSetWMProtocols(XtDisplay(top), XtWindow(top), wm_protocols, 2); XtMapWidget(top); XtAppMainLoop(app); exit(0); }