[comp.windows.x] Asking for Backing Store

sanders@peyote.cactus.org (Tony Sanders) (02/12/91)

In article <1991Feb5.191434@mathcs.emory.edu> km@mathcs.emory.edu writes:
>Is there a way from the outside to get a client to request backing store,
>or at least for a server to think it has. It seems to me that a user may
If the people who wrote your server were nice enough to provided backing
store then it might be the case that they provided a X command line
argument to force backing store.

For you RS/6000 users out there: X -bs -wm  (enable bs and WhenMapped)
Others might try: X -help  or somesuch
to get a usage message and see if it helps.

You may find that forcing backing store makes things slower rather than
faster because it can be faster to repaint simple stuff rather than
store it way all the time when you don't need to.

good luck
-- sanders@peyote.cactus.org
First rule of software:  Throw the first one away.
and so on...
I am not an IBM representative and I speak only for myself.

zeeff@b-tech.ann-arbor.mi.us (Jon Zeeff) (02/14/91)

>Is there a way from the outside to get a client to request backing store,
>or at least for a server to think it has. It seems to me that a user may
>know that a particular client is connected over a slow network, and want 
>to avoid the exposure traffic, even though the client had no inherent 
>reason to set the attribute.

I just ran into this problem.  I can't readily modify the client 
(binaries only) and I'm using a very slow link.
-- 
Jon Zeeff (NIC handle JZ)	 zeeff@b-tech.ann-arbor.mi.us

km@mathcs.emory.edu (Ken Mandelberg) (02/14/91)

In article <5262@awdprime.UUCP>, sanders@peyote.cactus.org (Tony Sanders) writes:
|> In article <1991Feb5.191434@mathcs.emory.edu> km@mathcs.emory.edu writes:
|> >Is there a way from the outside to get a client to request backing store,
|> >or at least for a server to think it has. It seems to me that a user may
|> If the people who wrote your server were nice enough to provided backing
|> store then it might be the case that they provided a X command line
|> argument to force backing store.
|> 
|> For you RS/6000 users out there: X -bs -wm  (enable bs and WhenMapped)
|> Others might try: X -help  or somesuch
|> to get a usage message and see if it helps.
|> 
|> You may find that forcing backing store makes things slower rather than
|> faster because it can be faster to repaint simple stuff rather than
|> store it way all the time when you don't need to.
|> 
|> good luck
|> -- sanders@peyote.cactus.org

It seems to me that forcing the server to use backing store for all clients
is not generally what you want (exept maybe for an X terminal with a serial
link).

At the other extreme, expecting individual clients to figure out how fast
their communications link is and requesting backing store also seems
unlikely. They may abstractly know if they are doing the kind of graphics
that is easier to regenerate then save, but not the communications details
of the particular invocation.

I would argue you that the user who knows something about where he is running
the client, should be able to selectively force request backing store from
the server independent of the internal logic of the client. 

I'm a little surprised that this hasn't been built into the toolkit
initialization routines, so that the user could request it on a per
client basis by a property or command line argument. Alternately, window
managers could allow a user to flag a particular window to the server for
backing store even while its running.  

Is none of this around?

-- 
Ken Mandelberg      | km@mathcs.emory.edu          PREFERRED
Emory University    | {rutgers,gatech}!emory!km    UUCP 
Dept of Math and CS | km@emory.bitnet              NON-DOMAIN BITNET  
Atlanta, GA 30322   | Phone: Voice (404) 727-7963, FAX 727-5611

garfinkel@hpfcso.FC.HP.COM (Dan Garfinkel) (02/16/91)

> Is there a way from the outside to get a client to request backing store,
> or at least for a server to think it has. It seems to me that a user may
> know that a particular client is connected over a slow network, and want 
> to avoid the exposure traffic, even though the client had no inherent 
> reason to set the attribute.

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!

-Dan

sanders@peyote.cactus.org (Tony Sanders) (02/18/91)

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 <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
#include <ctype.h>

#include <X11/Xatom.h>
#include <X11/Xmu/WinUtil.h>

#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);
}