Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!ANDREW.CMU.EDU!yt07+ From: yt07+@ANDREW.CMU.EDU (Yin-Cheng Tsai) Newsgroups: comp.windows.x Subject: Resource problem (& XQueryTree)!! Message-ID: Date: 31 Jan 89 23:28:18 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 108 Hi, folks, More questions are coming up when I really try to use the powerful functions in Xlib. Following is my source codes. There are two problems in these codes. Problem 1: I can/can't get the data from the command line. For instance, "tst1 -dbase /usr/yt/.tstbase" DOESN'T work (defFile gets nothing) "tst1 -xrm "*dataBase:/usr/yt/.tstbase" work (defFile = "/usr/yt/.tstbase") Problem 2: The children returned by "XQueryTree" are not windows (?). I try to get the property of XA_WM_NAME, but just get Segmentation error. Thanks for any help. I really appreciate it. -- yin-cheng ##---------------------- tst1.c start from here ----------------------## #include #include #include #include /* include file.h/string.h/strings.h */ #include static XrmOptionDescRec options[] = { {"-display","*display", XrmoptionSepArg, (caddr_t) NULL}, {"-dbase", ".dataBase", XrmoptionSepArg, (caddr_t) NULL}, {"-pixmap", "*pixmap", XrmoptionSepArg, (caddr_t) NULL}, {"-width", "*width", XrmoptionSepArg, (caddr_t) NULL}, {"-height", "*height", XrmoptionSepArg, (caddr_t) NULL}, {"-xrm", NULL, XrmoptionResArg, (caddr_t) NULL}, }; main (argc, argv) int argc; char *argv[]; { char defFile[32], server[32], *string_type[20]; unsigned int nchild; int index; Window root, parent, *children; XrmDatabase comDB, defDB, rootDB, resDB; XrmValue value; Display *display; Pixmap pixmap; XrmInitialize (); XrmParseCommand (&comDB, options, sizeof(options)/sizeof(options[0]), argv[0], &argc, argv); if (XrmGetResource (comDB, ".dataBase", ".DataBase", string_type, &value)) strncpy (defFile, (char*) value.addr, (int) value.size); else { strcpy (defFile, getenv ("HOME")); strcat (defFile, "/.xdef"); } if (!access (defFile, F_OK)) { if (!(defDB = XrmGetFileDatabase (defFile))) { fprintf (stderr, "database file <%s> is not readable", defFile); exit (-1); } XrmMergeDatabases (defDB, &resDB); } else fprintf (stderr, "database file <%s> is not accessible\n", defFile); if (XrmGetResource (comDB, ".display", ".Display", string_type, &value) || XrmGetResource (resDB, ".display", ".Display", string_type, &value)) strncpy (server, (char*) value.addr, (int) value.size); else server[0] = '\0'; if ((display = XOpenDisplay (server)) == NULL) { fprintf (stderr, "no response from the X server <%s>\n", strlen (server)? server:(char*) getenv("DISPLAY")); exit (-1); } rootDB = XrmGetStringDatabase (XResourceManagerString (display)); XrmMergeDatabases (rootDB, &resDB); XrmMergeDatabases (comDB, &resDB); if (!XQueryTree (display, DefaultRootWindow (display), &root, &parent, &children, &nchild)) { fprintf (stderr, "can not query the tree\n"); exit (-1); } for (index = 0 ; index < nchild ; ++index) { Atom actual_type; int actual_format; unsigned long nitems, bytes_after; char *prop[20]; XGetWindowProperty (display, children[index], XA_WM_NAME, 0, 0, False, AnyPropertyType, &actual_type, &actual_format, &nitems, prop); } }