summaryrefslogtreecommitdiff
path: root/platform/glfw/glfw_view.cpp
diff options
context:
space:
mode:
authorm-stephen <truestyle2005@163.com>2019-07-10 10:08:27 +0800
committerGitHub <noreply@github.com>2019-07-10 10:08:27 +0800
commitb0b481279483414a9aa41083eee9ed36f9242e69 (patch)
tree4dd78fa3eff786b5dc7b39f713ff9a302456b694 /platform/glfw/glfw_view.cpp
parent604844a8b3f97952c2f9049746fd41a4e01f3ac0 (diff)
parent6b59db8fb0118633e354b4fff5d615a0f095faa7 (diff)
downloadqtlocation-mapboxgl-b0b481279483414a9aa41083eee9ed36f9242e69.tar.gz
Merge branch 'master' into Stephen-Exclude-offline-CJK-By-Defaultupstream/Stephen-Exclude-offline-CJK-By-Default
Diffstat (limited to 'platform/glfw/glfw_view.cpp')
-rw-r--r--platform/glfw/glfw_view.cpp8
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)) {