[winswitch] A Hopefully Quick Question About Xpra.

Dan DaCosta chaosape at gmail.com
Tue Nov 3 20:07:30 GMT 2015


Responses in-line.

On Tue, Nov 3, 2015 at 9:57 AM, Antoine Martin <antoine at nagafix.co.uk>

> On 02/11/15 20:02, Dan DaCosta wrote:
> > Xpra Experts:
> >
> > I have hacked a little code into Xpra that takes screenshots of all
> windows
> > managed by Xpra and stores them locally as files. Specifically, I
> > accomplished this by adding a bit of code to the x11/server.py file. It
> is
> > nothing pretty;
> Can you post this code?
> We now have code that achieves something similar in trunk:
> http://xpra.org/trac/ticket/988

I added the following two functions to XpraServer and then started the
on class initialization.

    def schedule_pictures_thread(self):
        while True:

    def get_pictures(self):
        for wid in sorted(self._id_to_window.keys()):
            if wid <= 1:
            window = self._id_to_window[wid]
                w, h = window.get_dimensions()
                image = window.get_image( 0, 0, w, h,logger=log.info)
                if (image == None):
                rgb = {
                    "XRGB"   : "RGB",
                    "BGRX"   : "RGB",
                    "RGBA"   : "RGBA",
                    "BGRA"   : "RGBA",
                }.get(image.get_pixel_format(), image.get_pixel_format())
                img = Image.frombuffer(rgb, (w, h), image.get_pixels(),
"raw",image.get_pixel_format(), image.get_rowstride())
                img.save("/tmp/%d-%d.png" % (wid,self._image_count), "PNG")
                self._image_count = self._image_count + 1

>  I was just interested in doing a little experimentation. I
> > have two issues that seemingly should be easy to fix but I have yet to
> > figure out how to hack around them:
> > 1) The server seems to be ignorant of any window pixmaps until the first
> > client attaches. Specifically, from my naive perspective, it seems like
> > Xpra cannot find the pixmap for any windows until the first attachment.
> Windows are not mapped onto the virtual screen until a client maps them
> somewhere on their desktop.
> And unmapped windows do not have pixmaps..

> 2) If, after an initial attach there are no attached clients, I can get
> > access to the window pixmaps but they are not updated unless someone is
> > attached, i.e, they remain in the same state as the last time there was
> an
> > attachment. Conceptually, it makes sense to avoid updating the pixmaps if
> > no one is attached but, for the life of me, I cannot find the switch that
> > turns pixmap updating on/off according to whether a client is attached or
> > not.
> If you share your code it will be easier to talk about it.

What I would like to do is keep the window mapped until its destruction.
way, I can take accurate screenshots of running programs regardless of if I
am attached  to them. I believe I have found that calling the setup() window
 method when it is initially created by the wm in _manage_client creates the
pixmap. Now, I would like to change a bit of code that will a) map a window
as soon as it is created by the wm and b) only unmap windows on
destruction. I am looking for some hints on where I should be making these

Dan DaCosta

> Cheers
> Antoine
> >
> > Thanks in Advance!
> > Dan DaCosta
> > _______________________________________________
> > shifter-users mailing list
> > shifter-users at lists.devloop.org.uk
> > http://lists.devloop.org.uk/mailman/listinfo/shifter-users
> _______________________________________________
> shifter-users mailing list
> shifter-users at lists.devloop.org.uk
> http://lists.devloop.org.uk/mailman/listinfo/shifter-users

More information about the shifter-users mailing list