# Restore SDL app, previously minimized, after screen saver

**URL:** <https://discourse.libsdl.org/t/restore-sdl-app-previously-minimized-after-screen-saver/20127>\
**Category:** SDL Development\
**Created:** [November 7, 2013, 6:35pm UTC](https://discourse.libsdl.org/t/restore-sdl-app-previously-minimized-after-screen-saver/20127 "2013-11-07T18:35:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Armando\_Alaminos\_Bou](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@Armando\_Alaminos\_Bou](https://discourse.libsdl.org/u/Armando_Alaminos_Bou)\
**Post date:** [November 7, 2013, 6:35pm UTC](https://discourse.libsdl.org/t/restore-sdl-app-previously-minimized-after-screen-saver/20127/1 "2013-11-07T18:35:34Z")

</div>

I ported some applications from SDL 1.2.15 to 2.0.1. They are Windows 32bits applications, compiled with Intel C/C++ (composer XE 2013). Using C, not C++.  
I found one problem:  
Condition : the applications was minimized and the system enters the screen-saver mode.  
Result : when the system exits the screen saver and I click to restore the SDL app, the window returns in black. To refresh the window to the proper state I need to create an event (click, resize, move, etc).  
I am assuming that some events were ignored in my code, but I do not find any other message to trigger the re-paint { SDL\_UpdateTexture(…); SDL\_SetRenderDrawColor(…);  
SDL\_RenderClear(…); SDL\_RenderCopy(…); SDL\_RenderPresent(); }  
The messages used so far to trigger windows re-paint are :

```
       case SDL_WINDOWEVENT_EXPOSED:
       case SDL_WINDOWEVENT_RESIZED:
       case SDL_WINDOWEVENT_RESTORED:
   case SDL_WINDOWEVENT_MAXIMIZED:
   case SDL_WINDOWEVENT_FOCUS_GAINED:
   case SDL_WINDOWEVENT_SIZE_CHANGED:
   case SDL_WINDOWEVENT_MOVED:
	                   mevis_sdl_RefreshWindow();
			   break;

```

All other re-paint conditions are working fine. The problem is only evident after minimization followed by screen saver.

Any advice ?  
Thanks.  
Armando AB------------------------  
Armando Alaminos Bouza

---

<div class="post-metadata">

**Author:** ![Armando\_Alaminos\_Bou](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@Armando\_Alaminos\_Bou](https://discourse.libsdl.org/u/Armando_Alaminos_Bou)\
**Post date:** [November 7, 2013, 10:34pm UTC](https://discourse.libsdl.org/t/restore-sdl-app-previously-minimized-after-screen-saver/20127/2 "2013-11-07T22:34:17Z")

</div>

I got an alternative solution, but it is not an elegant one. Creating a timer and pushing a SDL\_USEREVENT the application is forced to re-paint for all the process life.  
It is not an energy efficient way…  
Any way, I think that there is a better solution.  
I will be glad receiving other suggestions.  
Thanks------------------------  
Armando Alaminos Bouza

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [November 10, 2013, 10:52pm UTC](https://discourse.libsdl.org/t/restore-sdl-app-previously-minimized-after-screen-saver/20127/3 "2013-11-10T22:52:12Z")

</div>

There was a bug with SDL detecting minimize state.

Can you try the latest snapshot here?  
[http://www.libsdl.org/tmp/SDL-2.0.zip](http://www.libsdl.org/tmp/SDL-2.0.zip)

Thanks!On Thu, Nov 7, 2013 at 10:35 AM, alabouza wrote:

> I ported some applications from SDL 1.2.15 to 2.0.1. They are Windows  
> 32bits applications, compiled with Intel C/C++ (composer XE 2013). Using C,  
> not C++.  
> I found one problem:  
> Condition : the applications was minimized and the system enters the  
> screen-saver mode.  
> Result : when the system exits the screen saver and I click to restore the  
> SDL app, the window returns in black. To refresh the window to the proper  
> state I need to create an event (click, resize, move, etc).  
> I am assuming that some events were ignored in my code, but I do not find  
> any other message to trigger the re-paint { SDL\_UpdateTexture(…);  
> SDL\_SetRenderDrawColor(…);  
> SDL\_RenderClear(…); SDL\_RenderCopy(…); SDL\_RenderPresent(); }  
> The messages used so far to trigger windows re-paint are :
> 
> case SDL\_WINDOWEVENT\_EXPOSED:  
> case SDL\_WINDOWEVENT\_RESIZED:  
> case SDL\_WINDOWEVENT\_RESTORED:  
> case SDL\_WINDOWEVENT\_MAXIMIZED:  
> case SDL\_WINDOWEVENT\_FOCUS\_GAINED:  
> case SDL\_WINDOWEVENT\_SIZE\_CHANGED:  
> case SDL\_WINDOWEVENT\_MOVED:  
> mevis\_sdl\_RefreshWindow();  
> break;
> 
> All other re-paint conditions are working fine. The problem is only  
> evident after minimization followed by screen saver.
> 
> Any advice ?  
> Thanks.  
> Armando AB
> 
> * * *
> 
> Armando Alaminos Bouza
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![Armando\_Alaminos\_Bou](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@Armando\_Alaminos\_Bou](https://discourse.libsdl.org/u/Armando_Alaminos_Bou)\
**Post date:** [November 11, 2013, 12:06am UTC](https://discourse.libsdl.org/t/restore-sdl-app-previously-minimized-after-screen-saver/20127/4 "2013-11-11T00:06:35Z")

</div>

Sure ! I will compile the snapshot with Intel(R) C++ Compiler XE 13.1.3.198 to have the same conditions and will let you know.  
Thanks.

Sam Lantinga wrote:\> There was a bug with SDL detecting minimize state.

> Can you try the latest snapshot here?  
> [http://www.libsdl.org/tmp/SDL-2.0.zip](http://www.libsdl.org/tmp/SDL-2.0.zip) ([http://www.libsdl.org/tmp/SDL-2.0.zip](http://www.libsdl.org/tmp/SDL-2.0.zip))
> 
> Thanks!
> 
> On Thu, Nov 7, 2013 at 10:35 AM, alabouza \<@Armando\_Alaminos\_Bou (@Armando_Alaminos_Bou)\> wrote:
> 
> > ```
> > I ported some applications from SDL 1.2.15 to 2.0.1. They are Windows 32bits applications, compiled with Intel C/C++ (composer XE 2013). Using C, not C++.
> > 
> > ```
> > 
> > I found one problem:  
> > Condition : the applications was minimized and the system enters the screen-saver mode.  
> > Result : when the system exits the screen saver and I click to restore the SDL app, the window returns in black. To refresh the window to the proper state I need to create an event (click, resize, move, etc).  
> > I am assuming that some events were ignored in my code, but I do not find any other message to trigger the re-paint { SDL\_UpdateTexture(…); SDL\_SetRenderDrawColor(…);  
> > SDL\_RenderClear(…); SDL\_RenderCopy(…); SDL\_RenderPresent(); }  
> > The messages used so far to trigger windows re-paint are :
> > 
> > case SDL\_WINDOWEVENT\_EXPOSED:  
> > case SDL\_WINDOWEVENT\_RESIZED:  
> > case SDL\_WINDOWEVENT\_RESTORED:  
> > case SDL\_WINDOWEVENT\_MAXIMIZED:  
> > case SDL\_WINDOWEVENT\_FOCUS\_GAINED:  
> > case SDL\_WINDOWEVENT\_SIZE\_CHANGED:  
> > case SDL\_WINDOWEVENT\_MOVED:  
> > mevis\_sdl\_RefreshWindow();  
> > break;
> > 
> > All other re-paint conditions are working fine. The problem is only evident after minimization followed by screen saver.
> > 
> > Any advice ?  
> > Thanks.  
> > Armando AB
> > 
> > Armando Alaminos Bouza
> > 
> > * * *
> > 
> > SDL mailing list  
> > SDL at [lists.libsdl.org](http://lists.libsdl.org) (SDL at [lists.libsdl.org](http://lists.libsdl.org))  
> > [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org) ([http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org))

* * *

Armando Alaminos Bouza

---

<div class="post-metadata">

**Author:** ![Armando\_Alaminos\_Bou](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@Armando\_Alaminos\_Bou](https://discourse.libsdl.org/u/Armando_Alaminos_Bou)\
**Post date:** [November 14, 2013, 10:36am UTC](https://discourse.libsdl.org/t/restore-sdl-app-previously-minimized-after-screen-saver/20127/5 "2013-11-14T10:36:09Z")

</div>

I re-compiled the SDL 2 snapshot with Intel C++ Compiler XE 13.1.3.198. I am testing with three applications ported from SDL 1.2.15 and the previous problem is gone, as far as I can detect.

Thanks.

Sam Lantinga wrote:\> There was a bug with SDL detecting minimize state.

> Can you try the latest snapshot here?  
> [http://www.libsdl.org/tmp/SDL-2.0.zip](http://www.libsdl.org/tmp/SDL-2.0.zip) ([http://www.libsdl.org/tmp/SDL-2.0.zip](http://www.libsdl.org/tmp/SDL-2.0.zip))
> 
> Thanks!
> 
> On Thu, Nov 7, 2013 at 10:35 AM, alabouza \<@Armando\_Alaminos\_Bou (@Armando_Alaminos_Bou)\> wrote:
> 
> > ```
> > I ported some applications from SDL 1.2.15 to 2.0.1. They are Windows 32bits applications, compiled with Intel C/C++ (composer XE 2013). Using C, not C++.
> > 
> > ```
> > 
> > I found one problem:  
> > Condition : the applications was minimized and the system enters the screen-saver mode.  
> > Result : when the system exits the screen saver and I click to restore the SDL app, the window returns in black. To refresh the window to the proper state I need to create an event (click, resize, move, etc).  
> > I am assuming that some events were ignored in my code, but I do not find any other message to trigger the re-paint { SDL\_UpdateTexture(…); SDL\_SetRenderDrawColor(…);  
> > SDL\_RenderClear(…); SDL\_RenderCopy(…); SDL\_RenderPresent(); }  
> > The messages used so far to trigger windows re-paint are :
> > 
> > case SDL\_WINDOWEVENT\_EXPOSED:  
> > case SDL\_WINDOWEVENT\_RESIZED:  
> > case SDL\_WINDOWEVENT\_RESTORED:  
> > case SDL\_WINDOWEVENT\_MAXIMIZED:  
> > case SDL\_WINDOWEVENT\_FOCUS\_GAINED:  
> > case SDL\_WINDOWEVENT\_SIZE\_CHANGED:  
> > case SDL\_WINDOWEVENT\_MOVED:  
> > mevis\_sdl\_RefreshWindow();  
> > break;
> > 
> > All other re-paint conditions are working fine. The problem is only evident after minimization followed by screen saver.
> > 
> > Any advice ?  
> > Thanks.  
> > Armando AB
> > 
> > Armando Alaminos Bouza
> > 
> > * * *
> > 
> > SDL mailing list  
> > SDL at [lists.libsdl.org](http://lists.libsdl.org) (SDL at [lists.libsdl.org](http://lists.libsdl.org))  
> > [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org) ([http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org))

* * *

Armando Alaminos Bouza

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [November 15, 2013, 4:05am UTC](https://discourse.libsdl.org/t/restore-sdl-app-previously-minimized-after-screen-saver/20127/6 "2013-11-15T04:05:26Z")

</div>

Great, thanks!On Thu, Nov 14, 2013 at 2:36 AM, alabouza wrote:

> I re-compiled the SDL 2 snapshot with Intel C++ Compiler XE 13.1.3.198.  
> I am testing with three applications ported from SDL 1.2.15 and the  
> previous problem is gone, as far as I can detect.
> 
> Thanks.
> 
> Sam Lantinga wrote:
> 
> There was a bug with SDL detecting minimize state.
> 
> Can you try the latest snapshot here?  
> [http://www.libsdl.org/tmp/SDL-2.0.zip](http://www.libsdl.org/tmp/SDL-2.0.zip)
> 
> Thanks!
> 
> On Thu, Nov 7, 2013 at 10:35 AM, alabouza \<\> wrote:
> 
> Quote:
> 
> I ported some applications from SDL 1.2.15 to 2.0.1. They are Windows  
> 32bits applications, compiled with Intel C/C++ (composer XE 2013). Using C,  
> not C++.  
> I found one problem:  
> Condition : the applications was minimized and the system enters the  
> screen-saver mode.  
> Result : when the system exits the screen saver and I click to restore the  
> SDL app, the window returns in black. To refresh the window to the proper  
> state I need to create an event (click, resize, move, etc).  
> I am assuming that some events were ignored in my code, but I do not find  
> any other message to trigger the re-paint { SDL\_UpdateTexture(…);  
> SDL\_SetRenderDrawColor(…);  
> SDL\_RenderClear(…); SDL\_RenderCopy(…); SDL\_RenderPresent(); }  
> The messages used so far to trigger windows re-paint are :
> 
> case SDL\_WINDOWEVENT\_EXPOSED:  
> case SDL\_WINDOWEVENT\_RESIZED:  
> case SDL\_WINDOWEVENT\_RESTORED:  
> case SDL\_WINDOWEVENT\_MAXIMIZED:  
> case SDL\_WINDOWEVENT\_FOCUS\_GAINED:  
> case SDL\_WINDOWEVENT\_SIZE\_CHANGED:  
> case SDL\_WINDOWEVENT\_MOVED:  
> mevis\_sdl\_RefreshWindow();  
> break;
> 
> All other re-paint conditions are working fine. The problem is only  
> evident after minimization followed by screen saver.
> 
> Any advice ?  
> Thanks.  
> Armando AB
> 
> Armando Alaminos Bouza
> 
> * * *
> 
> SDL mailing list
> 
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
> 
> * * *
> 
> Armando Alaminos Bouza
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
