[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg
Subject:    How to set Xlib window background transpatrent?
From:       "=?ISO-8859-1?B?TElERQ==?=" <1053481745 () qq ! com>
Date:       2014-04-14 2:48:04
Message-ID: tencent_6C513FCC29AACE8F53BDAF78 () qq ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]

[Attachment #4 (text/plain)]

Hi:
    I want to create a window that has transparent background.How to do?I use \
XSetBackground(display, gc, 0), the background is black.I change the depth of the \
screen to 32.The resault is still black.Here is my code:  
        display = XOpenDisplay(getenv("DISPALY"));
        screen = DefaultScreen(display);
        depth = DefaultDepth(display,screen);
        printf("depth: %d\n", depth);
        rootwindow = RootWindow(display,screen);


        XVisualInfo vinfo;
        XMatchVisualInfo(display, DefaultScreen(display), 32, TrueColor, &vinfo);


        XSetWindowAttributes attr;
        attr.colormap = XCreateColormap(display, DefaultRootWindow(display), \
vinfo.visual, AllocNone);  attr.border_pixel = 0;
        attr.background_pixel = 0; 


        window = XCreateWindow(display, DefaultRootWindow(display), 0, 0, 1440, 900, \
                0, vinfo.depth, InputOutput,
                        vinfo.visual, CWColormap | CWBorderPixel | CWBackPixel, \
&attr);  
        gc = XCreateGC (display, window, 0, NULL);
       XSetBackground(display, gc, 0L);


[Attachment #5 (text/html)]

<div>Hi:</div><div>&nbsp; &nbsp; I want to create a window that has transparent \
background.How to do?I use XSetBackground(display, gc, 0), the background is black.I \
change the depth of the screen to 32.The resault is still black.Here is my \
code:</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; \
&nbsp; display = XOpenDisplay(getenv("DISPALY"));</div><div>&nbsp; &nbsp; &nbsp; \
&nbsp; screen = DefaultScreen(display);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; depth = \
DefaultDepth(display,screen);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("depth: \
%d\n", depth);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; rootwindow = \
RootWindow(display,screen);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
XVisualInfo vinfo;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; XMatchVisualInfo(display, \
DefaultScreen(display), 32, TrueColor, &amp;vinfo);</div><div><br></div><div><span \
style="line-height: 1.5;">&nbsp; &nbsp; &nbsp; &nbsp; XSetWindowAttributes \
attr;</span></div><div>&nbsp; &nbsp; &nbsp; &nbsp; attr.colormap = \
XCreateColormap(display, DefaultRootWindow(display), vinfo.visual, \
AllocNone);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; attr.border_pixel = \
0;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; attr.background_pixel = 0;<span \
style="line-height: 1.5;">&nbsp;</span></div><div><span style="line-height: \
1.5;"><br></span></div><div><span style="line-height: 1.5;">&nbsp; &nbsp; &nbsp; \
&nbsp; window = XCreateWindow(display, DefaultRootWindow(display), 0, 0, 1440, 900, \
0, vinfo.depth, InputOutput,</span></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vinfo.visual, CWColormap | \
CWBorderPixel | CWBackPixel, &amp;attr);</div><div>&nbsp; &nbsp; \
&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; gc = XCreateGC (display, window, 0, \
NULL);</div><div>&nbsp; &nbsp; &nbsp; &nbsp;<span style="line-height: \
1.5;">XSetBackground(display,&nbsp;</span><span style="line-height: \
1.5;">gc,</span><span style="line-height: \
1.5;">&nbsp;0L);</span></div><div><br></div><div><br></div><div><br></div><div>&nbsp; \
&nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; \
&nbsp;&nbsp;</div><div><br></div><div><br></div><div><br></div><div>&nbsp; &nbsp; \
&nbsp; &nbsp;&nbsp;</div>



_______________________________________________
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: %(user_address)s

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic