Re: XSetBackgroundPixmap question

2012-05-21 Thread Adam Jackson
On Sat, 2012-05-19 at 23:00 +0100, Glynn Clements wrote:

 I've encountered code which uses a background pixmap to implement a
 persistent screen, and drawing to the pixmap then calling XClearWindow
 (without calling XSetWindowBackgroundPixmap in between) results in the
 updated pixmap contents appearing in the window. So it appears to use
 reference counting or similar.

Any code which does this is being inadvisably friendly with the
implementation.  From the protocol spec:

Subsequent drawing into the background or border pixmap has an
undefined effect on the window state. The server might or might
not make a copy of the pixmap.

The sample implementation (at least at the dix level) has always done
the current behaviour of taking a reference on the pixmap, but the
sample implementation is not the only X server ever written.

- ajax


signature.asc
Description: This is a digitally signed message part
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: XSetBackgroundPixmap question

2012-05-20 Thread walter harms


Am 20.05.2012 05:30, schrieb Keith Packard:
 Glynn Clements gl...@gclements.plus.com writes:
 
 That seems to imply that the X server makes a copy of the pixmap data
 rather than keeping a reference to the original pixmap. However, I
 don't believe that's how the X.org server actually implements it.
 
 No, it keeps a reference, but not through the Pixmap ID, so while the
 client can destroy the ID, the server holds a reference to the
 underlying Pixmap structure itself. No copy is made.
 

Hello keith,
i am not an X11 expert, and i am not sure that i understand your answer.
So far i understand the problem was how to free the old one and the answer
is there is no need to free since you should set the pixmap like this:

newpm=xcreatepix()
XSetWindowBackgroundPixmap(newpm)
xfreepixmap(newpm)

Is that what you are saying ?

re,
 wh
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com


Re: XSetBackgroundPixmap question

2012-05-19 Thread Glynn Clements

[I presume that you mean XSetWindowBackgroundPixmap; there is no Xlib
function named XSetBackgroundPixmap.]

James Buren wrote:

 When using this Xlib function to set a new background pixmap, how does the 
 old one get
 freed? If I am setting the root window's background pixmap, I don't know how 
 I can get the
 XID of the old one. If it is a window I created, I can cache it but that 
 seems overkill if I'm
 just wanting to discard the old one. Can someone direct me to how I am 
 supposed to free
 the old background pixmap? Thanks.

The manual page for XSetWindowBackgroundPixmap says:

The XSetWindowBackgroundPixmap function sets the background
pixmap of the window to the specified pixmap. The background
pixmap can immediately be freed if no further explicit
references to it are to be made.

That seems to imply that the X server makes a copy of the pixmap data
rather than keeping a reference to the original pixmap. However, I
don't believe that's how the X.org server actually implements it.

I've encountered code which uses a background pixmap to implement a
persistent screen, and drawing to the pixmap then calling XClearWindow
(without calling XSetWindowBackgroundPixmap in between) results in the
updated pixmap contents appearing in the window. So it appears to use
reference counting or similar.

The combination of the documentation and the observed behaviour
implies that the X server *may* copy the pixmap data or it may just
keep a reference. Either way, deleting the pixmap after setting it
should be fine, but modifying a pixmap which has been used as a
background pixmap has undefined behaviour.

Regardless of the implementation, there isn't any way to query the
current background pixmap. The background_pixmap field in the
XSetWindowAttributes structure used by XChangeWindowAttributes isn't
present in the XWindowAttributes structure used by XGetWindowAttributes.

-- 
Glynn Clements gl...@gclements.plus.com
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com


Re: XSetBackgroundPixmap question

2012-05-19 Thread James Buren
Wow, that was fast. Thanks. Some other questions I've been having. I've been 
considering using
the XRender extension and I've noticed the documentation is nearly 
non-existent. What advantages
does it offer over older Xlib drawing API? At the very least, it seems to offer 
more complex graphics
operations like scaling and alpha blending.
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com


Re: XSetBackgroundPixmap question

2012-05-19 Thread Keith Packard
James Buren r...@ymail.com writes:

 Wow, that was fast. Thanks. Some other questions I've been having. I've been 
 considering using
 the XRender extension and I've noticed the documentation is nearly 
 non-existent. What advantages
 does it offer over older Xlib drawing API? At the very least, it seems to 
 offer more complex graphics
 operations like scaling and alpha blending.

You should look at cairo instead -- it nicely wraps the render extension
with a pretty postscript-like API.

-- 
keith.pack...@intel.com


pgpAzRRJkjwIZ.pgp
Description: PGP signature
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: XSetBackgroundPixmap question

2012-05-19 Thread James Buren
 The combination of the documentation and the observed behaviour
 implies that the X server *may* copy the pixmap data or it may just
 keep a reference. Either way, deleting the pixmap after setting it
 should be fine, but modifying a pixmap which has been used as a
 background pixmap has undefined behaviour.

What is undefined behavior? Modifying a pixmap that is still used
as a background pixmap, modifying a pixmap that was used as
a background pixmap but has since been replaced, or both of these
cases?
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com