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 is 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;
}
}
}
So it appears that the window has to be restored manually at this point(and maximized for normal effect).
Here is what I added in the SDL_WINDOWEVENT_EXPOSED
case after checking if the screen was minimized:
I fixed it.
Apparently I have to restore the window.
I added these lines in the expose event (after checking on minimize) and this works:
SDL_RestoreWindow(gpeWindow);
SDL_MaximizeWindow(gpeWindow);
SDL_GetWindowSize(gpeWindow,&mWidth,&mHeight);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.