diff options
author | m-stephen <truestyle2005@163.com> | 2019-07-10 10:08:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-10 10:08:27 +0800 |
commit | b0b481279483414a9aa41083eee9ed36f9242e69 (patch) | |
tree | 4dd78fa3eff786b5dc7b39f713ff9a302456b694 /platform/glfw | |
parent | 604844a8b3f97952c2f9049746fd41a4e01f3ac0 (diff) | |
parent | 6b59db8fb0118633e354b4fff5d615a0f095faa7 (diff) | |
download | qtlocation-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')
-rw-r--r-- | platform/glfw/glfw_view.cpp | 8 | ||||
-rw-r--r-- | platform/glfw/glfw_view.hpp | 1 |
2 files changed, 9 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)) { diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp index 9c9661546c..54b89ba2d9 100644 --- a/platform/glfw/glfw_view.hpp +++ b/platform/glfw/glfw_view.hpp @@ -68,6 +68,7 @@ private: static void onFramebufferResize(GLFWwindow *window, int width, int height); static void onMouseClick(GLFWwindow *window, int button, int action, int modifiers); static void onMouseMove(GLFWwindow *window, double x, double y); + static void onWindowFocus(GLFWwindow *window, int focused); // Internal void report(float duration); |