Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!romp!auschs!awdprime!sanders.austin.ibm.com!sanders From: sanders@peyote.cactus.org (Tony Sanders) Newsgroups: comp.windows.x Subject: Re: Asking for Backing Store Message-ID: <5397@awdprime.UUCP> Date: 18 Feb 91 01:31:30 GMT References: <1991Feb5.191434@mathcs.emory.edu> <7320015@hpfcso.FC.HP.COM> Sender: news@awdprime.UUCP Reply-To: sanders@peyote.cactus.org (Tony Sanders) Organization: IBM AWD, Austin Lines: 142 Originator: sanders@sanders.austin.ibm.com In article <7320015@hpfcso.FC.HP.COM> garfinkel@hpfcso.FC.HP.COM (Dan Garfinkel) writes: >Backing store is a window attribute. As such, an application can be written >to change another window's backing store attribute. It may be a little tricky >to figure out the window ids you want to change, since the window manager may >have reparented the application window. Give it a try and let us know if >it works! It works. I included my source xbs.c here because it isn't complete source. If you have source for X11R4 xprop just copy everything except xprop.c and instead use xbs.c. If you don't have source I leave it as an exercise to the reader to get it working, sorry. I took xprop.c and started deleting everything I didn't like and then stuck in my little snipit of code at the end. THIS ISN'T PRODUCTION CODE!!!!!!!! I just used the delete function of my editor to test the idea, I based it on xprop 'cuz it already did all the right things for a reparenting window manager. You probably want to make it recursive from target_win (steal code from xlswins). It only took me about 15 minutes to get this working so you shouldn't have too much trouble (hint use XQueryTree). -------------- xbs.c ----------------- /* example of how you might write xbs.c from xprop.c */ #include #include #include #include #include #include #include #include "dsimple.h" #define MAXSTR 10000 #define min(a,b) ((a) < (b) ? (a) : (b)) usage() { char **cpp; static char *help_message[] = { "where options include:", " -display host:dpy the X server to contact", " -id id resource id of window to examine", " -name name name of window to examine", " -root examine the root window", " -frame don't ignore window manager frames", " -bs notuseful|whenmapped|always setting of the backing store mode", NULL}; fflush (stdout); fprintf (stderr, "usage: %s [-options ...] [[format [dformat]] atom]\n\n", program_name); for (cpp = help_message; *cpp; cpp++) { fprintf (stderr, "%s\n", *cpp); } fprintf (stderr, "\n"); exit (1); } /* * * The Main Program: * */ Window target_win=0; int notype=0; int spy=0; int max_len=MAXSTR; XFontStruct *font; main(argc, argv) int argc; char **argv; { FILE *stream; char *name, *getenv(); Bool frame_only = False; int bsmode = (-1); /* not portable, should keep sep state */ INIT_NAME; /* Handle display name, opening the display */ Setup_Display_And_Screen(&argc, argv); /* Handle selecting the window to display properties for */ target_win = Select_Window_Args(&argc, argv); /* Handle '-' options to setup xbs, select window to work on */ while (argv++, --argc>0 && **argv=='-') { if (!strcmp(argv[0], "-")) continue; if (!strcmp(argv[0], "-frame")) { frame_only = True; continue; } if (!strcmp(argv[0], "-bs")) { if (++argv, --argc==0) usage(); if (strcmp(argv[0], "notuseful") == 0) bsmode = NotUseful; if (strcmp(argv[0], "whenmapped") == 0) bsmode = WhenMapped; if (strcmp(argv[0], "always") == 0) bsmode = Always; continue; } usage(); } if (target_win == None) { target_win = Select_Window(dpy); if (target_win != None && !frame_only) { Window root; int dummyi; unsigned int dummy; if (XGetGeometry (dpy, target_win, &root, &dummyi, &dummyi, &dummy, &dummy, &dummy, &dummy) && target_win != root) target_win = XmuClientWindow (dpy, target_win); } } if (target_win != -1) { XWindowAttributes cwa; if (bsmode != (-1)) { XSetWindowAttributes wa; fprintf(stderr,"setting bs %d: %#x %d\n",bsmode,dpy,target_win); wa.backing_store = bsmode; XChangeWindowAttributes(dpy,target_win,CWBackingStore,&wa); } XGetWindowAttributes(dpy,target_win,&cwa); fprintf(stderr,"spy: %#x %d %d\n",dpy,target_win,cwa.backing_store); } exit (0); }