Path: utzoo!utgpu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!udel!rochester!ferguson From: ferguson@cs.rochester.edu (George Ferguson) Newsgroups: alt.sources Subject: xloadimage for tvtwm Message-ID: <1990Sep11.212835.26266@cs.rochester.edu> Date: 11 Sep 90 21:28:35 GMT Reply-To: ferguson@cs.rochester.edu (George Ferguson) Distribution: alt Organization: University of Rochester Computer Science Dept. Lines: 137 I hacked xloadimage to search for a virtual root window so that it would work with tvtwm. I basically cut the code from ssetroot.c by Tom LaStrange in the tvtwm distribution into root.c of the xloadimage distribution. I figured others might be interested so here it is. It has only been very briefly tested, but seems to work for the common case. Unshar the file "changes" and apply it with "patch 'changes' <<'END_OF_FILE' X*** root.c.old Tue Sep 11 17:09:30 1990 X--- root.c Tue Sep 11 17:16:35 1990 X*************** X*** 93,98 **** X--- 93,109 ---- X } X } X X+ /* X+ * Modified to search for a virtual root window based on code from X+ * Tom LaStrange (toml@solbourne.com) in the tvtwm distribution. X+ * I doubt that I got all the other possible places changes are needed, X+ * especially w.r.t. colormaps. X+ * X+ * George Ferguson, ferguson@cs.rochester.edu, 11 Sep 1990. X+ */ X+ X+ static Window getRootWindow(); X+ X void imageOnRoot(disp, scrn, image, verbose) X Display *disp; X int scrn; X*************** X*** 100,109 **** X unsigned int verbose; X { Pixmap pixmap; X Colormap xcmap; X X X! freePrevious(disp, RootWindow(disp, scrn)); X X if (! sendImageToX(disp, scrn, DefaultVisual(disp, scrn), image, X &pixmap, &xcmap, verbose)) X exit(1); X--- 111,123 ---- X unsigned int verbose; X { Pixmap pixmap; X Colormap xcmap; X+ Window root; X X X! root = getRootWindow(disp,scrn); X X+ freePrevious(disp, root); X+ X if (! sendImageToX(disp, scrn, DefaultVisual(disp, scrn), image, X &pixmap, &xcmap, verbose)) X exit(1); X*************** X*** 117,124 **** X exit(1); X } X X! XSetWindowBackgroundPixmap(disp, RootWindow(disp, scrn), pixmap); X! XClearWindow(disp, RootWindow(disp, scrn)); X XFreePixmap(disp, pixmap); X! preserveResource(disp, RootWindow(disp, scrn)); X } X--- 131,167 ---- X exit(1); X } X X! XSetWindowBackgroundPixmap(disp, root, pixmap); X! XClearWindow(disp, root); X XFreePixmap(disp, pixmap); X! preserveResource(disp, root); X! } X! X! /* X! * This is more or less directly from ssetroot.c in the tvtwm distribution. X! */ X! static Window X! getRootWindow(disp,scrn) X! Display *disp; X! int scrn; X! { X! Atom __SWM_VROOT,actual_type; X! Window root,rootReturn,parentReturn,*children,*newRoot; X! int numChildren,i,actual_format; X! long nitems, bytesafter; X! X! X! root = RootWindow(disp,scrn); X! __SWM_VROOT = XInternAtom(disp,"__SWM_VROOT",False); X! XQueryTree(disp,root,&rootReturn,&parentReturn,&children,&numChildren); X! for (i = 0; i < numChildren; i++) { X! newRoot = NULL; X! if (XGetWindowProperty (disp, children[i], __SWM_VROOT,0,1, X! False,XA_WINDOW,&actual_type,&actual_format,&nitems,&bytesafter, X! (unsigned char **)&newRoot) == Success && newRoot) { X! root = *newRoot; X! break; X! } X! } X! return(root); X } END_OF_FILE if test 2507 -ne `wc -c <'changes'`; then echo shar: \"'changes'\" unpacked with wrong size! fi # end of 'changes' fi echo shar: End of shell archive. exit 0 -- George Ferguson ARPA: ferguson@cs.rochester.edu University of Rochester UUCP: {decvax,rutgers}!rochester!ferguson Rochester NY 14627 VOX: (716) 275-2527