X window fades and loses color for SDL program in development.

Asked by Michael Williamson

I am writing a C program using the SDL2 library for X window graphics. When started, the windows are created correctly and display correctly initially. After 2 or 3 seconds the brightness fades and colors become gray. I do not know if the problem is with my use of the SDL2 library or the Ubuntu 14.02 window manager. I suspect the window manager because the same fade effect occurs with FireFox web browser when there is a network problem. As the program runs, the graphics are redrawn but faded and gray.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Michael Williamson
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

What is the output of:

lsb_release -a; uname -a

Thanks

Revision history for this message
Michael Williamson (michael-h-williamson) said :
#2

root@ast2:/home# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty
root@ast2:/home# uname -a
Linux ast2 3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:28:41 UTC 2015 i686 i686 i686 GNU/Linux

Also, I am pretty sure that Ubuntu (window manager) is responsible, and not SDL, because the title bar at the top of the window fades also. It happens more like 4 or 5 seconds after the window appears. I am guessing that the window manager concludes mistakenly that my SDL windows are inactive for some reason.

Revision history for this message
Michael Williamson (michael-h-williamson) said :
#3

The program I am testing is on github, if someone else wants to try it on their computer. It is project "michael9422/lensy", program name "spectrograph".

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#4

If you try a non composting session like XFCE (sudo apt-get install xfce4) then logoff and log back in to the XFCE session, is it OK?

Revision history for this message
Manfred Hampl (m-hampl) said :
#5

My knowledge about window management is that a program's window is temporarily greyed if the program does not answer (for a certain period). Are you sure that you are not running into some kind of endless loop in your program? What is the status of that program (running, waiting for io...) when that happens?

Revision history for this message
Michael Williamson (michael-h-williamson) said :
#6

Yes, I believe that is what is happening. (I will try XFCE too soon, as actionparsnip suggested). All that the program does so far is to calculate the next image and then redraw it using the SDL2 library. The redrawing continues after fading to gray scale. The windows are not interactive (yet). I do not know what the window manager wants from the program to indicate that it is alive, or what functions in SDL2 would provide that.

Revision history for this message
Michael Williamson (michael-h-williamson) said :
#7

It does *not* fade to gray using XFCE.
So, that means it is something specific to the default Ubuntu 14.04
window manager (Unity?).

Revision history for this message
Michael Williamson (michael-h-williamson) said :
#8

It does *not* fade to gray using XFCE.
So, that means it is something specific to the Ubuntu 14.04 default window manager (Unity?).

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#9

Compiz is the WM. Unity is a plugin for Unity.

Sounds like an issue with Compiz, or that the extra load put on the system due to Compiz is causing some issue.

Revision history for this message
Michael Williamson (michael-h-williamson) said :
#10

Agreed. Although, I doubt that it is a excessive CPU load issue, because I tested a loop which repeatedly draws graphics and then sleeps for one second, modifying the graphics each time, and it still fades.

I would like to be able to make a change to the program so it would not do that, but how? Is there a special place for compiz help?

Revision history for this message
Michael Williamson (michael-h-williamson) said :
#11

OK. I found the answer by googling "compiz SDL fade". I had to call the SDL2 function SDL_PumpEvents.
Thanks.