add minimize / restore for win32

This commit is contained in:
Mircea Rila 2014-08-12 22:22:47 +03:00
parent 46cdd6f8dd
commit cfafeb1e87
2 changed files with 24 additions and 1 deletions

View File

@ -24,6 +24,7 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCGLViewImpl.h" #include "CCGLViewImpl.h"
#include "CCApplication.h"
#include "base/CCDirector.h" #include "base/CCDirector.h"
#include "base/CCTouch.h" #include "base/CCTouch.h"
#include "base/CCEventDispatcher.h" #include "base/CCEventDispatcher.h"
@ -101,6 +102,14 @@ public:
_view = view; _view = view;
} }
static void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified)
{
if (_view)
{
_view->onGLFWWindowIconifyCallback(window, iconified);
}
}
private: private:
static GLViewImpl* _view; static GLViewImpl* _view;
}; };
@ -352,6 +361,7 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
glfwSetWindowPosCallback(_mainWindow, GLFWEventHandler::onGLFWWindowPosCallback); glfwSetWindowPosCallback(_mainWindow, GLFWEventHandler::onGLFWWindowPosCallback);
glfwSetFramebufferSizeCallback(_mainWindow, GLFWEventHandler::onGLFWframebuffersize); glfwSetFramebufferSizeCallback(_mainWindow, GLFWEventHandler::onGLFWframebuffersize);
glfwSetWindowSizeCallback(_mainWindow, GLFWEventHandler::onGLFWWindowSizeFunCallback); glfwSetWindowSizeCallback(_mainWindow, GLFWEventHandler::onGLFWWindowSizeFunCallback);
glfwSetWindowIconifyCallback(_mainWindow, GLFWEventHandler::onGLFWWindowIconifyCallback);
setFrameSize(rect.size.width, rect.size.height); 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) #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
static bool glew_dynamic_binding() static bool glew_dynamic_binding()
{ {

View File

@ -130,8 +130,9 @@ protected:
void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y); void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y);
void onGLFWframebuffersize(GLFWwindow* window, int w, int h); void onGLFWframebuffersize(GLFWwindow* window, int w, int h);
void onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height); void onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height);
void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified);
bool _captured; bool _captured;
bool _supportTouch; bool _supportTouch;
bool _isInRetinaMonitor; bool _isInRetinaMonitor;
bool _isRetinaEnabled; bool _isRetinaEnabled;