System tray rewrite ready for review

Jason Stubbs jasonbstubbs at gmail.com
Sat Aug 23 04:15:55 CEST 2008


Fredrik Höglund wrote:
> The code in createBackgroundPixmap() that converts the QImage to an XImage
> is not really sufficient, because there's no guarantee that the QImage format
> matches the visual format just because the depth is the same. For example
> the component order can be BGR instead of RGB if the X server is running on
> a big-endian system. You have to look at the red, green and blue masks in
> the XImage structure when you do the conversion.

I don't think I left FIXMEs, but I figured as much. The resulting image 
was already slightly incorrect at 16 bit depth and 8 bit wasn't 
supported at all. Is it obvious that I don't know X11 programming? ;)

> Instead of using an image I would render the background to a QPixmap though,
> and use XRenderComposite() to copy the pixmap contents to the pixmap you'll
> be passing to XSetWindowBackgroundPixmap(). Xrender will do the format
> conversion automatically in the X server if needed.

I've updated the code in subversion to go via this method, although I've 
skipped checking whether the render extension is available for the 
moment. I think the HOWTO I used as a guide is yours. :)

> XGetWindowAttributes() involves a roundtrip to the X server, so I would only
> call this function once when the window is embedded and save the data.
> The visual can't change after the window has been created.

After making this change the update goes much quicker. The Xlib manual 
doesn't seem to state that the call is synchronous. Is there somewhere I 
can look to know which functions are what?

> It also seems to me that if paintEvent() is called repeatedly at a fast enough
> rate, the timer will just be reset over and over again, and no painting will
> ever occur.

This was mainly a workaround for the jerkiness that was happening with 
the XGetWindowAttributes() call. I've removed the delay altogether.

> I'm also wondering if you could explain why you need to update the background
> pixmap each time paintEvent() is called. Doesn't the background stay the same
> except when the window is moved or resized?

The background could change for a number of reasons. For example, there 
could be an animated wallpaper under the system tray on the desktop. I 
tried to cache and compare the last drawn background (commented out in 
subversion) but it is breaking when exiting the dashboard. More strange 
behaviour that I can't explain. :(

--
Jason Stubbs



More information about the Plasma-devel mailing list