Jump to content
  • Advertisement
Sign in to follow this  
theweirdn8

Unable to successfully un-minimize window in SDL 2.x [ Code Provided]

This topic is 919 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

 
Hi there,
 
Currently, my program is losing focus and not processing after minimizing and unminimizing(restore/re-expose) of window.
 
I've added debugging code to my code to search out what is happening after you restore the window post-hitting minimize.
 
The Event that seems to be occurring is SDL_WINDOWEVENT_EXPOSED.
 
After, the window is re-expose I attempt to process it; but nothing happens. The window it unresponsive until I hit restore down.
 
Here is my code:
 
void GPE_Renderer::handle_events(SDL_Event& e)
{
     //Window event occured
    if( e.type == SDL_WINDOWEVENT )
    {
        //Caption update flag
        switch( e.window.event )
        {
            //Get new dimensions and repaint on window size change
            case SDL_WINDOWEVENT_SIZE_CHANGED:
            case SDL_WINDOWEVENT_RESIZED:
                if( isMinimized)
                {
                    SDL_RestoreWindow(gpeWindow);
                    //SDL_SetWindowSize(gpeWindow,mWidth,mHeight);
                    rWidth = mWidth;
                    rHeight = mHeight;
                    isMinimized = false;
                    clear_renderer();
                    record_error("Window unminimized");
                }
                else
                {
                    if( e.window.data1>0 && e.window.data2 > 0)
                    {
                        mWidth = rWidth = e.window.data1;
                        mHeight = rHeight = e.window.data2;
                        isMinimized = false;
                        record_error("Window reiszed with proper data");
                    }
                    else
                    {
                        rWidth = mWidth;
                        rHeight = mHeight;
                        record_error("Window resize with improper data");
                    }
                }
                WINDOW_WAS_JUST_RESIZED = true;
            break;
            case SDL_WINDOWEVENT_MINIMIZED:
                isMinimized = true;
                isResized = true;
                mWidth = rWidth;
                mHeight = rHeight;
                WINDOW_WAS_JUST_RESIZED = true;
                record_error("Window minimized");
            break;
            case SDL_WINDOWEVENT_ENTER:
 
            break;
            case SDL_WINDOWEVENT_EXPOSED:
                if( isMinimized)
                {
                    isMinimized = false;
                    WINDOW_WAS_JUST_RESIZED = true;
                    SDL_SetWindowSize(gpeWindow,mWidth,mHeight);
                    SCREEN_WIDTH =  rWidth = mWidth;
                    SCREEN_HEIGHT = rHeight = mHeight;
                    clear_renderer();
                    record_error("Window unminimized from being exposed!");
                 }
                else
                {
                    record_error("Window exposed!!!!");
                }
            break;
            case SDL_WINDOWEVENT_LEAVE:
            break;
            case SDL_WINDOWEVENT_FOCUS_GAINED:
                SDL_SetWindowTitle(gpeWindow,"[Game Pencil Engine]");
            break;
            case SDL_WINDOWEVENT_FOCUS_LOST:
                SDL_SetWindowTitle(gpeWindow,"*Out of Focus*Game Pencil Engine");
            break;
            case SDL_WINDOWEVENT_CLOSE:
            break;
            case SDL_WINDOWEVENT_RESTORED:
                if( isMinimized)
                {
                    //SDL_SetWindowSize(gpeWindow,mWidth,mHeight);
                    rWidth = mWidth;
                    rHeight = mHeight;
                    isMinimized = false;
                    record_error("Window restored and unminimized");
                }
                else
                {
                    rWidth = mWidth = MIN_WINDOW_WIDTH;
                    rHeight = mHeight = MIN_WINDOW_HEIGHT;
                    record_error("Window restored.");
                }
                isResized = true;
                WINDOW_WAS_JUST_RESIZED = true;
            break;
            case SDL_WINDOWEVENT_NONE:
            break;
            default:
            break;
        }
    }
}
 

Share this post


Link to post
Share on other sites
Advertisement
What happens if you remove the calls to SDL_SetWindowSize and SDL_RestoreWindow?

Share this post


Link to post
Share on other sites

Nothing changes, the problem remains the same.

 

The event that is happpening in the switch-statement is the "SDL_WINDOWEVENT_EXPOSED" event

Share this post


Link to post
Share on other sites
 
I fixed it.
 
Apparently I have to restore hte window.
 
I added these lines in the expose event(after checking on miniimize) and this works:
                    SDL_RestoreWindow(gpeWindow);
                    SDL_MaximizeWindow(gpeWindow);
                    SDL_GetWindowSize(gpeWindow,&mWidth,&mHeight);
Edited by theweirdn8

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!