mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Handle iconification by waiting for events.
This commit is contained in:
parent
ff8a85ea2d
commit
1e7c6e3f49
@ -16,6 +16,7 @@ static GLFWwindow* s_window;
|
|||||||
static std::function<void()> s_redraw;
|
static std::function<void()> s_redraw;
|
||||||
static RunQueue* s_mainThreadTasks;
|
static RunQueue* s_mainThreadTasks;
|
||||||
static WindowPosition* s_winPos;
|
static WindowPosition* s_winPos;
|
||||||
|
static bool s_iconified;
|
||||||
|
|
||||||
static void glfw_error_callback( int error, const char* description )
|
static void glfw_error_callback( int error, const char* description )
|
||||||
{
|
{
|
||||||
@ -45,6 +46,11 @@ static void glfw_window_maximize_callback( GLFWwindow*, int maximized )
|
|||||||
s_winPos->maximize = maximized;
|
s_winPos->maximize = maximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void glfw_window_iconify_callback( GLFWwindow*, int iconified )
|
||||||
|
{
|
||||||
|
s_iconified = iconified != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Backend::Backend( const char* title, std::function<void()> redraw, RunQueue* mainThreadTasks )
|
Backend::Backend( const char* title, std::function<void()> redraw, RunQueue* mainThreadTasks )
|
||||||
{
|
{
|
||||||
@ -79,10 +85,12 @@ Backend::Backend( const char* title, std::function<void()> redraw, RunQueue* mai
|
|||||||
s_redraw = redraw;
|
s_redraw = redraw;
|
||||||
s_mainThreadTasks = mainThreadTasks;
|
s_mainThreadTasks = mainThreadTasks;
|
||||||
s_winPos = &m_winPos;
|
s_winPos = &m_winPos;
|
||||||
|
s_iconified = false;
|
||||||
|
|
||||||
glfwSetWindowPosCallback( s_window, glfw_window_pos_callback );
|
glfwSetWindowPosCallback( s_window, glfw_window_pos_callback );
|
||||||
glfwSetWindowSizeCallback( s_window, glfw_window_size_callback );
|
glfwSetWindowSizeCallback( s_window, glfw_window_size_callback );
|
||||||
glfwSetWindowMaximizeCallback( s_window, glfw_window_maximize_callback );
|
glfwSetWindowMaximizeCallback( s_window, glfw_window_maximize_callback );
|
||||||
|
glfwSetWindowIconifyCallback( s_window, glfw_window_iconify_callback );
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend::~Backend()
|
Backend::~Backend()
|
||||||
@ -104,12 +112,13 @@ void Backend::Run()
|
|||||||
{
|
{
|
||||||
while( !glfwWindowShouldClose( s_window ) )
|
while( !glfwWindowShouldClose( s_window ) )
|
||||||
{
|
{
|
||||||
glfwPollEvents();
|
if( s_iconified )
|
||||||
if( glfwGetWindowAttrib( s_window, GLFW_ICONIFIED ) )
|
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
|
glfwWaitEvents();
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glfwPollEvents();
|
||||||
s_redraw();
|
s_redraw();
|
||||||
if( !glfwGetWindowAttrib( s_window, GLFW_FOCUSED ) )
|
if( !glfwGetWindowAttrib( s_window, GLFW_FOCUSED ) )
|
||||||
{
|
{
|
||||||
@ -118,6 +127,7 @@ void Backend::Run()
|
|||||||
s_mainThreadTasks->Run();
|
s_mainThreadTasks->Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Backend::NewFrame( int& w, int& h )
|
void Backend::NewFrame( int& w, int& h )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user