From 6fd4d6e4ab7fa1ae1ba79fbb6de09bcd8961f548 Mon Sep 17 00:00:00 2001 From: halx99 Date: Mon, 3 Aug 2020 10:33:04 +0800 Subject: [PATCH] Adapte multi monitors --- cocos/platform/desktop/CCGLViewImpl-desktop.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp index a5a4a63be5..fc266c7f76 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp @@ -649,13 +649,11 @@ void GLViewImpl::setFullscreen() } void GLViewImpl::setFullscreen(int w, int h, int refreshRate) { - if (this->isFullscreen()) - return; - _monitor = glfwGetPrimaryMonitor(); - if (nullptr == _monitor) { + auto monitor = glfwGetPrimaryMonitor(); + if (nullptr == monitor || monitor == _monitor) { return; } - this->setFullscreen(_monitor, w, h, refreshRate); + this->setFullscreen(monitor, w, h, refreshRate); } void GLViewImpl::setFullscreen(int monitorIndex) @@ -664,15 +662,13 @@ void GLViewImpl::setFullscreen(int monitorIndex) } void GLViewImpl::setFullscreen(int monitorIndex, int w, int h, int refreshRate) { - if (this->isFullscreen()) - return; int count = 0; GLFWmonitor** monitors = glfwGetMonitors(&count); if (monitorIndex < 0 || monitorIndex >= count) { return; } GLFWmonitor* monitor = monitors[monitorIndex]; - if (nullptr == monitor) { + if (nullptr == monitor || _monitor == monitor) { return; } this->setFullscreen(monitor, w, h, refreshRate);