SDL Forum Index
SDL
Simple DirectMedia Layer Forums
Reply to topic
Unable to successfully un-minimize window in SDL 2.x
theweirdn8


Joined: 10 Feb 2011
Posts: 23
Location: Chicago, IL, USA!
Reply with quote
Hello,

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:

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;
        }
    }
}

View user's profileSend private messageVisit poster's websiteAIM AddressYahoo MessengerMSN Messenger
theweirdn8


Joined: 10 Feb 2011
Posts: 23
Location: Chicago, IL, USA!
Reply with quote
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:
Code:

                    SDL_RestoreWindow(gpeWindow);
                    SDL_MaximizeWindow(gpeWindow);
                    SDL_GetWindowSize(gpeWindow,&mWidth,&mHeight);
View user's profileSend private messageVisit poster's websiteAIM AddressYahoo MessengerMSN Messenger
Unable to successfully un-minimize window in SDL 2.x
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic