fix: High background GPU usage on Windows if window is minimized

This commit is contained in:
WerWolv
2025-08-02 23:35:47 +02:00
parent 693a0f2516
commit 2db85ced59

View File

@@ -322,9 +322,12 @@ namespace hex {
ImHexApi::System::impl::setMainWindowSize(width, height);
}
if (!glfwGetWindowAttrib(m_window, GLFW_VISIBLE) || glfwGetWindowAttrib(m_window, GLFW_ICONIFIED)) {
while (!glfwGetWindowAttrib(m_window, GLFW_VISIBLE) || glfwGetWindowAttrib(m_window, GLFW_ICONIFIED)) {
// If the application is minimized or not visible, don't render anything
// glfwWaitEvents() is supposed to block the thread, but it does pretty often spuriously wake up anyway
// so we need to keep looping here until the window is visible again, adding a short sleep to avoid busy-waiting
glfwWaitEvents();
std::this_thread::sleep_for(100ms);
}
static ImVec2 lastWindowSize = ImHexApi::System::getMainWindowSize();