diff options
Diffstat (limited to 'platform/glfw/glfw_view.cpp')
-rw-r--r-- | platform/glfw/glfw_view.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 41c3e93b35..43c4de9759 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -102,6 +102,7 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_) glfwSetFramebufferSizeCallback(window, onFramebufferResize); glfwSetScrollCallback(window, onScroll); glfwSetKeyCallback(window, onKey); + glfwSetWindowFocusCallback(window, onWindowFocus); glfwGetWindowSize(window, &width, &height); @@ -559,6 +560,13 @@ void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) { view->lastY = y; } +void GLFWView::onWindowFocus(GLFWwindow *window, int focused) { + if (focused == GLFW_FALSE) { // Focus lost. + auto *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window)); + view->rendererFrontend->getRenderer()->reduceMemoryUse(); + } +} + void GLFWView::run() { auto callback = [&] { if (glfwWindowShouldClose(window)) { |