summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri3
-rw-r--r--src/gui/kernel/qapplication_qpa.cpp4
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.cpp54
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.h5
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h6
-rw-r--r--src/gui/kernel/qplatformwindowformat_qpa.cpp37
-rw-r--r--src/gui/kernel/qplatformwindowformat_qpa.h17
-rw-r--r--src/gui/kernel/qwidget.cpp2
-rw-r--r--src/gui/kernel/qwidget_qpa.cpp2
9 files changed, 110 insertions, 20 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 43b1ab8..9941b1b 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -241,7 +241,8 @@ qpa {
kernel/qplatformintegrationplugin_qpa.cpp \
kernel/qplatformwindow_qpa.cpp \
kernel/qplatformwindowformat_qpa.cpp \
- kernel/qplatformeventloopintegration_qpa.cpp
+ kernel/qplatformeventloopintegration_qpa.cpp \
+ kernel/qplatformglcontext_qpa.cpp
contains(QT_CONFIG, glib) {
SOURCES += \
diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp
index 26ae82d..e5b5396 100644
--- a/src/gui/kernel/qapplication_qpa.cpp
+++ b/src/gui/kernel/qapplication_qpa.cpp
@@ -510,7 +510,7 @@ void qt_init(QApplicationPrivate *priv, int type)
}
QList<QByteArray> pluginList;
- QString platformName = qgetenv("QT_QPA_PLATFORM");
+ QString platformName = QLatin1String(qgetenv("QT_QPA_PLATFORM"));
// Get command line params
@@ -526,7 +526,7 @@ void qt_init(QApplicationPrivate *priv, int type)
appFont = argv[i];
} else if (arg == "-platform") {
if (++i < argc)
- platformName = argv[i];
+ platformName = QLatin1String(argv[i]);
} else if (arg == "-plugin") {
if (++i < argc)
pluginList << argv[i];
diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp
new file mode 100644
index 0000000..a2ffbf3
--- /dev/null
+++ b/src/gui/kernel/qplatformglcontext_qpa.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformglcontext_qpa.h"
+
+static QPlatformGLContext *staticSharedContext = 0;
+
+void QPlatformGLContext::setDefaultSharedContext(QPlatformGLContext *sharedContext)
+{
+ staticSharedContext = sharedContext;
+}
+
+QPlatformGLContext *QPlatformGLContext::defaultSharedContext()
+{
+ return staticSharedContext;
+}
diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h
index dcfd54c..9f3bfb3 100644
--- a/src/gui/kernel/qplatformglcontext_qpa.h
+++ b/src/gui/kernel/qplatformglcontext_qpa.h
@@ -58,6 +58,11 @@ public:
virtual void swapBuffers() = 0;
virtual void* getProcAddress(const QString& procName) = 0;
+ static QPlatformGLContext *defaultSharedContext();
+
+protected:
+ static void setDefaultSharedContext(QPlatformGLContext *sharedContext);
+
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
index f6f10a8..9f7367e 100644
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -73,10 +73,12 @@ public:
virtual bool isVirtualDesktop() { return false; }
virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
-// Experimental
+// Experimental in mainthread eventloop integration
+// This should only be used if it is only possible to do window system event processing in
+// the gui thread. All of the functions in QWindowSystemInterface are thread safe.
virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const;
-// should it be hasGLContext?
+//jl:XXX should it be hasGLContext and do we need it at all?
virtual bool hasOpenGL() const;
diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp
index bc234ab..9d86948 100644
--- a/src/gui/kernel/qplatformwindowformat_qpa.cpp
+++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp
@@ -50,7 +50,8 @@ public:
: ref(1)
, opts(QPlatformWindowFormat::DoubleBuffer | QPlatformWindowFormat::DepthBuffer
| QPlatformWindowFormat::Rgba | QPlatformWindowFormat::DirectRendering
- | QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions)
+ | QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions
+ | QPlatformWindowFormat::UseDefaultSharedContext)
, depthSize(-1)
, accumSize(-1)
, stencilSize(-1)
@@ -60,9 +61,8 @@ public:
, alphaSize(-1)
, numSamples(-1)
, swapInterval(-1)
- , majorVersion(1)
- , minorVersion(0)
, windowApi(QPlatformWindowFormat::Raster)
+ , sharedContext(0)
{
}
@@ -78,9 +78,8 @@ public:
alphaSize(other->alphaSize),
numSamples(other->numSamples),
swapInterval(other->swapInterval),
- majorVersion(other->majorVersion),
- minorVersion(other->minorVersion),
- windowApi(other->windowApi)
+ windowApi(other->windowApi),
+ sharedContext(other->sharedContext)
{
}
QAtomicInt ref;
@@ -94,9 +93,8 @@ public:
int alphaSize;
int numSamples;
int swapInterval;
- int majorVersion;
- int minorVersion;
QPlatformWindowFormat::WindowApi windowApi;
+ QPlatformGLContext *sharedContext;
};
/*!
@@ -519,6 +517,16 @@ void QPlatformWindowFormat::setSampleBuffers(bool enable)
setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers);
}
+void QPlatformWindowFormat::setUseDefaultSharedContext(bool enable)
+{
+ if (enable) {
+ setOption(QPlatformWindowFormat::UseDefaultSharedContext);
+ d->sharedContext = 0;
+ } else {
+ setOption(QPlatformWindowFormat::NoDefaultSharedContext);
+ }
+}
+
/*!
Returns the number of samples per pixel when multisampling is
enabled. By default, the highest number of samples that is
@@ -595,6 +603,17 @@ QPlatformWindowFormat::WindowApi QPlatformWindowFormat::windowApi() const
return d->windowApi;
}
+void QPlatformWindowFormat::setSharedContext(QPlatformGLContext *context)
+{
+ setUseDefaultSharedContext(false);
+ d->sharedContext = context;
+}
+
+QPlatformGLContext *QPlatformWindowFormat::sharedGLContext() const
+{
+ return d->sharedContext;
+}
+
///*!
// \fn bool QGLFormat::hasOverlay() const
@@ -952,8 +971,6 @@ bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b)
&& a.d->blueSize == b.d->blueSize
&& a.d->numSamples == b.d->numSamples
&& a.d->swapInterval == b.d->swapInterval
- && a.d->majorVersion == b.d->majorVersion
- && a.d->minorVersion == b.d->minorVersion
&& a.d->windowApi == b.d->windowApi);
}
diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h
index 3c5f907..37e628d 100644
--- a/src/gui/kernel/qplatformwindowformat_qpa.h
+++ b/src/gui/kernel/qplatformwindowformat_qpa.h
@@ -64,6 +64,7 @@ public:
HasOverlay = 0x0100,
SampleBuffers = 0x0200,
DeprecatedFunctions = 0x0400,
+ UseDefaultSharedContext = 0x0800,
SingleBuffer = DoubleBuffer << 16,
NoDepthBuffer = DepthBuffer << 16,
ColorIndex = Rgba << 16,
@@ -74,7 +75,9 @@ public:
IndirectRendering = DirectRendering << 16,
NoOverlay = HasOverlay << 16,
NoSampleBuffers = SampleBuffers << 16,
- NoDeprecatedFunctions = DeprecatedFunctions << 16
+ NoDeprecatedFunctions = DeprecatedFunctions << 16,
+ NoDefaultSharedContext = UseDefaultSharedContext << 16
+
};
Q_DECLARE_FLAGS(FormatOptions, FormatOption)
@@ -123,6 +126,9 @@ public:
void setWindowApi(QPlatformWindowFormat::WindowApi api);
WindowApi windowApi() const;
+ void setSharedContext(QPlatformGLContext *context);
+ QPlatformGLContext *sharedGLContext() const;
+
bool doubleBuffer() const;
void setDoubleBuffer(bool enable);
bool depth() const;
@@ -139,6 +145,8 @@ public:
void setStereo(bool enable);
bool directRendering() const;
void setDirectRendering(bool enable);
+ bool useDefaultSharedContext() const;
+ void setUseDefaultSharedContext(bool enable);
// bool hasOverlay() const;
// void setOverlay(bool enable);
@@ -148,9 +156,6 @@ public:
static QPlatformWindowFormat defaultFormat();
static void setDefaultFormat(const QPlatformWindowFormat& f);
-// static QPlatformWindowFormat defaultOverlayFormat();
-// static void setDefaultOverlayFormat(const QPlatformWindowFormat& f);
-
private:
QPlatformWindowFormatPrivate *d;
@@ -215,6 +220,10 @@ inline bool QPlatformWindowFormat::sampleBuffers() const
return testOption(QPlatformWindowFormat::SampleBuffers);
}
+inline bool QPlatformWindowFormat::useDefaultSharedContext() const
+{
+ return testOption(QPlatformWindowFormat::UseDefaultSharedContext);
+}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 958c476..c236c60 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -2410,7 +2410,9 @@ WId QWidget::winId() const
qDebug() << "QWidget::winId: creating native window for" << this;
#endif
QWidget *that = const_cast<QWidget*>(this);
+#ifndef Q_WS_QPA
that->setAttribute(Qt::WA_NativeWindow);
+#endif
that->d_func()->createWinId();
return that->data->winid;
}
diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp
index 1b7d9d2..104c529 100644
--- a/src/gui/kernel/qwidget_qpa.cpp
+++ b/src/gui/kernel/qwidget_qpa.cpp
@@ -182,7 +182,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
// Reparenting toplevel to child
- if (!(f&Qt::Window) && (oldFlags&Qt::Window)) {
+ if (!(f&Qt::Window) && (oldFlags&Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
//qDebug() << "setParent_sys() change from toplevel";
q->destroy();
}