diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-01 01:01:20 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-01 01:01:20 +0200 |
commit | 4e40c54a3caabb6bced27e18e040ee88b739a3c8 (patch) | |
tree | bf33b7207326f516a119e72ca1c5e02e248206e0 /src/plugins/platforms/windows | |
parent | fbda189e081e6c7abf82334c0ac71b16ec2c37dd (diff) | |
parent | 9e59024bf80124dbf301e8b3dca3dc4548fee428 (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I77ba01f09b3dbcaf13cb265a70d9da661c32a61f
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsglcontext.cpp | 62 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsglcontext.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 12 |
3 files changed, 42 insertions, 35 deletions
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 64b83e2bc4..f2d31d5783 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -891,13 +891,6 @@ QWindowsOpenGLContextFormat QWindowsOpenGLContextFormat::current() result.profile = QSurfaceFormat::CoreProfile; else if (value & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) result.profile = QSurfaceFormat::CompatibilityProfile; - if (result.version < 0x0400) - return result; - // v4.0 onwards - value = 0; - QOpenGLStaticContext::opengl32.glGetIntegerv(RESET_NOTIFICATION_STRATEGY_ARB, &value); - if (value == LOSE_CONTEXT_ON_RESET_ARB) - result.options |= QSurfaceFormat::ResetNotification; return result; } @@ -975,6 +968,7 @@ QOpenGLTemporaryContext::~QOpenGLTemporaryContext() */ #define SAMPLE_BUFFER_EXTENSION "GL_ARB_multisample" +#define ROBUSTNESS_EXTENSION "GL_ARB_robustness" QOpenGLStaticContext::QOpenGLStaticContext() : vendor(QOpenGLStaticContext::getGlString(GL_VENDOR)), @@ -995,9 +989,31 @@ QOpenGLStaticContext::QOpenGLStaticContext() : wglGetExtensionsStringARB(reinterpret_cast<WglGetExtensionsStringARB>( reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.wglGetProcAddress("wglGetExtensionsStringARB")))) { - if (extensionNames.startsWith(SAMPLE_BUFFER_EXTENSION " ") - || extensionNames.indexOf(" " SAMPLE_BUFFER_EXTENSION " ") != -1) - extensions |= SampleBuffers; + if (defaultFormat.version < 0x0300) { + if (extensionNames.startsWith(SAMPLE_BUFFER_EXTENSION " ") + || extensionNames.indexOf(" " SAMPLE_BUFFER_EXTENSION " ") != -1) + extensions |= SampleBuffers; + if (extensionNames.startsWith(ROBUSTNESS_EXTENSION " ") + || extensionNames.indexOf(" " ROBUSTNESS_EXTENSION " ") != -1) + extensions |= Robustness; + } else { + typedef const GLubyte * (APIENTRY *glGetStringi_t)(GLenum, GLuint); + auto glGetStringi = reinterpret_cast<glGetStringi_t>( + reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.wglGetProcAddress("glGetStringi"))); + if (glGetStringi) { + GLint n = 0; + QOpenGLStaticContext::opengl32.glGetIntegerv(GL_NUM_EXTENSIONS, &n); + for (GLint i = 0; i < n; ++i) { + const char *p = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i)); + if (p) { + if (!strcmp(p, SAMPLE_BUFFER_EXTENSION)) + extensions |= SampleBuffers; + else if (!strcmp(p, ROBUSTNESS_EXTENSION)) + extensions |= Robustness; + } + } + } + } } QByteArray QOpenGLStaticContext::getGlString(unsigned int which) @@ -1236,27 +1252,11 @@ bool QWindowsGLContext::updateObtainedParams(HDC hdc, int *obtainedSwapInterval) if (m_staticContext->wglGetSwapInternalExt && obtainedSwapInterval) *obtainedSwapInterval = m_staticContext->wglGetSwapInternalExt(); - bool hasRobustness = false; - if (m_obtainedFormat.majorVersion() < 3) { - const char *exts = reinterpret_cast<const char *>(QOpenGLStaticContext::opengl32.glGetString(GL_EXTENSIONS)); - hasRobustness = exts && strstr(exts, "GL_ARB_robustness"); - } else { - typedef const GLubyte * (APIENTRY *glGetStringi_t)(GLenum, GLuint); - auto glGetStringi = reinterpret_cast<glGetStringi_t>( - reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.wglGetProcAddress("glGetStringi"))); - if (glGetStringi) { - GLint n = 0; - QOpenGLStaticContext::opengl32.glGetIntegerv(GL_NUM_EXTENSIONS, &n); - for (GLint i = 0; i < n; ++i) { - const char *p = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i)); - if (p && !strcmp(p, "GL_ARB_robustness")) { - hasRobustness = true; - break; - } - } - } - } - if (hasRobustness) { + if (testFlag(m_staticContext->extensions, QOpenGLStaticContext::Robustness)) { + GLint value = 0; + QOpenGLStaticContext::opengl32.glGetIntegerv(RESET_NOTIFICATION_STRATEGY_ARB, &value); + if (value == LOSE_CONTEXT_ON_RESET_ARB) + m_obtainedFormat.setOption(QSurfaceFormat::ResetNotification); m_getGraphicsResetStatus = reinterpret_cast<GlGetGraphicsResetStatusArbType>( reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.wglGetProcAddress("glGetGraphicsResetStatusARB"))); } diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h index e962af39c2..e5f6fefd5a 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.h +++ b/src/plugins/platforms/windows/qwindowsglcontext.h @@ -142,7 +142,8 @@ public: enum Extensions { SampleBuffers = 0x1, - sRGBCapableFramebuffer = 0x2 + sRGBCapableFramebuffer = 0x2, + Robustness = 0x4, }; typedef bool diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index ffc8f5ed21..a4f4099aa6 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2697,10 +2697,16 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re return true; } if (localPos.y() < 0) { - const int topResizeBarPos = -frameMargins().top(); - if (localPos.y() >= topResizeBarPos) + // We want to return HTCAPTION/true only over the outer sizing frame, not the entire title bar, + // otherwise the title bar buttons (close, etc.) become unresponsive on Windows 7 (QTBUG-78262). + // However, neither frameMargins() nor GetSystemMetrics(SM_CYSIZEFRAME), etc., give the correct + // sizing frame height in all Windows versions/scales. This empirical constant seems to work, though. + const int sizingHeight = 9; + const int topResizeBarPos = sizingHeight - frameMargins().top(); + if (localPos.y() < topResizeBarPos) { *result = HTCAPTION; // Extend caption over top resize bar, let's user move the window. - return true; + return true; + } } } if (fixedWidth && (localPos.x() < 0 || localPos.x() >= size.width())) { |