From 5d5e0a4e976622bc3db8b1f7f70041ff71e45085 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Sat, 29 Aug 2015 15:21:43 -0400 Subject: Avoid triggering OpenGL initialization for RasterSurface Application that do not require OpenGL need a way to opt-out of GLX/EGL calls completely. The initialization can be expensive and what is more, some systems may not have functional GLX at all (some VMs are known to crash when trying to get FBConfigs for the window). QApplication already has AA_ForceRasterWidgets, which causes the use of plain RasterSurface everywhere instead of RasterGLSurface. Combined with a trivial check in the xcb backend to skip all the Xlib+GLX/EGL path, the attribute will allow apps to ensure that no GLX/EGL calls are ever made. This however implies a change in QWindowContainer: the embedded window must use the same initialization path as the parent otherwise we will end up with a BadMatch. QWindowContainer can do this transparently to the applications, unless the QWindow is already created. Change-Id: I846af7edb8b92b9836cdbd93c6a5eec5a6147a49 Task-number: QTBUG-46765 Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qwindowcontainer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/widgets/kernel/qwindowcontainer.cpp') diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 9d3a4ef0b2..3885431b05 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -34,6 +34,8 @@ #include "qwindowcontainer_p.h" #include "qwidget_p.h" #include +#include +#include #include #include @@ -196,6 +198,13 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt: return; } + // The embedded QWindow must use the same logic as QWidget when it comes to the surface type. + // Otherwise we may end up with BadMatch failures on X11. + if (embeddedWindow->surfaceType() == QSurface::RasterSurface + && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface) + && !QApplication::testAttribute(Qt::AA_ForceRasterWidgets)) + embeddedWindow->setSurfaceType(QSurface::RasterGLSurface); + d->window = embeddedWindow; d->window->setParent(&d->fakeParent); setAcceptDrops(true); -- cgit v1.2.3