<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span style="font-weight: bold;">Hi, I try to make a program who renders a background when I launch X, for now I'm able to render a rectangle filled with a color, but I didn't find how to put a picture in this rectangle, I add my code :</span></div><div><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">#include<cairo.h><br>#include<cairo-xlib.h><br>#include<X11/Xlib.h><br>#include<stdio.h><br>#include<stdlib.h><br>#include<string.h><br><br>#define DPYW DisplayWidth(dpy,scr)<br>#define DPYH DisplayHeight(dpy,scr)<br><br><br>int main(int argc, char *argv[]){<br>        Display *dpy;<br>        int
 scr;<br>        Window rootwin;<br>        Window wbg;<br>        XEvent e;<br>        cairo_surface_t *bg;<br><br><br>        scr=DefaultScreen(dpy);<br>        rootwin=RootWindow(dpy, scr);<br>        wbg=XCreateSimpleWindow(dpy,rootwin,0,0,<br>                                DPYW,DPYH,0,<br>                                BlackPixel(dpy,
 scr),<br>                                BlackPixel(dpy, scr) );<br><br><br>        XStoreName(dpy, wbg, "background");<br>        XSelectInput(dpy, wbg, ExposureMask);<br>        XMapWindow(dpy, wbg);<br><br>//      bg=cairo_xlib_surface_create(dpy, wbg, DefaultVisual(dpy, 0), DPYW, DPYH);<br>        bg=cairo_image_surface_create_from_png("/usr/share/backgrounds/wallpaper.png");<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">        while(1)
 {<br>                XNextEvent(dpy, &e);<br>                if(e.type==Expose && e.xexpose.count<1) {<br>                cairo_t *c;<br><br>                c=cairo_create(bg);<br>        //      cairo_rectangle(c,0,0,DPYW,DPYH);<br>        //      cairo_set_source_rgb(c,0.5,0,0);<br>        //      cairo_fill(c);<br>        //      cairo_show_page(c);<br>       
 //      cairo_destroy(c);<br><br>                cairo_set_source_surface (c, bg, 100, 100);<br>                cairo_paint(c);<br>        //      cairo_show_page(c);<br>        //      cairo_surface_destroy(bg);<br>                cairo_destroy(c);<br>                }<br>        }<br><br>        cairo_surface_destroy(bg);<br>        XCloseDisplay(dpy);<br><br>        return
 0;<br>}<br><br><span style="font-weight: bold;">I don't understand what it's missing, or what I'm doing wrong.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;">nicoo</span><br></div></div></body></html>