Path: utzoo!attcan!uunet!lll-winken!ames!hc!eggroll!pprg.unm.edu!unmvax!tut.cis.ohio-state.edu!bloom-beacon!earth.cray.COM!jlf From: jlf@earth.cray.COM (John Freeman) Newsgroups: comp.windows.x Subject: confusion about "application contexts" Message-ID: <8902161733.AA15972@thelake.cray.com> Date: 16 Feb 89 17:33:19 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 63 I have had the same questions about application contexts. I sent a posting to xpert last week and have seen no responses to it. However, since then, I have been able to get some things to work with application contexts, a sample 'Hello, World.' is enclosed using appcontext. > Just what are applications contexts for? Well, although the data type XtAppContext is opaque, if you look at it, you'll find it does have a pointer to a list of displays, allowing the programmer to bring up widgets/windows on multiple displays. (See the example) It also has a resources pointer, meaning each AppContext could have different resource specifications. Beyond that, they still mystify me. ---------------------------------------------------------------------------- /* "Hello, World" on two displays - John L. Freeman, Cray Research Inc. */ #include #include #include #include #include #include #define STRING1 "Hello, World!" #define STRING2 "Goodbye, World!" Arg label1_args[] = {XtNlabel, (XtArgVal) STRING1 }; Arg label2_args[] = {XtNlabel, (XtArgVal) STRING2 }; Arg argies[5]; main(argc,argv) int argc; char **argv; { Widget top1, top2, label1, label2; Display *d1p, *d2p; XtAppContext app1; XtToolkitInitialize(); app1 = XtCreateApplicationContext(); /* Sun 3/60 named "thelake" using screens 0 and 1 */ d1p = XtOpenDisplay(app1, "thelake:0.0", NULL, "Xlabel", NULL, 0, &argc, argv); if (d1p == NULL) { printf("XtOpenDisplay failed\n"); return; } d2p = XtOpenDisplay(app1, "thelake:0.1", NULL, "Xlabel", NULL, 0, &argc, argv); if (d2p == NULL) { printf("XtOpenDisplay failed\n"); return; } top1 = XtAppCreateShell("XShell", "xshell", applicationShellWidgetClass, d1p, NULL, 0); top2 = XtAppCreateShell("XShell", "xshell", applicationShellWidgetClass, d2p, NULL, 0); label1 = XtCreateManagedWidget(argv[0], labelWidgetClass, top1, label1_args, XtNumber(label1_args)); label2 = XtCreateManagedWidget(argv[0], labelWidgetClass, top2, label2_args, XtNumber(label2_args)); XtRealizeWidget(top1); XtRealizeWidget(top2); XtAppMainLoop(app1); }