PDA

View Full Version : Fullscreen Transparent Windows



andyp
8th September 2009, 19:05
Can anyone direct me to how to get points interactively from the desktop ? I have tried creating a parentless fullscreen window with setWindowOpacity(0.01), then tracking mouse events while echoing a QRubberBand crosshair or rectangle. This works great on Windows (XP/Vista) but does not work on X11, because the setWindowOpacity has no effect. Basically I need a system which will work on all systems (without the need for X compositing). I just need to get points interactively, and do not have to use transparent windows if there is another way. Any pointers would be greatly appreciated.

giowck
8th September 2009, 19:18
this topic is useful to me.

/subscribed

hkvm
8th September 2009, 19:50
My ideas:
You can look at the source of the standard KDE color chooser widget (screenshot attached) -- when you click the pipette button it changes the cursor to crosshair and lets you click anywhere on screen to get the color of the clicked pixel. You could simply get just the positon. You can't "echo" the selected points directly, but it might be good enough.
EDIT: actually, you could probably create tiny colored borderless always-on-top windows that would mark the selected pixels :-)

Or you could (poorly) emulate transparency by displaying a snapshop of the desktop in your fullscreen window, then you can paint on it.

andyp
8th September 2009, 20:39
The workarounds people come up with always amaze me.
I like the idea of the desktop snapshot to be used as a new window background, but sledgehammer and walnut also come to mind. Also what happens with a dual screen situation ? Don't tell me: 2 screenshots.

andyp
8th September 2009, 20:48
The KDE color chooser code does what was suggested. It takes a screengrab of the desktop, displays it in a fullscreen QLabel and then works on it from there. So if KDE can't do it without this sort of scam, who are we to quibble ? It also has the advantage of being a universal platform-independent solution.

hkvm
8th September 2009, 21:24
You must have found some different code, the color picker has to do something more clever since the screen is updating normally even with video playing.

I looked at the source and it actually seems to install an X11 event filter. That seems quite elegant, but of course not platform-independent... Oh well, it's your choice :)

http://api.kde.org/4.0-api/kdelibs-apidocs/kdeui/html/kcolordialog_8cpp-source.html
(KDE3 version has slightly different code but seems like the same basic idea: http://mcs.une.edu.au/doc/kdelibs3-devel-3/kdeui/html/kcolordialog_8cpp-source.html)

void
KColorDialog::KColorDialogPrivate::slotColorPicker ()
{
bColorPicking = true;
#ifdef Q_WS_X11
filter = new KCDPickerFilter(q);
kapp->installX11EventFilter(filter);
#endif
q->grabMouse( Qt::CrossCursor );
q->grabKeyboard();
}

andyp
9th September 2009, 09:14
Yeah code I got hold of is completely different. I don't really want to be messing round with different code for different platforms if I can help it. Got the teeshirt etc. Thanks anyway.