This forum has been archived. All content is frozen. Please use KDE Discuss instead.

QPixmap::grabwindow yields black image.

Tags: None
(comma "," separated)
sambooka
Registered Member
Posts
6
Karma
0
Hello,

I have written a few screen savers for KDE4 using Qt, just for fun. One screen saver in particular grabs the desktop, converts to an image, and then uses that for a openGL texture. The problem is that with desktop effects off, it works flawlessly; with effects on, I get a black screen a large percentage of the time. When running in a window other than root window it never fails and my preview running in the setup window is fine as well.

I assume that there is some transition taking place when the screen saver starts and I am capturing a grey desktop? I tried moving the point that I take the shot but it yields the same result.

Any help is appreciated. I have been all over the net looking but come up empty handed.

Thanks so much.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
This is likely caused by KWin automatically unredirecting compositing for your window, hence causing a black image as your application is now opaque and covers everything.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
sambooka
Registered Member
Posts
6
Karma
0
Thanks for the reply. I think I understand what you are saying.

I considered using qdbus, to turn off compositing when the saver starts so that won't interfere with the desktop grab. Then turn it back on when the saver exits. That seems like a lot to go through for a silly saver, however!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You may wish to try toggling the value of "UnredirectFullscreen" in kwinrc ( not sure of its exact name ).


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
sambooka
Registered Member
Posts
6
Karma
0
Hey, its been some time since asking the original question. I still haven't come up with a solution other than turn off desktop effects. I have not poured lots of time into it either.

I did look for the kwinrc setting mentioned earlier in the post but I did not find it in the file. Just hoping maybe someone might have an answer.

I did play with qdbus and stopping stopping the effects as the saver started. It could work but it gets messy regarding the setup page, windowed mode or running full screen.

Thanks.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You may wish to check the source code of KSnapShot, as it functions fine with Desktop Effects enabled. It's source can be found in KDE SVN.

http://websvn.kde.org/trunk/KDE/kdegraphics/ksnapshot/


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
sambooka
Registered Member
Posts
6
Karma
0
Yes, thank you. Been there, too! I also looked a KCometen4 (I think thats how its spelled). That screen saver catches desktop as well. I loaded and played with it but it seems to have the same problem. Sometimes you just see the comets and no bounding cube. As the bounding cube uses the desktop ( if that option selected ) for the texture.

Maybe its a KDE - Nvidia issue? I never tried to use my saver on a machine that was not running Nvidia.

I believe the code to be good. I could post it. It ALWAYS works in windowed mode and in the preview screen of the setup page I wrote.

I like playing with OpenGL when time permits and thought perhaps I could throw some cool savers to the community if I get them debugged.

Thanks again bcooksley!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You may also wish to ask on kde-devel@kde.org. Make sure to have your code accessible somewhere however.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]