5

My X11 client/server are set up to use a backing store (backing_store = WhenMapped), which works fine when my window is partially obscured: remove what's obscuring the window and the now-visible part is refreshed from the backing store with no need for me to repaint...

...but it's not working when the window is unmapped then mapped again: I get UnmapNotify then MapNotify events, but my window is blank when mapped and I have to repaint the whole thing myself.

So my question: How do I get the backing store to work for Unmap/Map as well as Expose? (backing_store = Always) made no difference.

System: Ubuntu 16.04, X.Org X Server 1.19.3

Thank you

  • A hack to avoid handling expose events is to create a pixmap of the size of the window and set it as the background pixmap. The server will then refresh from this pixmap. The server is free to make a copy of the pixmap so It is undefined if any changes you make to the pixmap are seen, without doing another call to XSetWindowBackgroundPixmap(). – meuh Aug 26 '18 at 17:59
  • Do you not need to handle all expose events, just in case the server throws away the backing store. – ctrl-alt-delor Dec 11 '19 at 21:26

1 Answers1

2

By backing_store = always I presume you mean the window attributes in your client code? But are you sure BackingStore option is enabled for your X server? Presuming Xorg, you should locate your log (/var/log/Xorg.0.log, or more recently ~/.local/share/xorg/Xorg.0.log) and grep for Backing store:

> grep 'Backing store' ~/.local/share/xorg/Xorg.0.log

[    67.851] (==) intel(0): Backing store enabled

If it's not enabled, you could try creating /etc/X11/xorg.conf.d/10-backing-store.conf (or adding it to an existing file, if you have one with a Device section):

Section "Device"
  Option "BackingStore" "on"
EndSection

Restart X and see if the option is enabled in the Xorg.0.log.

There is also the +bs option (note the +) to Xorg itself, which I have used successfully in the past.

> Xorg --help
...
+bs      enable any backing store support
Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • Hi... The backing store is definitely enabled on the server-- I made sure, which is how I got this far (working for Expose, but not for Map). The log does also verify this: "FBDEV(0): Backing store enabled". So it's working, but not when I unmap then re-map the window. – Ian Macky Aug 27 '18 at 04:51
  • @ian.macky: fair enough, but there is also the window attribute "save-under", which works for Expose but not for Map, so it seemed possible that you were not really testing backing store even for Expose. May I ask what window manager you're using, and whether you've tried this with a different one? – flaysomerages Aug 28 '18 at 02:54
  • The comment below [this answer] (https://stackoverflow.com/a/17035752) sounds like it's worth trying, in your MapNotify handler. You use XClearArea() of one pixel, and it will trigger an Expose event. Alternatively, you can try creating a synthetic Expose event and send it using XSendEvent(). Also it should be mentioned, backing store is only a hint to the server, and might not be honored. – flaysomerages Aug 28 '18 at 19:33
  • Setting save-under/CWSaveUnder doesn't make any difference (just tried it). Note with the backing store enabled, I don't get Expose events when an obscured part of the window is uncovered-- it's just repainted from the backing store and I don't have to deal with it, as expected. With no backing store, I do get Expose events under same conditions. When a window is Unmapped then Mapped, should it start out with the saved contents from the backing store?? Am I barking up the wrong tree? I'm using an ancient window manager but don't see how would WM choice would affect anything. – Ian Macky Aug 29 '18 at 16:01
  • I just checked with an X client of my own, and I do get an expose event when I XUnmapWindow() and then XMapWindow(). (And the bitmap image is restored without redrawing.) So you might like to try the tricks in my previous comment, to force an Expose event on Map? I'm interested in your problem and would like to help, but it's been some time since I messed with this stuff. My app overrides the WM so it might be a bad comparison. – flaysomerages Aug 29 '18 at 16:22