From cfafeb1e87d2dbfa48d08f6143f4f837b7508b06 Mon Sep 17 00:00:00 2001 From: Mircea Rila Date: Tue, 12 Aug 2014 22:22:47 +0300 Subject: [PATCH] add minimize / restore for win32 --- cocos/platform/desktop/CCGLViewImpl.cpp | 22 ++++++++++++++++++++++ cocos/platform/desktop/CCGLViewImpl.h | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cocos/platform/desktop/CCGLViewImpl.cpp b/cocos/platform/desktop/CCGLViewImpl.cpp index 515e1272cf..cb8976fa92 100644 --- a/cocos/platform/desktop/CCGLViewImpl.cpp +++ b/cocos/platform/desktop/CCGLViewImpl.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCGLViewImpl.h" +#include "CCApplication.h" #include "base/CCDirector.h" #include "base/CCTouch.h" #include "base/CCEventDispatcher.h" @@ -101,6 +102,14 @@ public: _view = view; } + static void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified) + { + if (_view) + { + _view->onGLFWWindowIconifyCallback(window, iconified); + } + } + private: static GLViewImpl* _view; }; @@ -352,6 +361,7 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram glfwSetWindowPosCallback(_mainWindow, GLFWEventHandler::onGLFWWindowPosCallback); glfwSetFramebufferSizeCallback(_mainWindow, GLFWEventHandler::onGLFWframebuffersize); glfwSetWindowSizeCallback(_mainWindow, GLFWEventHandler::onGLFWWindowSizeFunCallback); + glfwSetWindowIconifyCallback(_mainWindow, GLFWEventHandler::onGLFWWindowIconifyCallback); setFrameSize(rect.size.width, rect.size.height); @@ -709,6 +719,18 @@ void GLViewImpl::onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int } } +void GLViewImpl::onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified) +{ + if (iconified == GL_TRUE) + { + Application::getInstance()->applicationDidEnterBackground(); + } + else + { + Application::getInstance()->applicationWillEnterForeground(); + } +} + #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) static bool glew_dynamic_binding() { diff --git a/cocos/platform/desktop/CCGLViewImpl.h b/cocos/platform/desktop/CCGLViewImpl.h index a9befbbd51..0bd3fd0373 100644 --- a/cocos/platform/desktop/CCGLViewImpl.h +++ b/cocos/platform/desktop/CCGLViewImpl.h @@ -130,8 +130,9 @@ protected: void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y); void onGLFWframebuffersize(GLFWwindow* window, int w, int h); void onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height); + void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified); - bool _captured; + bool _captured; bool _supportTouch; bool _isInRetinaMonitor; bool _isRetinaEnabled;