Getting window previews

Matthew Brush mbrush at codebrainz.ca
Tue Aug 4 01:44:16 CEST 2015


On 15-08-03 03:15 PM, adlo wrote:
> How do I make a Cairo surface from the Pixmap and draw it onto a widget?
>

Not a direct answer but a few tips to find stuff like this out:

1. Search Google for something like "cairo surface from pixmap" and 
click on the first search result and read the API reference.
2. If the information cannot be found by search Google or looking in the 
reference manual, usually there's someone on IRC for the project in 
question (ex. GTK+, Cairo, XLib, etc) that can help you.
3. If nobody's (answering) on IRC, ask on the mailing list for the 
project in question (ex. GTK+, Cairo, XLib, etc).
4. If you still can't find an answer, you can look at the source code of 
the libraries in question (ex. their examples and/or test suites), or at 
the source of other projects you know do what you're trying.

If after those steps you still can't find an answer, it's probable that 
what you're trying to do isn't possible or is just the wrong approach 
altogether. In your case step #1 should be enough.

For drawing Cairo surface onto a widget, that's just the normal way of 
drawing in GTK+ so your search terms for step #1 could be something like 
"drawing in gtk cairo" or something like that. The way to draw changed 
slightly in GTK3 so be aware that you will require some #ifdef stuff if 
you want to support the deprecated version too.

Cheers,
Matthew Brush

>
>
>> On 1 Aug 2015, at 01:04, Matthew Brush <mbrush at codebrainz.ca> wrote:
>>
>>> On 15-07-31 11:09 AM, adlo wrote:
>>> I am writing a GTK2 program that gets previews of all open windows. It uses the XCompositeNameWindowPixmap function.
>>>
>>> How do I put these previews into GtkImages?
>>
>> You'd probably get better answers on a GTK+ (or XLib) related mailing list but I think this function does what you want:
>>
>> https://developer.gnome.org/gdk-pixbuf/unstable/gdk-pixbuf-X-Drawables-to-Pixbufs.html#gdk-pixbuf-xlib-get-from-drawable
>>
>> And then create the GtkImage from the GdkPixbuf. I'd probably use Cairo for this myself since you can just make a surface from the Pixmap and draw it straight onto whichever widget you need (ex. a GtkDrawingArea).
>>
>> Cheers,
>> Matthew Brush
>> _______________________________________________
>> Xfce4-dev mailing list
>> Xfce4-dev at xfce.org
>> https://mail.xfce.org/mailman/listinfo/xfce4-dev
> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at xfce.org
> https://mail.xfce.org/mailman/listinfo/xfce4-dev
>



More information about the Xfce4-dev mailing list