[comp.windows.x] backing_store

hiebeler@turing.cs.rpi.edu (Dave Hiebeler) (04/13/89)

  Has anyone had any experience with backing_store under X11R3
on Suns?
  I tried to enable it (on a Sun 3/50 running X11R3) as follows:

    XSetWindowAttributes attributes[1];
    Display *display;
    Widget control_rootwidget, draw_rootwidget;
    
    control_rootwidget = XtInitialize(argv[0],"Xmessenger",NULL,0,&argc,argv);
    display = XtDisplay(control_rootwidget);
    draw_rootwidget = XtCreateApplicationShell("Xmessenger.draw",
						  topLevelShellWidgetClass,
						  NULL,0);
    init_draw_box();  /* this puts a viewport inside the draw_rootwidget */
    
    XtRealizeWidget(control_rootwidget);
    XtRealizeWidget(draw_rootwidget);
    
    attributes[0].backing_store = Always; /* also tried WhenMapped */
    XChangeWindowAttributes(display,XtWindow(draw_rootwidget),
			    CWBackingStore,attributes);

  But it seemed to have no effect.  I'm putting a viewport under
the draw_rootwidget, with a box in the viewport. I then use
xlib routines to draw in that box.  The reason I want backing-store
is because if I scroll part of the image off-screen, when I
scroll it back, it does not get redisplayed.
  My current solution for this is that I have a redraw() routine
which I call whenever I detect an expose event; but redrawing
takes much too long, as I draw a large number of lines in the box.

  Any suggestions would be appreciated.

--
Dave Hiebeler             Internet: hiebeler@cs.rpi.edu  (preferred address)
Computer Science Dept.              hiebeler@itsgw.rpi.edu
Amos Eaton Bldg.            Bitnet: userfrzk@rpitsmts.bitnet
Rensselaer Polytechnic Institute / Troy, NY 12180-3590

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (04/13/89)

    I'm putting a viewport under
    the draw_rootwidget, with a box in the viewport. I then use
    xlib routines to draw in that box.

Backing store applies only to the window you request it on, not to all of
its children.  If you want the box backing-stored, set backing-store on
the box.

hiebeler@TURING.CS.RPI.EDU (Dave Hiebeler) (04/14/89)

  Remember how I said I swore I had already tried what you said, but
it hadn't worked before?  Well, I was right.  And after some thought
and experimentation, I've found out why it wasn't working before.

  I use 2 suns:
    verdi, a Sun 3/50 running SunOS 3.5 and X11R3
    pawl4, a Sun 3/50 running SunOS 4.0 and X11R3

When I run my program on verdi, using verdi's display, backing_store
does NOT work.
When I run my program on verdi, using pawl4's display, backing_store
DOES work.

  From this, I can only conclude that there is some difference in
the servers between the two suns, since I am running the exact
same program in each case, and actually running it on the same
machine.

  So, do you happen to know of backing_store does not work under 3.5?
Or is there some way of disabling it entirely when compiling the
X server?  Perhaps our sysadmin did that unknowingly.  He said if
that's the case, and I tell him how to fix it, he'll recompile
the X server to enable backing-store for me.

  Again, thanks for your time and any suggestions...
 -Dave

Dave Hiebeler             Internet: hiebeler@cs.rpi.edu  (preferred address)
Computer Science Dept.            hiebeler@itsgw.rpi.edu
Amos Eaton Bldg.            Bitnet: userfrzk@rpitsmts.bitnet
Rensselaer Polytechnic Inst.
Troy, NY 12180-3590

klee@daisy.UUCP (Ken Lee) (04/14/89)

In article <HIEBELER.89Apr12174749@turing.cs.rpi.edu> hiebeler@turing.cs.rpi.edu (Dave Hiebeler) writes:
>
>  Has anyone had any experience with backing_store under X11R3
>on Suns?
>  I tried to enable it (on a Sun 3/50 running X11R3) as follows:
>    attributes[0].backing_store = Always; /* also tried WhenMapped */
>    XChangeWindowAttributes(display,XtWindow(draw_rootwidget),
>			    CWBackingStore,attributes);
>
>  But it seemed to have no effect.  I'm putting a viewport under
>the draw_rootwidget, with a box in the viewport. I then use
>xlib routines to draw in that box.

You're requesting backing store for the wrong window.  You have to request
it for the specific window you're drawing in, in this case the box in
the viewport.

A related issue is that you may have trouble drawing in a box widget
(and many other widgets).  None guarantee that drawing on their XtWindow 
will yield any meaningful results, although sometimes it does.  A better
solution would be to create your own widget, a subclass of core, that
has a backing store resource.  Then, you're guaranteed to be able to
draw on it and you can request backing store easily through the resource
manager.
-- 
Ken Lee
Daisy Systems Corp., Interactive Graphics Tools Dept.
Internet and Smail:  klee@daisy.uucp
              uucp:  uunet!daisy!klee

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (04/14/89)

    So, do you happen to know of backing_store does not work under 3.5?

I know of no reason why it should fail.

    Or is there some way of disabling it entirely when compiling the
    X server?

There is a server command line option, -bs, to do this.