From 2db85ced59b3a40a256fb305a5f2e667987f0ad5 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 2 Aug 2025 23:35:47 +0200 Subject: [PATCH] fix: High background GPU usage on Windows if window is minimized --- main/gui/source/window/window.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 132be428b..ca48295e6 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -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();