[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Where to start for making an alpha blended window thingy
From: Shashank Singh <shashank.personal () gmail ! com>
Date: 2009-05-18 11:20:33
Message-ID: 99584b820905180408i26b19ebja70d1ba5aaaad142 () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi,
if you want to make a ARGB window using xlib/Qt here is the code i use
/**files to include from xlib*/
#include <X11/extensions/Xrender.h>
#include <X11/Xlib.h>
/**getting display*/
Display *dpy = XOpenDisplay ( 0 ); // open default display
if ( !dpy ) {
qWarning ( "Cannot connect to the X server" );
exit ( 1 );
}
/**code for argb visual*/
bool argbVisual=false;
int screen = DefaultScreen ( dpy );
Colormap colormap = 0;
Visual *visual = 0;
int eventBase, errorBase;
if ( XRenderQueryExtension ( dpy, &eventBase, &errorBase ) ) {
qWarning ("You have ARGB support");
int nvi;
XVisualInfo templ;
templ.screen = screen;
templ.depth = 32;
templ.c_class = TrueColor;
XVisualInfo *xvi = XGetVisualInfo ( dpy, VisualScreenMask |
VisualDepthMask |
VisualClassMask, &templ, &nvi );
for ( int i = 0; i < nvi; ++i ) {
XRenderPictFormat *format = XRenderFindVisualFormat ( dpy,
xvi[i].visual );
if ( format->type == PictTypeDirect && format->direct.alphaMask
) {
visual = xvi[i].visual;
colormap = XCreateColormap ( dpy, RootWindow ( dpy, screen
),
visual, AllocNone );
argbVisual=true;
break;
}
}
}
/**end of code for argb visual*/
then QApplication app (dpy, argc, argv,Qt::HANDLE ( visual ), Qt::HANDLE (
colormap ) );
On Thu, May 14, 2009 at 6:24 PM, Thomas Lübking <thomas.luebking@web.de>wrote:
> Am Thursday 14 May 2009 schrieb Harald Hvaal:
>
>
> > Do I need to write graphics routines through kwin plugin framework? Is
> if you want an effect on desktops/windows (like the cube switch etc.)
> that's likely the best location
>
>
> > there a flag in Qt that I can use to get an alpha blended backgroudn for
> a
> > qmainwindow?
> Qt 4.5 (only on window type widgets QWidget::isWindow())
> QWidget::setAttribute(Qt::WA_TranslucentBackground)
> this will however (obviously) only work on composited desktops
>
>
> > Maybe plasma has something for this? Is it even possible?
> if you want whatever you want on the desktop layer (i.e. below all normal
> windows), you can make a plasmoid (QGraphicsViewItem) and just use alpha
> blending
>
>
> Thomas
>
>
>
>
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> unsubscribe <<
>
>
--
Regards:
Shashank Singh
Associate - Software | New Technologies team
Geodesic Limited | <http://www.geodesic.com>
Tel: +91 22 2831 2872
Blog:http://techfreaks4u.com/blog
Marble contributor : http://edu.kde.org/marble/
KDE-in Volunteer : http://www.kde.in/
[Attachment #5 (text/html)]
Hi,<br>if you want to make a ARGB window using xlib/Qt here is the code i \
use<br>/**files to include from xlib*/<br>#include \
<X11/extensions/Xrender.h><br>#include <X11/Xlib.h><br> <br>/**getting \
display*/<br>
Display *dpy = XOpenDisplay ( 0 ); // open default display<br> if ( !dpy ) {<br> \
qWarning ( "Cannot connect to the X server" );<br> exit ( 1 );<br> \
}<br><br>/**code for argb visual*/<br> bool argbVisual=false;<br>
int screen = DefaultScreen ( dpy );<br> Colormap colormap = 0;<br> Visual \
*visual = 0;<br> int eventBase, errorBase;<br><br> if ( XRenderQueryExtension ( \
dpy, &eventBase, &errorBase ) ) {<br> qWarning ("You have ARGB \
support");<br>
int nvi;<br> XVisualInfo templ;<br> templ.screen = screen;<br> \
templ.depth = 32;<br> templ.c_class = TrueColor;<br> XVisualInfo *xvi \
= XGetVisualInfo ( dpy, VisualScreenMask |<br>
VisualDepthMask |<br> \
VisualClassMask, &templ, &nvi );<br><br> for ( int i = 0; i < nvi; \
++i ) {<br> XRenderPictFormat *format = XRenderFindVisualFormat ( dpy,<br>
xvi[i].visual );<br> if ( \
format->type == PictTypeDirect && format->direct.alphaMask ) {<br> \
visual = xvi[i].visual;<br> colormap = XCreateColormap ( dpy, \
RootWindow ( dpy, screen ),<br>
visual, AllocNone );<br> \
argbVisual=true;<br> break;<br> }<br> }<br> }<br> \
/**end of code for argb visual*/<br><br>then QApplication app (dpy, argc, \
argv,Qt::HANDLE ( visual ), Qt::HANDLE ( colormap ) );<br>
<br><br><br><div class="gmail_quote">On Thu, May 14, 2009 at 6:24 PM, Thomas Lübking \
<span dir="ltr"><<a \
href="mailto:thomas.luebking@web.de">thomas.luebking@web.de</a>></span> \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="font-family: 'Segoe'; font-size: 10pt; font-weight: 400; \
font-style: normal;">Am Thursday 14 May 2009 schrieb Harald Hvaal:<div \
class="im"><br> <p style="margin: 0px; text-indent: 0px;"><br></p>> Do I need to \
write graphics routines through kwin plugin framework? Is<br></div> if you want an \
effect on desktops/windows (like the cube switch etc.) that's likely the best \
location<div class="im"><br> <p style="margin: 0px; text-indent: 0px;"><br></p>> \
there a flag in Qt that I can use to get an alpha blended backgroudn for a<br> > \
qmainwindow? <br></div> Qt 4.5 (only on window type widgets QWidget::isWindow())<br>
QWidget::setAttribute(Qt::WA_TranslucentBackground)<br>
this will however (obviously) only work on composited desktops<div class="im"><br>
<p style="margin: 0px; text-indent: 0px;"><br></p>> Maybe plasma has something for \
this? Is it even possible?<br></div> if you want whatever you want on the desktop \
layer (i.e. below all normal windows), you can make a plasmoid (QGraphicsViewItem) \
and just use alpha blending<br><font color="#888888"> <p style="margin: 0px; \
text-indent: 0px;"><br></p>Thomas<br> <p style="margin: 0px; text-indent: \
0px;"><br></p><p style="margin: 0px; text-indent: 0px;"><br></p></font></div><br><br> \
>> Visit <a href="http://mail.kde.org/mailman/listinfo/kde-devel#unsub" \
target="_blank">http://mail.kde.org/mailman/listinfo/kde-devel#unsub</a> to \
unsubscribe <<<br> <br></blockquote></div><br><br clear="all"><br>-- \
<br>Regards:<br>Shashank Singh<br>Associate - Software | New Technologies \
team<br>Geodesic Limited | <<a \
href="http://www.geodesic.com">http://www.geodesic.com</a>> <br>
Tel: +91 22 2831 2872 <br><br>Blog:<a \
href="http://techfreaks4u.com/blog">http://techfreaks4u.com/blog</a><br>Marble \
contributor : <a href="http://edu.kde.org/marble/">http://edu.kde.org/marble/</a><br>KDE-in \
Volunteer : <a href="http://www.kde.in/">http://www.kde.in/</a><br>
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic