summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-03-20 13:46:57 +0100
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-03-20 13:49:28 +0100
commit76c0be34cd4ff4564693162fa7528463e23ce9d8 (patch)
treef165b7bc319548fb0082365411a871028f92e89e /src/gui/kernel
parent27b4fe96b59e9e63d1e570e802c072e9afdfb2d4 (diff)
parent36cb3f3f655a9090c82de609010cbfb88651a0f3 (diff)
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle Conflicts: src/gui/text/qfontdatabase.cpp src/gui/text/qharfbuzz_copy_p.h src/widgets/kernel/qapplication.cpp src/widgets/kernel/qcoreapplication.cpp Change-Id: I72fbf83ab3c2206aeea1b089428b0fc2a89bd62b
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri4
-rw-r--r--src/gui/kernel/qclipboard.cpp14
-rw-r--r--src/gui/kernel/qclipboard.h4
-rw-r--r--src/gui/kernel/qcursor.h6
-rw-r--r--src/gui/kernel/qdrag.h4
-rw-r--r--src/gui/kernel/qevent.h4
-rw-r--r--src/gui/kernel/qgenericplugin.h4
-rw-r--r--src/gui/kernel/qgenericpluginfactory.h4
-rw-r--r--src/gui/kernel/qguiapplication.cpp193
-rw-r--r--src/gui/kernel/qguiapplication.h4
-rw-r--r--src/gui/kernel/qguiapplication_p.h7
-rw-r--r--src/gui/kernel/qinputmethod.cpp27
-rw-r--r--src/gui/kernel/qinputmethod.h7
-rw-r--r--src/gui/kernel/qinputmethod_p.h5
-rw-r--r--src/gui/kernel/qkeysequence.cpp64
-rw-r--r--src/gui/kernel/qkeysequence.h10
-rw-r--r--src/gui/kernel/qoffscreensurface.cpp345
-rw-r--r--src/gui/kernel/qoffscreensurface.h98
-rw-r--r--src/gui/kernel/qopenglcontext.cpp275
-rw-r--r--src/gui/kernel/qopenglcontext.h67
-rw-r--r--src/gui/kernel/qopenglcontext_p.h7
-rw-r--r--src/gui/kernel/qpalette.h4
-rw-r--r--src/gui/kernel/qplatformclipboard.h4
-rw-r--r--src/gui/kernel/qplatformcursor.cpp4
-rw-r--r--src/gui/kernel/qplatformcursor.h4
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h4
-rw-r--r--src/gui/kernel/qplatformdrag.h4
-rw-r--r--src/gui/kernel/qplatforminputcontext.h4
-rw-r--r--src/gui/kernel/qplatforminputcontext_p.h4
-rw-r--r--src/gui/kernel/qplatforminputcontextfactory_p.h4
-rw-r--r--src/gui/kernel/qplatforminputcontextplugin_p.h4
-rw-r--r--src/gui/kernel/qplatformintegration.cpp22
-rw-r--r--src/gui/kernel/qplatformintegration.h12
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_p.h4
-rw-r--r--src/gui/kernel/qplatformintegrationplugin.h4
-rw-r--r--src/gui/kernel/qplatformmenu.h16
-rw-r--r--src/gui/kernel/qplatformnativeinterface.h4
-rw-r--r--src/gui/kernel/qplatformoffscreensurface.cpp93
-rw-r--r--src/gui/kernel/qplatformoffscreensurface.h85
-rw-r--r--src/gui/kernel/qplatformopenglcontext.h7
-rw-r--r--src/gui/kernel/qplatformscreen.h4
-rw-r--r--src/gui/kernel/qplatformscreen_p.h4
-rw-r--r--src/gui/kernel/qplatformscreenpageflipper.h4
-rw-r--r--src/gui/kernel/qplatformservices.h3
-rw-r--r--src/gui/kernel/qplatformsharedgraphicscache.h4
-rw-r--r--src/gui/kernel/qplatformsurface.h5
-rw-r--r--src/gui/kernel/qplatformtheme.cpp16
-rw-r--r--src/gui/kernel/qplatformtheme.h7
-rw-r--r--src/gui/kernel/qplatformthemefactory_p.h4
-rw-r--r--src/gui/kernel/qplatformthemeplugin.h4
-rw-r--r--src/gui/kernel/qplatformwindow.cpp16
-rw-r--r--src/gui/kernel/qplatformwindow.h3
-rw-r--r--src/gui/kernel/qplatformwindow_p.h4
-rw-r--r--src/gui/kernel/qscreen.h4
-rw-r--r--src/gui/kernel/qscreen_p.h4
-rw-r--r--src/gui/kernel/qsessionmanager.h4
-rw-r--r--src/gui/kernel/qshortcutmap.cpp2
-rw-r--r--src/gui/kernel/qstylehints.h4
-rw-r--r--src/gui/kernel/qsurface.cpp1
-rw-r--r--src/gui/kernel/qsurface.h7
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp24
-rw-r--r--src/gui/kernel/qsurfaceformat.h8
-rw-r--r--src/gui/kernel/qtouchdevice.h4
-rw-r--r--src/gui/kernel/qtouchdevice_p.h4
-rw-r--r--src/gui/kernel/qwindow.cpp257
-rw-r--r--src/gui/kernel/qwindow.h61
-rw-r--r--src/gui/kernel/qwindow_p.h12
-rw-r--r--src/gui/kernel/qwindowdefs.h4
-rw-r--r--src/gui/kernel/qwindowdefs_win.h4
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp57
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h15
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h46
72 files changed, 1649 insertions, 391 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index f766b5fbaf..eb87a8c31b 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -24,6 +24,7 @@ HEADERS += \
kernel/qplatformthemefactory_p.h \
kernel/qplatformthemeplugin.h \
kernel/qplatformwindow.h \
+ kernel/qplatformoffscreensurface.h \
kernel/qplatformwindow_p.h \
kernel/qplatformcursor.h \
kernel/qplatformclipboard.h \
@@ -34,6 +35,7 @@ HEADERS += \
kernel/qguiapplication_p.h \
kernel/qwindow_p.h \
kernel/qwindow.h \
+ kernel/qoffscreensurface.h \
kernel/qplatformsurface.h \
kernel/qsurface.h \
kernel/qclipboard.h \
@@ -81,6 +83,7 @@ SOURCES += \
kernel/qplatformthemefactory.cpp \
kernel/qplatformthemeplugin.cpp \
kernel/qplatformwindow.cpp \
+ kernel/qplatformoffscreensurface.cpp \
kernel/qplatformcursor.cpp \
kernel/qplatformclipboard.cpp \
kernel/qplatformnativeinterface.cpp \
@@ -88,6 +91,7 @@ SOURCES += \
kernel/qsurfaceformat.cpp \
kernel/qguiapplication.cpp \
kernel/qwindow.cpp \
+ kernel/qoffscreensurface.cpp \
kernel/qplatformsurface.cpp \
kernel/qsurface.cpp \
kernel/qclipboard.cpp \
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index 79da6471b8..f0b1f16ba2 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -226,7 +226,7 @@ QClipboard::~QClipboard()
the global clipboard.
\value Selection indicates that data should be stored and retrieved from
- the global mouse selection. Support for \c Selection is provided only on
+ the global mouse selection. Support for \c Selection is provided only on
systems with a global mouse selection (e.g. X11).
\value FindBuffer indicates that data should be stored and retrieved from
@@ -344,7 +344,7 @@ void QClipboard::setText(const QString &text, Mode mode)
clipboard is used. If \a mode is QClipboard::Clipboard, the
image is retrieved from the global clipboard. If \a mode is
QClipboard::Selection, the image is retrieved from the global
- mouse selection.
+ mouse selection.
\sa setImage(), pixmap(), mimeData(), QImage::isNull()
*/
@@ -459,7 +459,7 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode)
\sa mimeData()
*/
-/*!
+/*!
\fn void QClipboard::clear(Mode mode)
Clear the clipboard contents.
@@ -467,7 +467,7 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode)
clipboard is used. If \a mode is QClipboard::Clipboard, this
function clears the global clipboard contents. If \a mode is
QClipboard::Selection, this function clears the global mouse
- selection contents. If \a mode is QClipboard::FindBuffer, this
+ selection contents. If \a mode is QClipboard::FindBuffer, this
function clears the search string buffer.
\sa QClipboard::Mode, supportsSelection()
@@ -521,21 +521,21 @@ bool QClipboard::ownsFindBuffer() const
return ownsMode(FindBuffer);
}
-/*!
+/*!
\internal
\fn bool QClipboard::supportsMode(Mode mode) const;
Returns true if the clipboard supports the clipboard mode speacified by \a mode;
otherwise returns false.
*/
-/*!
+/*!
\internal
\fn bool QClipboard::ownsMode(Mode mode) const;
Returns true if the clipboard supports the clipboard data speacified by \a mode;
otherwise returns false.
*/
-/*!
+/*!
\internal
Emits the appropriate changed signal for \a mode.
*/
diff --git a/src/gui/kernel/qclipboard.h b/src/gui/kernel/qclipboard.h
index 520d731717..7235a03b6b 100644
--- a/src/gui/kernel/qclipboard.h
+++ b/src/gui/kernel/qclipboard.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -112,6 +110,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QCLIPBOARD_H
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index d4ca15ff93..0bf4cc7bf9 100644
--- a/src/gui/kernel/qcursor.h
+++ b/src/gui/kernel/qcursor.h
@@ -45,8 +45,6 @@
#include <QtCore/qpoint.h>
#include <QtGui/qwindowdefs.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -109,7 +107,7 @@ public:
static void setPos(QScreen *screen, int x, int y);
inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
inline static void setPos(QScreen *screen, const QPoint &p) { setPos(screen, p.x(), p.y()); }
-
+
private:
QCursorData *d;
};
@@ -130,6 +128,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QCursor &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QCURSOR_H
diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h
index abbb382400..553b0e1922 100644
--- a/src/gui/kernel/qdrag.h
+++ b/src/gui/kernel/qdrag.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -100,6 +98,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QDRAG_H
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index e84765cae6..0b4e708bdb 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -58,8 +58,6 @@
#include <QtGui/qvector2d.h>
#include <QtGui/qtouchdevice.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -909,6 +907,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QEVENT_H
diff --git a/src/gui/kernel/qgenericplugin.h b/src/gui/kernel/qgenericplugin.h
index 10bde146bd..f00a532283 100644
--- a/src/gui/kernel/qgenericplugin.h
+++ b/src/gui/kernel/qgenericplugin.h
@@ -45,8 +45,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -68,6 +66,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QGENERICPLUGIN_H
diff --git a/src/gui/kernel/qgenericpluginfactory.h b/src/gui/kernel/qgenericpluginfactory.h
index 03d688a5c5..2443e670cc 100644
--- a/src/gui/kernel/qgenericpluginfactory.h
+++ b/src/gui/kernel/qgenericpluginfactory.h
@@ -44,8 +44,6 @@
#include <QtCore/qstringlist.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -61,6 +59,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QGENERICPLUGINFACTORY_H
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index d42da6ee79..a1c9af45b8 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -111,6 +111,8 @@ bool QGuiApplicationPrivate::tabletState = false;
QWindow *QGuiApplicationPrivate::tabletPressTarget = 0;
QWindow *QGuiApplicationPrivate::currentMouseWindow = 0;
+Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive;
+
QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0;
QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0;
@@ -664,7 +666,7 @@ QWindowList QGuiApplication::topLevelWindows()
const QWindowList &list = QGuiApplicationPrivate::window_list;
QWindowList topLevelWindows;
for (int i = 0; i < list.size(); i++) {
- if (!list.at(i)->parent()) {
+ if (!list.at(i)->parent() && list.at(i)->type() != Qt::Desktop) {
// Top windows of embedded QAxServers do not have QWindow parents,
// but they are not true top level windows, so do not include them.
const bool embedded = list.at(i)->handle() && list.at(i)->handle()->isEmbedded(0);
@@ -1065,6 +1067,8 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
delete platform_integration;
platform_integration = 0;
delete m_gammaTables.load();
+
+ window_list.clear();
}
#if 0
@@ -1274,6 +1278,12 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
case QWindowSystemInterfacePrivate::WindowStateChanged:
QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e));
break;
+ case QWindowSystemInterfacePrivate::ApplicationStateChanged:
+ QGuiApplicationPrivate::processApplicationStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::FlushEvents:
+ QWindowSystemInterface::deferredFlushWindowSystemEvents();
+ break;
case QWindowSystemInterfacePrivate::Close:
QGuiApplicationPrivate::processCloseEvent(
static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
@@ -1499,10 +1509,20 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
{
QWindow *window = e->window.data();
modifier_buttons = e->modifiers;
- if (e->nullWindow)
+ if (e->nullWindow
+#ifdef Q_OS_ANDROID
+ || (e->keyType == QEvent::KeyRelease && e->key == Qt::Key_Back) || e->key == Qt::Key_Menu
+#endif
+ ) {
window = QGuiApplication::focusWindow();
- if (!window)
+ }
+ if (!window
+#ifdef Q_OS_ANDROID
+ && e->keyType != QEvent::KeyRelease && e->key != Qt::Key_Back
+#endif
+ ) {
return;
+ }
if (window->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow key events through
return;
@@ -1512,7 +1532,19 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers,
e->unicode, e->repeat, e->repeatCount);
ev.setTimestamp(e->timestamp);
- QGuiApplication::sendSpontaneousEvent(window, &ev);
+
+#ifdef Q_OS_ANDROID
+ if (e->keyType == QEvent::KeyRelease && e->key == Qt::Key_Back) {
+ if (!window) {
+ qApp->quit();
+ } else {
+ QGuiApplication::sendEvent(window, &ev);
+ if (!ev.isAccepted() && e->key == Qt::Key_Back)
+ QWindowSystemInterface::handleCloseEvent(window);
+ }
+ } else
+#endif
+ QGuiApplication::sendSpontaneousEvent(window, &ev);
}
void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
@@ -1565,21 +1597,21 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
return;
if (previous) {
- QFocusEvent focusOut(QEvent::FocusOut);
+ QFocusEvent focusOut(QEvent::FocusOut, e->reason);
QCoreApplication::sendSpontaneousEvent(previous, &focusOut);
QObject::disconnect(previous, SIGNAL(focusObjectChanged(QObject*)),
qApp, SLOT(_q_updateFocusObject(QObject*)));
- } else {
+ } else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) {
QEvent appActivate(QEvent::ApplicationActivate);
qApp->sendSpontaneousEvent(qApp, &appActivate);
}
if (QGuiApplicationPrivate::focus_window) {
- QFocusEvent focusIn(QEvent::FocusIn);
+ QFocusEvent focusIn(QEvent::FocusIn, e->reason);
QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn);
QObject::connect(QGuiApplicationPrivate::focus_window, SIGNAL(focusObjectChanged(QObject*)),
qApp, SLOT(_q_updateFocusObject(QObject*)));
- } else {
+ } else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) {
QEvent appActivate(QEvent::ApplicationDeactivate);
qApp->sendSpontaneousEvent(qApp, &appActivate);
}
@@ -1603,6 +1635,26 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa
}
}
+void QGuiApplicationPrivate::processApplicationStateChangedEvent(QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e)
+{
+ if (e->newState == applicationState)
+ return;
+ applicationState = e->newState;
+
+ switch (e->newState) {
+ case Qt::ApplicationActive: {
+ QEvent appActivate(QEvent::ApplicationActivate);
+ qApp->sendSpontaneousEvent(qApp, &appActivate);
+ break; }
+ case Qt::ApplicationInactive: {
+ QEvent appDeactivate(QEvent::ApplicationDeactivate);
+ qApp->sendSpontaneousEvent(qApp, &appDeactivate);
+ break; }
+ default:
+ break;
+ }
+}
+
void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce)
{
if (self)
@@ -1669,10 +1721,10 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl
void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e)
{
- if (e->fileName.isEmpty())
+ if (e->url.isEmpty())
return;
- QFileOpenEvent event(e->fileName);
+ QFileOpenEvent event(e->url);
QGuiApplication::sendSpontaneousEvent(qApp, &event);
}
@@ -2626,6 +2678,13 @@ static inline void applyCursor(QWindow *w, QCursor c)
cursor->changeCursor(&c, w);
}
+static inline void unsetCursor(QWindow *w)
+{
+ if (const QScreen *screen = w->screen())
+ if (QPlatformCursor *cursor = screen->handle()->cursor())
+ cursor->changeCursor(0, w);
+}
+
static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c)
{
for (int i = 0; i < l.size(); ++i) {
@@ -2639,8 +2698,13 @@ static inline void applyWindowCursor(const QList<QWindow *> &l)
{
for (int i = 0; i < l.size(); ++i) {
QWindow *w = l.at(i);
- if (w->handle() && w->type() != Qt::Desktop)
- applyCursor(w, w->cursor());
+ if (w->handle() && w->type() != Qt::Desktop) {
+ if (qt_window_private(w)->hasCursor) {
+ applyCursor(w, w->cursor());
+ } else {
+ unsetCursor(w);
+ }
+ }
}
}
@@ -2772,111 +2836,6 @@ QInputMethod *QGuiApplication::inputMethod()
QFontDatabase::removeApplicationFont()
*/
-// These pixmaps approximate the images in the Windows User Interface Guidelines.
-
-// XPM
-
-static const char * const move_xpm[] = {
-"11 20 3 1",
-". c None",
-"a c #FFFFFF",
-"X c #000000", // X11 cursor is traditionally black
-"aa.........",
-"aXa........",
-"aXXa.......",
-"aXXXa......",
-"aXXXXa.....",
-"aXXXXXa....",
-"aXXXXXXa...",
-"aXXXXXXXa..",
-"aXXXXXXXXa.",
-"aXXXXXXXXXa",
-"aXXXXXXaaaa",
-"aXXXaXXa...",
-"aXXaaXXa...",
-"aXa..aXXa..",
-"aa...aXXa..",
-"a.....aXXa.",
-"......aXXa.",
-".......aXXa",
-".......aXXa",
-"........aa."};
-
-
-/* XPM */
-static const char * const copy_xpm[] = {
-"24 30 3 1",
-". c None",
-"a c #000000",
-"X c #FFFFFF",
-"XX......................",
-"XaX.....................",
-"XaaX....................",
-"XaaaX...................",
-"XaaaaX..................",
-"XaaaaaX.................",
-"XaaaaaaX................",
-"XaaaaaaaX...............",
-"XaaaaaaaaX..............",
-"XaaaaaaaaaX.............",
-"XaaaaaaXXXX.............",
-"XaaaXaaX................",
-"XaaXXaaX................",
-"XaX..XaaX...............",
-"XX...XaaX...............",
-"X.....XaaX..............",
-"......XaaX..............",
-".......XaaX.............",
-".......XaaX.............",
-"........XX...aaaaaaaaaaa",
-".............aXXXXXXXXXa",
-".............aXXXXXXXXXa",
-".............aXXXXaXXXXa",
-".............aXXXXaXXXXa",
-".............aXXaaaaaXXa",
-".............aXXXXaXXXXa",
-".............aXXXXaXXXXa",
-".............aXXXXXXXXXa",
-".............aXXXXXXXXXa",
-".............aaaaaaaaaaa"};
-
-/* XPM */
-static const char * const link_xpm[] = {
-"24 30 3 1",
-". c None",
-"a c #000000",
-"X c #FFFFFF",
-"XX......................",
-"XaX.....................",
-"XaaX....................",
-"XaaaX...................",
-"XaaaaX..................",
-"XaaaaaX.................",
-"XaaaaaaX................",
-"XaaaaaaaX...............",
-"XaaaaaaaaX..............",
-"XaaaaaaaaaX.............",
-"XaaaaaaXXXX.............",
-"XaaaXaaX................",
-"XaaXXaaX................",
-"XaX..XaaX...............",
-"XX...XaaX...............",
-"X.....XaaX..............",
-"......XaaX..............",
-".......XaaX.............",
-".......XaaX.............",
-"........XX...aaaaaaaaaaa",
-".............aXXXXXXXXXa",
-".............aXXXaaaaXXa",
-".............aXXXXaaaXXa",
-".............aXXXaaaaXXa",
-".............aXXaaaXaXXa",
-".............aXXaaXXXXXa",
-".............aXXaXXXXXXa",
-".............aXXXaXXXXXa",
-".............aXXXXXXXXXa",
-".............aaaaaaaaaaa"};
-
QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
{
Q_UNUSED(cshape);
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index f90321f396..0e9d6f2336 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -49,8 +49,6 @@
#include <QtCore/qpoint.h>
#include <QtCore/qsize.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -187,6 +185,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QGUIAPPLICATION_H
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 0946591887..13b5952e73 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -65,8 +65,6 @@
#include "private/qshortcutmap_p.h"
#include <qicon.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformIntegration;
@@ -129,6 +127,8 @@ public:
static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
+ static void processApplicationStateChangedEvent(QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e);
+
static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
static void updateFilteredScreenOrientation(QScreen *screen);
@@ -201,6 +201,7 @@ public:
static bool tabletState;
static QWindow *tabletPressTarget;
static QWindow *currentMouseWindow;
+ static Qt::ApplicationState applicationState;
#ifndef QT_NO_CLIPBOARD
static QClipboard *qt_clipboard;
@@ -293,6 +294,4 @@ Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QGUIAPPLICATION_P_H
diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp
index 436b0aed1e..438c169f71 100644
--- a/src/gui/kernel/qinputmethod.cpp
+++ b/src/gui/kernel/qinputmethod.cpp
@@ -99,6 +99,33 @@ void QInputMethod::setInputItemTransform(const QTransform &transform)
emit cursorRectangleChanged();
}
+
+/*!
+ \since 5.1
+
+ Returns the input item's geometry in input item coordinates.
+
+ \sa setInputItemRectangle()
+*/
+QRectF QInputMethod::inputItemRectangle() const
+{
+ Q_D(const QInputMethod);
+ return d->inputRectangle;
+}
+
+/*!
+ \since 5.1
+
+ Sets the input item's geometry to be \a rect, in input item coordinates.
+ This needs to be updated by the focused window like QQuickCanvas whenever
+ item is moved inside the scene, or focus is changed.
+*/
+void QInputMethod::setInputItemRectangle(const QRectF &rect)
+{
+ Q_D(QInputMethod);
+ d->inputRectangle = rect;
+}
+
/*!
\property QInputMethod::cursorRectangle
\brief Input item's cursor rectangle in window coordinates.
diff --git a/src/gui/kernel/qinputmethod.h b/src/gui/kernel/qinputmethod.h
index 35e29e9cb5..fe6cc3f331 100644
--- a/src/gui/kernel/qinputmethod.h
+++ b/src/gui/kernel/qinputmethod.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QInputMethodPrivate;
@@ -69,6 +67,9 @@ public:
QTransform inputItemTransform() const;
void setInputItemTransform(const QTransform &transform);
+ QRectF inputItemRectangle() const;
+ void setInputItemRectangle(const QRectF &rect);
+
// in window coordinates
QRectF cursorRectangle() const; // ### what if we have rotations for the item?
@@ -116,6 +117,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qinputmethod_p.h b/src/gui/kernel/qinputmethod_p.h
index ab91660e3f..79b1299722 100644
--- a/src/gui/kernel/qinputmethod_p.h
+++ b/src/gui/kernel/qinputmethod_p.h
@@ -61,8 +61,6 @@
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QInputMethodPrivate : public QObjectPrivate
@@ -86,11 +84,10 @@ public:
bool objectAcceptsInputMethod(QObject *object);
QTransform inputItemTransform;
+ QRectF inputRectangle;
QPlatformInputContext *testContext;
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 07ec658818..44de8c5847 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -257,6 +257,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
\row \li FindPrevious \li Shift+F3, Ctrl+Shift+G \li Ctrl+Shift+G \li Shift+F3 \li Ctrl+Shift+G, Shift+F3
\row \li Replace \li Ctrl+H \li (none) \li Ctrl+R \li Ctrl+H
\row \li SelectAll \li Ctrl+A \li Ctrl+A \li Ctrl+A \li Ctrl+A
+ \row \li Deselect \li \li \li Ctrl+Shift+A \li Ctrl+Shift+A
\row \li Bold \li Ctrl+B \li Ctrl+B \li Ctrl+B \li Ctrl+B
\row \li Italic \li Ctrl+I \li Ctrl+I \li Ctrl+I \li Ctrl+I
\row \li Underline \li Ctrl+U \li Ctrl+U \li Ctrl+U \li Ctrl+U
@@ -753,6 +754,7 @@ const QKeyBinding QKeySequencePrivate::keyBindings[] = {
{QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, KB_Mac},
{QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, KB_Win},
{QKeySequence::FullScreen, 1, Qt::CTRL | Qt::Key_F11, KB_Gnome},
+ {QKeySequence::Deselect, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_A, KB_X11},
{QKeySequence::FullScreen, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F, KB_KDE},
{QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Gnome | KB_Mac},
{QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Win},
@@ -866,6 +868,7 @@ const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate
\value SaveAs Save document after prompting the user for a file name.
\value Save Save document.
\value SelectAll Select all text.
+ \value Deselect Deselect text. Since 5.1
\value SelectEndOfBlock Extend selection to the end of a text block. This shortcut is only used on OS X.
\value SelectEndOfDocument Extend selection to end of document.
\value SelectEndOfLine Extend selection to end of line.
@@ -878,7 +881,7 @@ const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate
\value SelectPreviousPage Extend selection to previous page.
\value SelectPreviousWord Extend selection to previous word.
\value SelectStartOfBlock Extend selection to the start of a text block. This shortcut is only used on OS X.
- \value SelectStartOfDocument Extend selection to start of document.
+ \value SelectStartOfDocument Extend selection to start of document.
\value SelectStartOfLine Extend selection to start of line.
\value Underline Underline text.
\value Undo Undo.
@@ -892,10 +895,10 @@ const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate
/*!
\since 4.2
- Constructs a QKeySequence object for the given \a key.
- The result will depend on the currently running platform.
+ Constructs a QKeySequence object for the given \a key.
+ The result will depend on the currently running platform.
- The resulting object will be based on the first element in the
+ The resulting object will be based on the first element in the
list of key bindings for the \a key.
*/
QKeySequence::QKeySequence(StandardKey key)
@@ -903,7 +906,7 @@ QKeySequence::QKeySequence(StandardKey key)
const QList <QKeySequence> bindings = keyBindings(key);
//pick only the first/primary shortcut from current bindings
if (bindings.size() > 0) {
- d = bindings.first().d;
+ d = bindings.first().d;
d->ref.ref();
}
else
@@ -991,8 +994,8 @@ static inline int maybeSwapShortcut(int shortcut)
\since 4.2
Returns a list of key bindings for the given \a key.
- The result of calling this function will vary based on the target platform.
- The first element of the list indicates the primary shortcut for the given platform.
+ The result of calling this function will vary based on the target platform.
+ The first element of the list indicates the primary shortcut for the given platform.
If the result contains more than one result, these can
be considered alternative shortcuts on the same platform for the given \a key.
*/
@@ -1509,9 +1512,9 @@ QKeySequence::SequenceMatch QKeySequence::matches(const QKeySequence &seq) const
\obsolete
- Use toString() instead.
-
- Returns the key sequence as a QString. This is equivalent to
+ Use toString() instead.
+
+ Returns the key sequence as a QString. This is equivalent to
calling toString(QKeySequence::NativeText). Note that the
result is not platform independent.
*/
@@ -1681,6 +1684,47 @@ QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format)
return QKeySequence(str, format);
}
+/*!
+ \since 5.1
+
+ Return a list of QKeySequence from the string \a str based on \a format.
+
+ \sa fromString()
+ \sa listToString()
+*/
+QList<QKeySequence> QKeySequence::listFromString(const QString &str, SequenceFormat format)
+{
+ QList<QKeySequence> result;
+
+ QStringList strings = str.split(QLatin1String("; "));
+ foreach (const QString &string, strings) {
+ result << fromString(string, format);
+ }
+
+ return result;
+}
+
+/*!
+ \since 5.1
+
+ Return a string representation of \a list based on \a format.
+
+ \sa toString()
+ \sa listFromString()
+*/
+QString QKeySequence::listToString(const QList<QKeySequence> &list, SequenceFormat format)
+{
+ QString result;
+
+ foreach (const QKeySequence &sequence, list) {
+ result += sequence.toString(format);
+ result += QLatin1String("; ");
+ }
+ result.truncate(result.length() - 2);
+
+ return result;
+}
+
/*****************************************************************************
QKeySequence stream functions
*****************************************************************************/
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index dd26efda8e..05460c6651 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -45,8 +45,6 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -138,7 +136,8 @@ public:
SaveAs,
Preferences,
Quit,
- FullScreen
+ FullScreen,
+ Deselect
};
enum SequenceFormat {
@@ -165,6 +164,9 @@ public:
QString toString(SequenceFormat format = PortableText) const;
static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText);
+ static QList<QKeySequence> listFromString(const QString &str, SequenceFormat format = PortableText);
+ static QString listToString(const QList<QKeySequence> &list, SequenceFormat format = PortableText);
+
SequenceMatch matches(const QKeySequence &seq) const;
static QKeySequence mnemonic(const QString &text);
static QList<QKeySequence> keyBindings(StandardKey key);
@@ -231,6 +233,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QKEYSEQUENCE_H
diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp
new file mode 100644
index 0000000000..e2306050dd
--- /dev/null
+++ b/src/gui/kernel/qoffscreensurface.cpp
@@ -0,0 +1,345 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qoffscreensurface.h"
+
+#include "qguiapplication_p.h"
+#include "qscreen.h"
+#include "qplatformintegration.h"
+#include "qplatformoffscreensurface.h"
+#include "qwindow.h"
+#include "qplatformwindow.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QOffscreenSurface
+ \inmodule QtGui
+ \since 5.1
+ \brief The QOffscreenSurface class represents an offscreen surface in the underlying platform.
+
+ QOffscreenSurface is intended to be used with QOpenGLContext to allow rendering with OpenGL in
+ an arbitrary thread without the need to create a QWindow.
+
+ Even though the surface is renderable, the surface's pixels are not accessible.
+ QOffscreenSurface should only be used to create OpenGL resources such as textures
+ or framebuffer objects.
+
+ An application will typically use QOffscreenSurface to perform some time-consuming tasks in a
+ separate thread in order to avoid stalling the main rendering thread. Resources created in the
+ QOffscreenSurface's context can be shared with the main OpenGL context. Some common use cases
+ are asynchronous texture uploads or rendering into a QOpenGLFramebufferObject.
+
+ How the offscreen surface is implemented depends on the underlying platform, but it will
+ typically use a pixel buffer (pbuffer). If the platform doesn't implement or support
+ offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally.
+*/
+class Q_GUI_EXPORT QOffscreenSurfacePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QOffscreenSurface)
+
+public:
+ QOffscreenSurfacePrivate()
+ : QObjectPrivate()
+ , surfaceType(QSurface::OpenGLSurface)
+ , platformOffscreenSurface(0)
+ , offscreenWindow(0)
+ , screen(0)
+ , size(1, 1)
+ {
+ }
+
+ ~QOffscreenSurfacePrivate()
+ {
+ }
+
+ QSurface::SurfaceType surfaceType;
+ QPlatformOffscreenSurface *platformOffscreenSurface;
+ QWindow *offscreenWindow;
+ QSurfaceFormat requestedFormat;
+ QScreen *screen;
+ QSize size;
+};
+
+
+/*!
+ Creates an offscreen surface for the \a targetScreen.
+
+ The underlying platform surface is not created until create() is called.
+
+ \sa setScreen(), create()
+*/
+QOffscreenSurface::QOffscreenSurface(QScreen *targetScreen)
+ : QObject(*new QOffscreenSurfacePrivate(), 0)
+ , QSurface(Offscreen)
+{
+ Q_D(QOffscreenSurface);
+ d->screen = targetScreen;
+ if (!d->screen)
+ d->screen = QGuiApplication::primaryScreen();
+
+ //if your applications aborts here, then chances are your creating a QOffscreenSurface before
+ //the screen list is populated.
+ Q_ASSERT(d->screen);
+
+ connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
+}
+
+
+/*!
+ Destroys the offscreen surface.
+*/
+QOffscreenSurface::~QOffscreenSurface()
+{
+ destroy();
+}
+
+/*!
+ Returns the surface type of the offscreen surface.
+
+ The surface type of an offscreen surface is always QSurface::OpenGLSurface.
+*/
+QOffscreenSurface::SurfaceType QOffscreenSurface::surfaceType() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->surfaceType;
+}
+
+/*!
+ Allocates the platform resources associated with the offscreen surface.
+
+ It is at this point that the surface format set using setFormat() gets resolved
+ into an actual native surface.
+
+ Call destroy() to free the platform resources if necessary.
+
+ \sa destroy()
+*/
+void QOffscreenSurface::create()
+{
+ Q_D(QOffscreenSurface);
+ if (!d->platformOffscreenSurface && !d->offscreenWindow) {
+ d->platformOffscreenSurface = QGuiApplicationPrivate::platformIntegration()->createPlatformOffscreenSurface(this);
+ // No platform offscreen surface, fallback to an invisible window
+ if (!d->platformOffscreenSurface) {
+ d->offscreenWindow = new QWindow(d->screen);
+ d->offscreenWindow->setSurfaceType(QWindow::OpenGLSurface);
+ d->offscreenWindow->setFormat(d->requestedFormat);
+ d->offscreenWindow->setGeometry(0, 0, d->size.width(), d->size.height());
+ d->offscreenWindow->create();
+ }
+ }
+}
+
+/*!
+ Releases the native platform resources associated with this offscreen surface.
+
+ \sa create()
+*/
+void QOffscreenSurface::destroy()
+{
+ Q_D(QOffscreenSurface);
+ delete d->platformOffscreenSurface;
+ d->platformOffscreenSurface = 0;
+ if (d->offscreenWindow) {
+ d->offscreenWindow->destroy();
+ delete d->offscreenWindow;
+ d->offscreenWindow = 0;
+ }
+}
+
+/*!
+ Returns \c true if this offscreen surface is valid; otherwise returns \c false.
+
+ The offscreen surface is valid if the platform resources have been successfuly allocated.
+
+ \sa create()
+*/
+bool QOffscreenSurface::isValid() const
+{
+ Q_D(const QOffscreenSurface);
+ return (d->platformOffscreenSurface && d->platformOffscreenSurface->isValid())
+ || (d->offscreenWindow && d->offscreenWindow->handle());
+}
+
+/*!
+ Sets the offscreen surface \a format.
+
+ The surface format will be resolved in the create() function. Calling
+ this function after create() will not re-resolve the surface format of the native surface.
+
+ \sa create(), destroy()
+*/
+void QOffscreenSurface::setFormat(const QSurfaceFormat &format)
+{
+ Q_D(QOffscreenSurface);
+ d->requestedFormat = format;
+}
+
+/*!
+ Returns the requested surfaceformat of this offscreen surface.
+
+ If the requested format was not supported by the platform implementation,
+ the requestedFormat will differ from the actual offscreen surface format.
+
+ This is the value set with setFormat().
+
+ \sa setFormat(), format()
+ */
+QSurfaceFormat QOffscreenSurface::requestedFormat() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->requestedFormat;
+}
+
+/*!
+ Returns the actual format of this offscreen surface.
+
+ After the offscreen surface has been created, this function will return the actual
+ surface format of the surface. It might differ from the requested format if the requested
+ format could not be fulfilled by the platform.
+
+ \sa create(), requestedFormat()
+*/
+QSurfaceFormat QOffscreenSurface::format() const
+{
+ Q_D(const QOffscreenSurface);
+ if (d->platformOffscreenSurface)
+ return d->platformOffscreenSurface->format();
+ if (d->offscreenWindow)
+ return d->offscreenWindow->format();
+ return d->requestedFormat;
+}
+
+/*!
+ Returns the size of the offscreen surface.
+*/
+QSize QOffscreenSurface::size() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->size;
+}
+
+/*!
+ Returns the screen to which the offscreen surface is connected.
+
+ \sa setScreen()
+*/
+QScreen *QOffscreenSurface::screen() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->screen;
+}
+
+/*!
+ Sets the screen to which the offscreen surface is connected.
+
+ If the offscreen surface has been created, it will be recreated on the \a newScreen.
+
+ \sa screen()
+*/
+void QOffscreenSurface::setScreen(QScreen *newScreen)
+{
+ Q_D(QOffscreenSurface);
+ if (!newScreen)
+ newScreen = QGuiApplication::primaryScreen();
+ if (newScreen != d->screen) {
+ const bool wasCreated = d->platformOffscreenSurface != 0 || d->offscreenWindow != 0;
+ if (wasCreated)
+ destroy();
+ if (d->screen)
+ disconnect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
+ d->screen = newScreen;
+ if (newScreen) {
+ connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
+ if (wasCreated)
+ create();
+ }
+ emit screenChanged(newScreen);
+ }
+}
+
+/*!
+ Called when the offscreen surface's screen is destroyed.
+
+ \internal
+*/
+void QOffscreenSurface::screenDestroyed(QObject *object)
+{
+ Q_D(QOffscreenSurface);
+ if (object == static_cast<QObject *>(d->screen))
+ setScreen(0);
+}
+
+/*!
+ \fn QOffscreenSurface::screenChanged(QScreen *screen)
+
+ This signal is emitted when an offscreen surface's \a screen changes, either
+ by being set explicitly with setScreen(), or automatically when
+ the window's screen is removed.
+*/
+
+/*!
+ Returns the platform offscreen surface corresponding to the offscreen surface.
+
+ \internal
+*/
+QPlatformOffscreenSurface *QOffscreenSurface::handle() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->platformOffscreenSurface;
+}
+
+/*!
+ Returns the platform surface corresponding to the offscreen surface.
+
+ \internal
+*/
+QPlatformSurface *QOffscreenSurface::surfaceHandle() const
+{
+ Q_D(const QOffscreenSurface);
+ if (d->offscreenWindow)
+ return d->offscreenWindow->handle();
+
+ return d->platformOffscreenSurface;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qoffscreensurface.h b/src/gui/kernel/qoffscreensurface.h
new file mode 100644
index 0000000000..a1b46f9b88
--- /dev/null
+++ b/src/gui/kernel/qoffscreensurface.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOFFSCREENSURFACE_H
+#define QOFFSCREENSURFACE_H
+
+#include <QtCore/QObject>
+#include <QtGui/qsurface.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOffscreenSurfacePrivate;
+
+class QScreen;
+class QPlatformOffscreenSurface;
+
+class Q_GUI_EXPORT QOffscreenSurface : public QObject, public QSurface
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QOffscreenSurface)
+
+public:
+
+ explicit QOffscreenSurface(QScreen *screen = 0);
+ virtual ~QOffscreenSurface();
+
+ SurfaceType surfaceType() const;
+
+ void create();
+ void destroy();
+
+ bool isValid() const;
+
+ void setFormat(const QSurfaceFormat &format);
+ QSurfaceFormat format() const;
+ QSurfaceFormat requestedFormat() const;
+
+ QSize size() const;
+
+ QScreen *screen() const;
+ void setScreen(QScreen *screen);
+
+ QPlatformOffscreenSurface *handle() const;
+
+Q_SIGNALS:
+ void screenChanged(QScreen *screen);
+
+private Q_SLOTS:
+ void screenDestroyed(QObject *screen);
+
+private:
+
+ QPlatformSurface *surfaceHandle() const;
+
+ Q_DISABLE_COPY(QOffscreenSurface)
+};
+
+QT_END_NAMESPACE
+
+#endif // QOFFSCREENSURFACE_H
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 645c13a2ea..483baf0f09 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -54,11 +54,163 @@
#include <QtGui/QScreen>
#include <private/qopenglextensions_p.h>
+#include <private/qopenglversionfunctionsfactory_p.h>
#include <QDebug>
QT_BEGIN_NAMESPACE
+class QOpenGLVersionProfilePrivate
+{
+public:
+ QOpenGLVersionProfilePrivate()
+ : majorVersion(0),
+ minorVersion(0),
+ profile(QSurfaceFormat::NoProfile)
+ {}
+
+ int majorVersion;
+ int minorVersion;
+ QSurfaceFormat::OpenGLContextProfile profile;
+};
+
+
+/*!
+ \class QOpenGLVersionProfile
+ \inmodule QtGui
+ \since 5.1
+ \brief The QOpenGLVersionProfile class represents the version and if applicable
+ the profile of an OpenGL context.
+
+ An object of this class can be passed to QOpenGLContext::versionFunctions() to
+ request a functions object for a specific version and profile of OpenGL.
+
+ It also contains some helper functions to check if a version supports profiles
+ or is a legacy version.
+*/
+
+/*!
+ Creates a default invalid QOpenGLVersionProfile object.
+*/
+QOpenGLVersionProfile::QOpenGLVersionProfile()
+ : d(new QOpenGLVersionProfilePrivate)
+{
+}
+
+/*!
+ Creates a QOpenGLVersionProfile object initialised with the version and profile
+ from \a format.
+*/
+QOpenGLVersionProfile::QOpenGLVersionProfile(const QSurfaceFormat &format)
+ : d(new QOpenGLVersionProfilePrivate)
+{
+ d->majorVersion = format.majorVersion();
+ d->minorVersion = format.minorVersion();
+ d->profile = format.profile();
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QOpenGLVersionProfile::QOpenGLVersionProfile(const QOpenGLVersionProfile &other)
+ : d(new QOpenGLVersionProfilePrivate)
+{
+ *d = *(other.d);
+}
+
+/*!
+ Destroys the QOpenGLVersionProfile object.
+*/
+QOpenGLVersionProfile::~QOpenGLVersionProfile()
+{
+ delete d;
+}
+
+/*!
+ Assigns the version and profile of \a rhs to this QOpenGLVersionProfile object.
+*/
+QOpenGLVersionProfile &QOpenGLVersionProfile::operator=(const QOpenGLVersionProfile &rhs)
+{
+ if (this == &rhs)
+ return *this;
+ *d = *(rhs.d);
+ return *this;
+}
+
+/*!
+ Returns a QPair<int,int> where the components represent the major and minor OpenGL
+ version numbers respectively.
+
+ \sa setVersion()
+*/
+QPair<int, int> QOpenGLVersionProfile::version() const
+{
+ return qMakePair( d->majorVersion, d->minorVersion);
+}
+
+/*!
+ Sets the major and minor version numbers to \a majorVersion and \a minorVersion respectively.
+
+ \sa version()
+*/
+void QOpenGLVersionProfile::setVersion(int majorVersion, int minorVersion)
+{
+ d->majorVersion = majorVersion;
+ d->minorVersion = minorVersion;
+}
+
+/*!
+ Returns the OpenGL profile. Only make sense if profiles are supported by this version.
+
+ \sa setProfile(), supportsProfiles()
+*/
+QSurfaceFormat::OpenGLContextProfile QOpenGLVersionProfile::profile() const
+{
+ return d->profile;
+}
+
+/*!
+ Sets the profile. Only make sense if profiles are supported by this version.
+
+ \sa profile(), supportsProfiles()
+*/
+void QOpenGLVersionProfile::setProfile(QSurfaceFormat::OpenGLContextProfile profile)
+{
+ d->profile = profile;
+}
+
+/*!
+ Returns true if profiles are supported by the OpenGL version returned by version(). Only
+ OpenGL versions >= 3.2 support profiles.
+
+ \sa profile(), version()
+*/
+bool QOpenGLVersionProfile::hasProfiles() const
+{
+ return ( d->majorVersion > 3
+ || (d->majorVersion == 3 && d->minorVersion > 1));
+}
+
+/*!
+ Returns true is the OpenGL version returned by version() contains deprecated functions
+ and does not support profiles i.e. if the OpenGL version is <= 3.1.
+*/
+bool QOpenGLVersionProfile::isLegacyVersion() const
+{
+ return (d->majorVersion < 3 || (d->majorVersion == 3 && d->minorVersion == 0));
+}
+
+/*!
+ Returns true if the version number is valid. Note that for a default constructed
+ QOpenGLVersionProfile object this function will return false.
+
+ \sa setVersion(), version()
+*/
+bool QOpenGLVersionProfile::isValid() const
+{
+ return d->majorVersion > 0 && d->minorVersion >= 0;
+}
+
class QGuiGLThreadContext
{
public:
@@ -367,6 +519,10 @@ void QOpenGLContext::destroy()
d->platformGLContext = 0;
delete d->functions;
d->functions = 0;
+ qDeleteAll(d->versionFunctions);
+ d->versionFunctions.clear();
+ qDeleteAll(d->versionFunctionsBackend);
+ d->versionFunctionsBackend.clear();
}
/*!
@@ -425,6 +581,97 @@ QOpenGLFunctions *QOpenGLContext::functions() const
}
/*!
+ \fn T *QOpenGLContext::versionFunctions() const
+
+ Returns a pointer to an object that provides access to all functions for
+ the version and profile of this context. Before using any of the functions
+ they must be initialized by calling QAbstractOpenGLFunctions::initializeOpenGLFunctions().
+
+ Usually one would use the template version of this function to automatically
+ have the result cast to the correct type.
+
+ \code
+ QOpenGLFunctions_3_3_Core* funcs = 0;
+ funcs = context->versionFunctions<QOpenGLFunctions_3_3_Core>();
+ if (!funcs) {
+ qWarning() << "Could not obtain required OpenGL context version";
+ exit(1);
+ }
+ funcs->initializeOpenGLFunctions(context);
+ \endcode
+
+ It is possible to request a functions object for a different version and profile
+ than that for which the context was created. To do this either use the template
+ version of this function specifying the desired functions object type as the
+ template parameter or by passing in a QOpenGLVersionProfile object as an argument
+ to the non-template function.
+
+ Note that requests for function objects of other versions or profiles can fail and
+ in doing so will return a null pointer. Situations in which creation of the functions
+ object can fail are if the request cannot be satisfied due to asking for functions
+ that are not in the version or profile of this context. For example:
+
+ \list
+ \li Requesting a 3.3 core profile functions object would succeed.
+ \li Requesting a 3.3 compatibility profile functions object would fail. We would fail
+ to resolve the deprecated functions.
+ \li Requesting a 4.3 core profile functions object would fail. We would fail to resolve
+ the new core functions introduced in versions 4.0-4.3.
+ \li Requesting a 3.1 functions object would succeed. There is nothing in 3.1 that is not
+ also in 3.3 core.
+ \endlist
+
+ Note that if creating a functions object via this method that the QOpenGLContext
+ retains ownership of the object. This is to allow the object to be cached and shared.
+*/
+
+/*!
+ Returns a pointer to an object that provides access to all functions for
+ the version of the current context. Before using any of the functions
+ they must be initialized by calling QAbstractOpenGLFunctions::initializeOpenGLFunctions().
+
+ Usually one would use the template version of this function to automatically
+ have the result cast to the correct type.
+
+ \sa T *QOpenGLContext::versionFunctions()
+*/
+QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionProfile &versionProfile) const
+{
+ Q_D(const QOpenGLContext);
+ const QSurfaceFormat f = format();
+
+ // Ensure we have a valid version and profile. Default to context's if none specified
+ QOpenGLVersionProfile vp = versionProfile;
+ if (!vp.isValid())
+ vp = QOpenGLVersionProfile(f);
+
+ // Check that context is compatible with requested version
+ const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
+ if (v < vp.version())
+ return 0;
+
+ // If this context only offers core profile functions then we can't create
+ // function objects for legacy or compatibility profile requests
+ if (((vp.hasProfiles() && vp.profile() != QSurfaceFormat::CoreProfile) || vp.isLegacyVersion())
+ && f.profile() == QSurfaceFormat::CoreProfile)
+ return 0;
+
+ // Create object if suitable one not cached
+ QAbstractOpenGLFunctions* funcs = 0;
+ if (!d->versionFunctions.contains(vp)) {
+ funcs = QOpenGLVersionFunctionsFactory::create(vp);
+ if (funcs) {
+ funcs->setOwningContext(this);
+ d->versionFunctions.insert(vp, funcs);
+ }
+ } else {
+ funcs = d->versionFunctions.value(vp);
+ }
+
+ return funcs;
+}
+
+/*!
Returns the set of OpenGL extensions supported by this context.
The context or a sharing context must be current.
@@ -702,6 +949,34 @@ void QOpenGLContext::deleteQGLContext()
}
/*!
+ \internal
+*/
+QOpenGLVersionFunctionsBackend *QOpenGLContext::functionsBackend(const QOpenGLVersionStatus &v) const
+{
+ Q_D(const QOpenGLContext);
+ return d->versionFunctionsBackend.value(v, 0);
+}
+
+/*!
+ \internal
+*/
+void QOpenGLContext::insertFunctionsBackend(const QOpenGLVersionStatus &v,
+ QOpenGLVersionFunctionsBackend *backend)
+{
+ Q_D(QOpenGLContext);
+ d->versionFunctionsBackend.insert(v, backend);
+}
+
+/*!
+ \internal
+*/
+void QOpenGLContext::removeFunctionsBackend(const QOpenGLVersionStatus &v)
+{
+ Q_D(QOpenGLContext);
+ d->versionFunctionsBackend.remove(v);
+}
+
+/*!
\class QOpenGLContextGroup
\since 5.0
\brief The QOpenGLContextGroup class represents a group of contexts sharing
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index d6d812a98d..419fd541eb 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -42,6 +42,8 @@
#ifndef QOPENGLCONTEXT_H
#define QOPENGLCONTEXT_H
+#include <QtCore/qglobal.h>
+
#ifndef QT_NO_OPENGL
#include <QtCore/qnamespace.h>
@@ -58,8 +60,10 @@
#endif
#include <QtGui/qopengl.h>
+#include <QtGui/qopenglversionfunctions.h>
-QT_BEGIN_HEADER
+#include <QtCore/qhash.h>
+#include <QtCore/qpair.h>
QT_BEGIN_NAMESPACE
@@ -71,6 +75,50 @@ class QPlatformOpenGLContext;
class QScreen;
class QSurface;
+class QOpenGLVersionProfilePrivate;
+
+class Q_GUI_EXPORT QOpenGLVersionProfile
+{
+public:
+ QOpenGLVersionProfile();
+ explicit QOpenGLVersionProfile(const QSurfaceFormat &format);
+ QOpenGLVersionProfile(const QOpenGLVersionProfile &other);
+ ~QOpenGLVersionProfile();
+
+ QOpenGLVersionProfile &operator=(const QOpenGLVersionProfile &rhs);
+
+ QPair<int, int> version() const;
+ void setVersion(int majorVersion, int minorVersion);
+
+ QSurfaceFormat::OpenGLContextProfile profile() const;
+ void setProfile(QSurfaceFormat::OpenGLContextProfile profile);
+
+ bool hasProfiles() const;
+ bool isLegacyVersion() const;
+ bool isValid() const;
+
+private:
+ QOpenGLVersionProfilePrivate* d;
+};
+
+inline uint qHash(const QOpenGLVersionProfile &v, uint seed)
+{
+ return qHash(static_cast<int>(v.profile() * 1000)
+ + v.version().first * 100 + v.version().second * 10, seed);
+}
+
+inline bool operator==(const QOpenGLVersionProfile &lhs, const QOpenGLVersionProfile &rhs)
+{
+ if (lhs.profile() != rhs.profile())
+ return false;
+ return lhs.version() == rhs.version();
+}
+
+inline bool operator!=(const QOpenGLVersionProfile &lhs, const QOpenGLVersionProfile &rhs)
+{
+ return !operator==(lhs, rhs);
+}
+
class Q_GUI_EXPORT QOpenGLContextGroup : public QObject
{
Q_OBJECT
@@ -129,6 +177,15 @@ public:
QOpenGLFunctions *functions() const;
+ QAbstractOpenGLFunctions *versionFunctions(const QOpenGLVersionProfile &versionProfile = QOpenGLVersionProfile()) const;
+
+ template<class TYPE>
+ TYPE *versionFunctions() const
+ {
+ QOpenGLVersionProfile v = TYPE::versionProfile();
+ return static_cast<TYPE*>(versionFunctions(v));
+ }
+
QSet<QByteArray> extensions() const;
bool hasExtension(const QByteArray &extension) const;
@@ -149,18 +206,22 @@ private:
friend class QOpenGL2PaintEngineExPrivate;
friend class QSGDistanceFieldGlyphCache;
friend class QWidgetPrivate;
+ friend class QAbstractOpenGLFunctionsPrivate;
void *qGLContextHandle() const;
void setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *));
void deleteQGLContext();
+ QOpenGLVersionFunctionsBackend* functionsBackend(const QOpenGLVersionStatus &v) const;
+ void insertFunctionsBackend(const QOpenGLVersionStatus &v,
+ QOpenGLVersionFunctionsBackend *backend);
+ void removeFunctionsBackend(const QOpenGLVersionStatus &v);
+
void destroy();
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif // QGUIGLCONTEXT_H
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index fb81412b2b..8a36df3e7c 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -64,8 +64,6 @@
#include <QtCore/QHash>
#include <QtCore/QSet>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -215,6 +213,9 @@ public:
//QWidgetPrivate::deleteTLSysExtra()
}
+ mutable QHash<QOpenGLVersionProfile, QAbstractOpenGLFunctions *> versionFunctions;
+ mutable QHash<QOpenGLVersionStatus, QOpenGLVersionFunctionsBackend *> versionFunctionsBackend;
+
void *qGLContextHandle;
void (*qGLContextDeleteFunction)(void *handle);
@@ -259,7 +260,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif // QOPENGLCONTEXT_P_H
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
index 9ea0830442..2248f6727e 100644
--- a/src/gui/kernel/qpalette.h
+++ b/src/gui/kernel/qpalette.h
@@ -46,8 +46,6 @@
#include <QtGui/qcolor.h>
#include <QtGui/qbrush.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -210,6 +208,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QPalette &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPALETTE_H
diff --git a/src/gui/kernel/qplatformclipboard.h b/src/gui/kernel/qplatformclipboard.h
index a925b16e9e..3ffc020e8d 100644
--- a/src/gui/kernel/qplatformclipboard.h
+++ b/src/gui/kernel/qplatformclipboard.h
@@ -57,8 +57,6 @@
#include <QtGui/QClipboard>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -76,8 +74,6 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_CLIPBOARD
#endif //QPLATFORMCLIPBOARD_H
diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp
index 16a59f5d07..c2f510b496 100644
--- a/src/gui/kernel/qplatformcursor.cpp
+++ b/src/gui/kernel/qplatformcursor.cpp
@@ -95,6 +95,10 @@ QList<QPlatformCursor *> QPlatformCursorPrivate::getInstances()
\a windowCursor is a pointer to the QCursor that should be displayed.
+ To unset the cursor of \a window, 0 is passed. This means \a window does not have
+ a cursor set and the cursor of a the first parent window which has a cursor explicitly
+ set or the system default cursor should take effect.
+
\a window is a pointer to the window currently displayed at QCursor::pos(). Note
that this may be 0 if the current position is not occupied by a displayed widget.
diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h
index d624a068f1..011209aa3a 100644
--- a/src/gui/kernel/qplatformcursor.h
+++ b/src/gui/kernel/qplatformcursor.h
@@ -58,8 +58,6 @@
#include <qpa/qplatformscreen.h>
#include <QtGui/QCursor>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -106,6 +104,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMCURSOR_H
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index fe3c5d2b99..ecc00ed8c6 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -59,8 +59,6 @@
#include <QtCore/QDir>
#include <QtGui/QRgb>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -319,6 +317,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMDIALOGHELPER_H
diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h
index 61ff2dddf6..59f9899f23 100644
--- a/src/gui/kernel/qplatformdrag.h
+++ b/src/gui/kernel/qplatformdrag.h
@@ -54,8 +54,6 @@
#include <QtCore/qglobal.h>
#include <QtGui/QPixmap>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DRAGANDDROP
@@ -118,6 +116,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qplatforminputcontext.h b/src/gui/kernel/qplatforminputcontext.h
index 2efe9486ca..0e4121eed4 100644
--- a/src/gui/kernel/qplatforminputcontext.h
+++ b/src/gui/kernel/qplatforminputcontext.h
@@ -53,8 +53,6 @@
#include <QtGui/qinputmethod.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformInputContextPrivate;
@@ -102,6 +100,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINPUTCONTEXT_H
diff --git a/src/gui/kernel/qplatforminputcontext_p.h b/src/gui/kernel/qplatforminputcontext_p.h
index f55acbd79f..29d6e45269 100644
--- a/src/gui/kernel/qplatforminputcontext_p.h
+++ b/src/gui/kernel/qplatforminputcontext_p.h
@@ -55,8 +55,6 @@
#include <private/qobject_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformInputContextPrivate: public QObjectPrivate
@@ -73,6 +71,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qplatforminputcontextfactory_p.h b/src/gui/kernel/qplatforminputcontextfactory_p.h
index 2e82f7c4d5..2177d7965d 100644
--- a/src/gui/kernel/qplatforminputcontextfactory_p.h
+++ b/src/gui/kernel/qplatforminputcontextfactory_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qstringlist.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -72,7 +70,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINPUTCONTEXTFACTORY_H
diff --git a/src/gui/kernel/qplatforminputcontextplugin_p.h b/src/gui/kernel/qplatforminputcontextplugin_p.h
index ac97df15a3..ff79bb94b9 100644
--- a/src/gui/kernel/qplatforminputcontextplugin_p.h
+++ b/src/gui/kernel/qplatforminputcontextplugin_p.h
@@ -56,8 +56,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -77,6 +75,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINPUTCONTEXTPLUGIN_H
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 980e45742e..70de75072c 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -199,6 +199,17 @@ QPlatformServices *QPlatformIntegration::services() const
\value MultipleWindows The platform supports multiple QWindows, i.e. does some kind
of compositing either client or server side. Some platforms might only support a
single fullscreen window.
+
+ \value ApplicationState The platform handles the application state explicitly.
+ This means that QEvent::ApplicationActivate and QEvent::ApplicationDeativate
+ will not be posted automatically. Instead, the platform must handle application
+ state explicitly by using QWindowSystemInterface::handleApplicationStateChanged().
+ If not set, application state will follow window activation, which is the normal
+ behavior for desktop platforms.
+
+ \value ForeignWindows The platform allows creating QWindows which represent
+ native windows created by other processes or anyway created by using native
+ libraries.
*/
@@ -360,4 +371,15 @@ class QPlatformTheme *QPlatformIntegration::createPlatformTheme(const QString &n
return new QPlatformTheme;
}
+/*!
+ Factory function for QOffscreenSurface. An offscreen surface will typically be implemented with a
+ pixel buffer (pbuffer). If the platform doesn't support offscreen surfaces, an invisible window
+ will be used by QOffscreenSurface instead.
+*/
+QPlatformOffscreenSurface *QPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
+{
+ Q_UNUSED(surface)
+ return 0;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index ee796bf323..ddee6f05c8 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -55,8 +55,6 @@
#include <qpa/qplatformscreen.h>
#include <QtGui/qsurfaceformat.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -77,6 +75,8 @@ class QPlatformDialogHelper;
class QPlatformSharedGraphicsCache;
class QPlatformServices;
class QKeyEvent;
+class QPlatformOffscreenSurface;
+class QOffscreenSurface;
class Q_GUI_EXPORT QPlatformIntegration
{
@@ -88,7 +88,9 @@ public:
SharedGraphicsCache,
BufferQueueingOpenGL,
WindowMasks,
- MultipleWindows
+ MultipleWindows,
+ ApplicationState,
+ ForeignWindows
};
virtual ~QPlatformIntegration() { }
@@ -148,12 +150,12 @@ public:
virtual QStringList themeNames() const;
virtual QPlatformTheme *createPlatformTheme(const QString &name) const;
+ virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
+
protected:
void screenAdded(QPlatformScreen *screen);
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINTEGRATION_H
diff --git a/src/gui/kernel/qplatformintegrationfactory_p.h b/src/gui/kernel/qplatformintegrationfactory_p.h
index 859e6f9c4d..fb3ba55316 100644
--- a/src/gui/kernel/qplatformintegrationfactory_p.h
+++ b/src/gui/kernel/qplatformintegrationfactory_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qstringlist.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -71,7 +69,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINTEGRATIONFACTORY_H
diff --git a/src/gui/kernel/qplatformintegrationplugin.h b/src/gui/kernel/qplatformintegrationplugin.h
index 4de0d3edc0..434366f0b0 100644
--- a/src/gui/kernel/qplatformintegrationplugin.h
+++ b/src/gui/kernel/qplatformintegrationplugin.h
@@ -54,8 +54,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -75,6 +73,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINTEGRATIONPLUGIN_H
diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h
index b02998940b..3485cc58dd 100644
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -57,8 +57,6 @@
#include <QtGui/QKeySequence>
#include <QtGui/QIcon>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformMenu;
@@ -80,6 +78,7 @@ public:
virtual void setIsSeparator(bool isSeparator) = 0;
virtual void setFont(const QFont &font) = 0;
virtual void setRole(MenuRole role) = 0;
+ virtual void setCheckable(bool checkable) = 0;
virtual void setChecked(bool isChecked) = 0;
virtual void setShortcut(const QKeySequence& shortcut) = 0;
virtual void setEnabled(bool enabled) = 0;
@@ -101,8 +100,19 @@ public:
virtual quintptr tag()const = 0;
virtual void setText(const QString &text) = 0;
+ virtual void setIcon(const QIcon &icon) = 0;
virtual void setEnabled(bool enabled) = 0;
virtual void setVisible(bool visible) = 0;
+ virtual void setMinimumWidth(int width) { Q_UNUSED(width); }
+ virtual void setFont(const QFont &font) { Q_UNUSED(font); }
+
+ virtual void showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item)
+ {
+ Q_UNUSED(parentWindow);
+ Q_UNUSED(pos);
+ Q_UNUSED(item);
+ setVisible(true);
+ }
virtual QPlatformMenuItem *menuItemAt(int position) const = 0;
virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const = 0;
@@ -125,7 +135,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qplatformnativeinterface.h b/src/gui/kernel/qplatformnativeinterface.h
index fd892c1e75..eaa24a9e55 100644
--- a/src/gui/kernel/qplatformnativeinterface.h
+++ b/src/gui/kernel/qplatformnativeinterface.h
@@ -55,8 +55,6 @@
#include <QtCore/QObject>
#include <QtCore/QVariant>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -98,6 +96,4 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMNATIVEINTERFACE_H
diff --git a/src/gui/kernel/qplatformoffscreensurface.cpp b/src/gui/kernel/qplatformoffscreensurface.cpp
new file mode 100644
index 0000000000..dd354f465e
--- /dev/null
+++ b/src/gui/kernel/qplatformoffscreensurface.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformoffscreensurface.h"
+
+#include "qoffscreensurface.h"
+#include "qscreen.h"
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformOffscreenSurfacePrivate
+{
+public:
+};
+
+QPlatformOffscreenSurface::QPlatformOffscreenSurface(QOffscreenSurface *offscreenSurface)
+ : QPlatformSurface(offscreenSurface)
+ , d_ptr(new QPlatformOffscreenSurfacePrivate)
+{
+}
+
+QPlatformOffscreenSurface::~QPlatformOffscreenSurface()
+{
+}
+
+QOffscreenSurface *QPlatformOffscreenSurface::offscreenSurface() const
+{
+ return static_cast<QOffscreenSurface*>(m_surface);
+}
+
+/*!
+ Returns the platform screen handle corresponding to this QPlatformOffscreenSurface.
+*/
+QPlatformScreen *QPlatformOffscreenSurface::screen() const
+{
+ return offscreenSurface()->screen()->handle();
+}
+
+/*!
+ Returns the actual surface format of the offscreen surface.
+*/
+QSurfaceFormat QPlatformOffscreenSurface::format() const
+{
+ return QSurfaceFormat();
+}
+
+/*!
+ Returns \c true if the platform offscreen surface has been allocated.
+*/
+bool QPlatformOffscreenSurface::isValid() const
+{
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformoffscreensurface.h b/src/gui/kernel/qplatformoffscreensurface.h
new file mode 100644
index 0000000000..099d8ee94a
--- /dev/null
+++ b/src/gui/kernel/qplatformoffscreensurface.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMOFFSCREENSURFACE_H
+#define QPLATFORMOFFSCREENSURFACE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the QPA API and is not meant to be used
+// in applications. Usage of this API may make your code
+// source and binary incompatible with future versions of Qt.
+//
+
+#include "qplatformsurface.h"
+#include <QtCore/qscopedpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOffscreenSurface;
+class QPlatformScreen;
+class QPlatformOffscreenSurfacePrivate;
+
+class Q_GUI_EXPORT QPlatformOffscreenSurface : public QPlatformSurface
+{
+ Q_DECLARE_PRIVATE(QPlatformOffscreenSurface)
+public:
+ explicit QPlatformOffscreenSurface(QOffscreenSurface *offscreenSurface);
+ virtual ~QPlatformOffscreenSurface();
+
+ QOffscreenSurface *offscreenSurface() const;
+
+ QPlatformScreen *screen() const;
+
+ virtual QSurfaceFormat format() const;
+ virtual bool isValid() const;
+
+protected:
+ QScopedPointer<QPlatformOffscreenSurfacePrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QPlatformOffscreenSurface)
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLATFORMOFFSCREENSURFACE_H
diff --git a/src/gui/kernel/qplatformopenglcontext.h b/src/gui/kernel/qplatformopenglcontext.h
index 6a0c819752..42e4db2f9d 100644
--- a/src/gui/kernel/qplatformopenglcontext.h
+++ b/src/gui/kernel/qplatformopenglcontext.h
@@ -51,15 +51,14 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtCore/qnamespace.h>
+
#ifndef QT_NO_OPENGL
-#include <QtCore/qnamespace.h>
#include <QtGui/qsurfaceformat.h>
#include <QtGui/qwindow.h>
#include <QtGui/qopengl.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -102,8 +101,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif // QPLATFORMOPENGLCONTEXT_H
diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h
index eae9c5a739..085a147e8d 100644
--- a/src/gui/kernel/qplatformscreen.h
+++ b/src/gui/kernel/qplatformscreen.h
@@ -63,8 +63,6 @@
#include <QtGui/qwindowdefs.h>
#include <qpa/qplatformpixmap.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -133,6 +131,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMSCREEN_H
diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h
index 6914a82a06..588496b494 100644
--- a/src/gui/kernel/qplatformscreen_p.h
+++ b/src/gui/kernel/qplatformscreen_p.h
@@ -53,8 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QScreen;
@@ -67,6 +65,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMSCREEN_P_H
diff --git a/src/gui/kernel/qplatformscreenpageflipper.h b/src/gui/kernel/qplatformscreenpageflipper.h
index c6eac28564..232e37d24a 100644
--- a/src/gui/kernel/qplatformscreenpageflipper.h
+++ b/src/gui/kernel/qplatformscreenpageflipper.h
@@ -53,8 +53,6 @@
#include <QtCore/QObject>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QPlatformScreenBuffer {
@@ -91,6 +89,4 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMSCREENPAGEFLIPPER_H
diff --git a/src/gui/kernel/qplatformservices.h b/src/gui/kernel/qplatformservices.h
index 200298f2ba..609a4a04be 100644
--- a/src/gui/kernel/qplatformservices.h
+++ b/src/gui/kernel/qplatformservices.h
@@ -53,8 +53,6 @@
#include <QtCore/QtGlobal>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QUrl;
@@ -71,6 +69,5 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QPLATFORMSERVICES_H
diff --git a/src/gui/kernel/qplatformsharedgraphicscache.h b/src/gui/kernel/qplatformsharedgraphicscache.h
index 20a551688f..bb2dfe00e5 100644
--- a/src/gui/kernel/qplatformsharedgraphicscache.h
+++ b/src/gui/kernel/qplatformsharedgraphicscache.h
@@ -54,8 +54,6 @@
#include <QtCore/qobject.h>
#include <QtGui/qimage.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QPlatformSharedGraphicsCache: public QObject
@@ -103,6 +101,4 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMSHAREDGRAPHICSCACHE_H
diff --git a/src/gui/kernel/qplatformsurface.h b/src/gui/kernel/qplatformsurface.h
index bffb3c5848..b96e494f74 100644
--- a/src/gui/kernel/qplatformsurface.h
+++ b/src/gui/kernel/qplatformsurface.h
@@ -55,8 +55,6 @@
#include <QtGui/qsurface.h>
#include <QtGui/qsurfaceformat.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -74,10 +72,9 @@ private:
QSurface *m_surface;
friend class QPlatformWindow;
+ friend class QPlatformOffscreenSurface;
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif //QPLATFORMSURFACE_H
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index ceb95c51e8..9f5c789a6e 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -46,6 +46,7 @@
#include <QtCore/qfileinfo.h>
#include <qpalette.h>
#include <qtextformat.h>
+#include <qiconloader_p.h>
QT_BEGIN_NAMESPACE
@@ -272,4 +273,19 @@ QPlatformSystemTrayIcon *QPlatformTheme::createPlatformSystemTrayIcon() const
}
#endif
+/*!
+ Factory function for the QIconEngine used by QIcon::fromTheme(). By default this
+ function returns a QIconLoaderEngine, but subclasses can reimplement it to
+ provide their own.
+
+ It is especially useful to benefit from some platform specific facilities or
+ optimizations like an inter-process cache in systems mostly built with Qt.
+
+ \since 5.1
+*/
+QIconEngine *QPlatformTheme::createIconEngine(const QString &iconName) const
+{
+ return new QIconLoaderEngine(iconName);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
index 3ac2b904d2..0e95321102 100644
--- a/src/gui/kernel/qplatformtheme.h
+++ b/src/gui/kernel/qplatformtheme.h
@@ -53,10 +53,9 @@
#include <QtCore/QtGlobal>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
+class QIconEngine;
class QMenu;
class QMenuBar;
class QPlatformMenuItem;
@@ -272,11 +271,11 @@ public:
virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const;
virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const;
+ virtual QIconEngine *createIconEngine(const QString &iconName) const;
+
static QVariant defaultThemeHint(ThemeHint hint);
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMTHEME_H
diff --git a/src/gui/kernel/qplatformthemefactory_p.h b/src/gui/kernel/qplatformthemefactory_p.h
index 632aae86ee..ad954f39b6 100644
--- a/src/gui/kernel/qplatformthemefactory_p.h
+++ b/src/gui/kernel/qplatformthemefactory_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qstringlist.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -71,6 +69,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMTHEMEFACTORY_H
diff --git a/src/gui/kernel/qplatformthemeplugin.h b/src/gui/kernel/qplatformthemeplugin.h
index e3f106753a..cef5fb77b4 100644
--- a/src/gui/kernel/qplatformthemeplugin.h
+++ b/src/gui/kernel/qplatformthemeplugin.h
@@ -54,8 +54,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformTheme;
@@ -74,6 +72,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMTHEMEPLUGIN_H
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index 79e4cbf674..bfb6ab5a68 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -199,7 +199,13 @@ bool QPlatformWindow::isEmbedded(const QPlatformWindow *parentWindow) const
*/
QPoint QPlatformWindow::mapToGlobal(const QPoint &pos) const
{
- return pos;
+ const QPlatformWindow *p = this;
+ QPoint result = pos;
+ while (p) {
+ result += p->geometry().topLeft();
+ p = p->parent();
+ }
+ return result;
}
/*!
@@ -211,7 +217,13 @@ QPoint QPlatformWindow::mapToGlobal(const QPoint &pos) const
*/
QPoint QPlatformWindow::mapFromGlobal(const QPoint &pos) const
{
- return pos;
+ const QPlatformWindow *p = this;
+ QPoint result = pos;
+ while (p) {
+ result -= p->geometry().topLeft();
+ p = p->parent();
+ }
+ return result;
}
/*!
diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h
index 410e7ea9bb..7ade461890 100644
--- a/src/gui/kernel/qplatformwindow.h
+++ b/src/gui/kernel/qplatformwindow.h
@@ -59,8 +59,6 @@
#include <qpa/qplatformopenglcontext.h>
#include <qpa/qplatformsurface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -143,5 +141,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
#endif //QPLATFORMWINDOW_H
diff --git a/src/gui/kernel/qplatformwindow_p.h b/src/gui/kernel/qplatformwindow_p.h
index 24e18ca379..ac47afb6f1 100644
--- a/src/gui/kernel/qplatformwindow_p.h
+++ b/src/gui/kernel/qplatformwindow_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qrect.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformWindowPrivate
@@ -67,6 +65,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMWINDOW_P_H
diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h
index 557cd019a3..9fe4379646 100644
--- a/src/gui/kernel/qscreen.h
+++ b/src/gui/kernel/qscreen.h
@@ -52,8 +52,6 @@
#include <QtCore/qnamespace.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -160,7 +158,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSCREEN_H
diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h
index 7b26159c20..3e5feb2932 100644
--- a/src/gui/kernel/qscreen_p.h
+++ b/src/gui/kernel/qscreen_p.h
@@ -58,8 +58,6 @@
#include <QtCore/private/qobject_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QScreenPrivate : public QObjectPrivate
@@ -98,6 +96,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSCREEN_P_H
diff --git a/src/gui/kernel/qsessionmanager.h b/src/gui/kernel/qsessionmanager.h
index 4eac11e403..a1cd8741d2 100644
--- a/src/gui/kernel/qsessionmanager.h
+++ b/src/gui/kernel/qsessionmanager.h
@@ -49,8 +49,6 @@
#ifndef QT_NO_SESSIONMANAGER
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -101,8 +99,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_SESSIONMANAGER
#endif // QSESSIONMANAGER_H
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index 489242464b..cd822090e2 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -317,7 +317,7 @@ QKeySequence::SequenceMatch QShortcutMap::state()
/*! \internal
Uses ShortcutOverride event to see if any widgets want to override
the event. If not, uses nextState(QKeyEvent) to check for a grabbed
- Shortcut, and dispatchEvent() is found an identical.
+ Shortcut, and dispatchEvent() is found and identical.
\sa nextState, dispatchEvent
*/
bool QShortcutMap::tryShortcutEvent(QObject *o, QKeyEvent *e)
diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h
index c9c8185b9a..7a447aae67 100644
--- a/src/gui/kernel/qstylehints.h
+++ b/src/gui/kernel/qstylehints.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -74,6 +72,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp
index 97b8220124..a943639d5f 100644
--- a/src/gui/kernel/qsurface.cpp
+++ b/src/gui/kernel/qsurface.cpp
@@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE
The SurfaceClass enum describes the actual subclass of the surface.
\value Window The surface is an instance of QWindow.
+ \value Offscreen The surface is an instance of QOffscreenSurface.
*/
diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h
index 36d85342c5..8dbc230c10 100644
--- a/src/gui/kernel/qsurface.h
+++ b/src/gui/kernel/qsurface.h
@@ -47,8 +47,6 @@
#include <QtCore/qsize.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -60,7 +58,8 @@ class Q_GUI_EXPORT QSurface
{
public:
enum SurfaceClass {
- Window
+ Window,
+ Offscreen
};
enum SurfaceType {
@@ -89,6 +88,4 @@ protected:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif //QSURFACE_H
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 2c26a172a4..25b603bb9c 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -583,6 +583,30 @@ int QSurfaceFormat::minorVersion() const
}
/*!
+ Returns a QPair<int, int> representing the OpenGL version.
+
+ Useful for version checks, for example format.version() >= qMakePair(3, 2)
+*/
+QPair<int, int> QSurfaceFormat::version() const
+{
+ return qMakePair(d->major, d->minor);
+}
+
+/*!
+ Sets the desired \a major and \a minor OpenGL versions.
+
+ The default version is 2.0.
+*/
+void QSurfaceFormat::setVersion(int major, int minor)
+{
+ if (d->minor != minor || d->major != major) {
+ detach();
+ d->minor = minor;
+ d->major = major;
+ }
+}
+
+/*!
Returns true if all the options of the two QSurfaceFormat objects
\a a and \a b are equal.
diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h
index 8ab89225de..7c3c846df3 100644
--- a/src/gui/kernel/qsurfaceformat.h
+++ b/src/gui/kernel/qsurfaceformat.h
@@ -42,8 +42,7 @@
#define QSURFACEFORMAT_H
#include <QtCore/qglobal.h>
-
-QT_BEGIN_HEADER
+#include <QtCore/qpair.h>
QT_BEGIN_NAMESPACE
@@ -122,6 +121,9 @@ public:
void setMinorVersion(int minorVersion);
int minorVersion() const;
+ QPair<int, int> version() const;
+ void setVersion(int major, int minor);
+
bool stereo() const;
void setStereo(bool enable);
@@ -156,6 +158,4 @@ inline bool QSurfaceFormat::stereo() const
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif //QSURFACEFORMAT_H
diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h
index d9892bfbd3..312bdce3e6 100644
--- a/src/gui/kernel/qtouchdevice.h
+++ b/src/gui/kernel/qtouchdevice.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -90,6 +88,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QTouchDevice::Capabilities)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTOUCHDEVICE_H
diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h
index a358d77e92..435f8a5c37 100644
--- a/src/gui/kernel/qtouchdevice_p.h
+++ b/src/gui/kernel/qtouchdevice_p.h
@@ -56,8 +56,6 @@
#include <QtCore/qobject.h>
#include <QtGui/qtouchdevice.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -79,6 +77,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTOUCHDEVICE_P_H
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 65530f676a..f09edfe88e 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -115,6 +115,9 @@ QT_BEGIN_NAMESPACE
windowing systems that do not make this information visible to the
application, isExposed() will simply return the same value as isVisible().
+ QWindow::Visibility queried through visibility() is a convenience API
+ combining the functions of visible() and windowState().
+
\section1 Rendering
There are two Qt APIs that can be used to render content into a window,
@@ -228,6 +231,120 @@ QWindow::~QWindow()
}
/*!
+ \enum QWindow::Visibility
+ \since 5.1
+
+ This enum describes what part of the screen the window occupies or should
+ occupy.
+
+ \value Windowed The window occupies part of the screen, but not necessarily
+ the entire screen. This state will occur only on windowing systems which
+ support showing multiple windows simultaneously. In this state it is
+ possible for the user to move and resize the window manually, if
+ WindowFlags permit it and if it is supported by the windowing system.
+
+ \value Minimized The window is reduced to an entry or icon on the task bar,
+ dock, task list or desktop, depending on how the windowing system handles
+ minimized windows.
+
+ \value Maximized The window occupies one entire screen, and the titlebar is
+ still visible. On most windowing systems this is the state achieved by
+ clicking the maximize button on the toolbar.
+
+ \value FullScreen The window occupies one entire screen, is not resizable,
+ and there is no titlebar. On some platforms which do not support showing
+ multiple simultaneous windows, this can be the usual visibility when the
+ window is not hidden.
+
+ \value AutomaticVisibility This means to give the window a default visible
+ state, which might be fullscreen or windowed depending on the platform.
+ It can be given as a parameter to setVisibility but will never be
+ read back from the visibility accessor.
+
+ \value Hidden The window is not visible in any way, however it may remember
+ a latent visibility which can be restored by setting AutomaticVisibility.
+*/
+
+/*!
+ \property QWindow::visibility
+ \brief the screen-occupation state of the window
+ \since 5.1
+
+ Visibility is whether the window should appear in the windowing system as
+ normal, minimized, maximized, fullscreen or hidden.
+
+ To set the visibility to AutomaticVisibility means to give the window
+ a default visible state, which might be fullscreen or windowed depending on
+ the platform.
+ When reading the visibility property you will always get the actual state,
+ never AutomaticVisibility.
+*/
+QWindow::Visibility QWindow::visibility() const
+{
+ Q_D(const QWindow);
+ return d->visibility;
+}
+
+void QWindow::setVisibility(Visibility v)
+{
+ switch (v) {
+ case Hidden:
+ hide();
+ break;
+ case AutomaticVisibility:
+ show();
+ break;
+ case Windowed:
+ showNormal();
+ break;
+ case Minimized:
+ showMinimized();
+ break;
+ case Maximized:
+ showMaximized();
+ break;
+ case FullScreen:
+ showFullScreen();
+ break;
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+}
+
+void QWindowPrivate::updateVisibility()
+{
+ Q_Q(QWindow);
+
+ QWindow::Visibility old = visibility;
+
+ if (visible) {
+ switch (windowState) {
+ case Qt::WindowMinimized:
+ visibility = QWindow::Minimized;
+ break;
+ case Qt::WindowMaximized:
+ visibility = QWindow::Maximized;
+ break;
+ case Qt::WindowFullScreen:
+ visibility = QWindow::FullScreen;
+ break;
+ case Qt::WindowNoState:
+ visibility = QWindow::Windowed;
+ break;
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+ } else {
+ visibility = QWindow::Hidden;
+ }
+
+ if (visibility != old)
+ emit q->visibilityChanged(visibility);
+}
+
+/*!
Sets the \a surfaceType of the window.
Specifies whether the window is meant for raster rendering with
@@ -276,6 +393,7 @@ void QWindow::setVisible(bool visible)
return;
d->visible = visible;
emit visibleChanged(visible);
+ d->updateVisibility();
if (!d->platformWindow)
create();
@@ -296,7 +414,7 @@ void QWindow::setVisible(bool visible)
}
#ifndef QT_NO_CURSOR
- if (visible)
+ if (visible && d->hasCursor)
d->applyCursor();
#endif
d->platformWindow->setVisible(visible);
@@ -356,6 +474,10 @@ void QWindow::create()
WId QWindow::winId() const
{
Q_D(const QWindow);
+
+ if (type() == Qt::ForeignWindow)
+ return WId(property("_q_foreignWinId").value<WId>());
+
if(!d->platformWindow)
const_cast<QWindow *>(this)->create();
@@ -381,8 +503,11 @@ QWindow *QWindow::parent() const
the clip of the window, so it will be clipped to the \a parent window.
Setting \a parent to be 0 will make the window become a top level window.
-*/
+ If \a parent is a window created by fromWinId(), then the current window
+ will be embedded inside \a parent, if the platform supports it. Window
+ embedding is currently supported only by the X11 platform plugin.
+*/
void QWindow::setParent(QWindow *parent)
{
Q_D(QWindow);
@@ -654,7 +779,9 @@ void QWindow::lower()
}
/*!
- Sets the window's opacity in the windowing system to \a level.
+ \property QWindow::opacity
+ \brief The opacity of the window in the windowing system.
+ \since 5.1
If the windowing system supports window opacity, this can be used to fade the
window in and out, or to make it semitransparent.
@@ -662,15 +789,58 @@ void QWindow::lower()
A value of 1.0 or above is treated as fully opaque, whereas a value of 0.0 or below
is treated as fully transparent. Values inbetween represent varying levels of
translucency between the two extremes.
+
+ The default value is 1.0.
*/
void QWindow::setOpacity(qreal level)
{
Q_D(QWindow);
- if (level == d->opacity) // #fixme: Add property for 5.1
+ if (level == d->opacity)
return;
d->opacity = level;
- if (d->platformWindow)
+ if (d->platformWindow) {
d->platformWindow->setOpacity(level);
+ emit opacityChanged(level);
+ }
+}
+
+qreal QWindow::opacity() const
+{
+ Q_D(const QWindow);
+ return d->opacity;
+}
+
+/*!
+ Sets the mask of the window.
+
+ The mask is a hint to the windowing system that the application does not
+ want to receive mouse or touch input outside the given \a region.
+
+ The window manager may or may not choose to display any areas of the window
+ not included in the mask, thus it is the application's responsibility to
+ clear to transparent the areas that are not part of the mask.
+
+ Setting the mask before the window has been created has no effect.
+*/
+void QWindow::setMask(const QRegion &region)
+{
+ Q_D(QWindow);
+ if (!d->platformWindow)
+ return;
+ d->platformWindow->setMask(region);
+ d->mask = region;
+}
+
+/*!
+ Returns the mask set on the window.
+
+ The mask is a hint to the windowing system that the application does not
+ want to receive mouse or touch input outside the given region.
+*/
+QRegion QWindow::mask() const
+{
+ Q_D(const QWindow);
+ return d->mask;
}
/*!
@@ -735,6 +905,7 @@ bool QWindow::isActive() const
/*!
\property QWindow::contentOrientation
\brief the orientation of the window's contents
+ \since 5.1
This is a hint to the window manager in case it needs to display
additional content like popups, dialogs, status bars, or similar
@@ -809,6 +980,7 @@ void QWindow::setWindowState(Qt::WindowState state)
d->platformWindow->setWindowState(state);
d->windowState = state;
emit windowStateChanged(d->windowState);
+ d->updateVisibility();
}
/*!
@@ -990,6 +1162,7 @@ void QWindow::setHeight(int arg)
/*!
\property QWindow::minimumWidth
\brief the minimum width of the window's geometry
+ \since 5.1
*/
void QWindow::setMinimumWidth(int w)
{
@@ -999,6 +1172,7 @@ void QWindow::setMinimumWidth(int w)
/*!
\property QWindow::minimumHeight
\brief the minimum height of the window's geometry
+ \since 5.1
*/
void QWindow::setMinimumHeight(int h)
{
@@ -1031,6 +1205,7 @@ void QWindow::setMaximumSize(const QSize &size)
/*!
\property QWindow::maximumWidth
\brief the maximum width of the window's geometry
+ \since 5.1
*/
void QWindow::setMaximumWidth(int w)
{
@@ -1040,6 +1215,7 @@ void QWindow::setMaximumWidth(int w)
/*!
\property QWindow::maximumHeight
\brief the maximum height of the window's geometry
+ \since 5.1
*/
void QWindow::setMaximumHeight(int h)
{
@@ -1731,6 +1907,7 @@ bool QWindow::event(QEvent *ev)
case QEvent::WindowStateChange: {
Q_D(QWindow);
emit windowStateChanged(d->windowState);
+ d->updateVisibility();
break;
}
@@ -1945,6 +2122,34 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed()
}
+/*!
+ Creates a local representation of a window created by another process or by
+ using native libraries below Qt.
+
+ Given the handle \a id to a native window, this method creates a QWindow
+ object which can be used to represent the window when invoking methods like
+ setParent() and setTransientParent().
+ This can be used, on platforms which support it, to embed a window inside a
+ container or to make a window stick on top of a window created by another
+ process.
+
+ \sa setParent()
+ \sa setTransientParent()
+*/
+QWindow *QWindow::fromWinId(WId id)
+{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ForeignWindows)) {
+ qWarning() << "QWindow::fromWinId(): platform plugin does not support foreign windows.";
+ return 0;
+ }
+
+ QWindow *window = new QWindow;
+ window->setFlags(Qt::ForeignWindow);
+ window->setProperty("_q_foreignWinId", QVariant::fromValue(id));
+ window->create();
+ return window;
+}
+
#ifndef QT_NO_CURSOR
/*!
\brief set the cursor shape for this window
@@ -1966,13 +2171,7 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed()
void QWindow::setCursor(const QCursor &cursor)
{
Q_D(QWindow);
- d->cursor = cursor;
- // Only attempt to set cursor and emit signal if there is an actual platform cursor
- if (d->screen->handle()->cursor()) {
- d->applyCursor();
- QEvent event(QEvent::CursorChange);
- QGuiApplication::sendEvent(this, &event);
- }
+ d->setCursor(&cursor);
}
/*!
@@ -1980,7 +2179,8 @@ void QWindow::setCursor(const QCursor &cursor)
*/
void QWindow::unsetCursor()
{
- setCursor(Qt::ArrowCursor);
+ Q_D(QWindow);
+ d->setCursor(0);
}
/*!
@@ -1994,14 +2194,39 @@ QCursor QWindow::cursor() const
return d->cursor;
}
+void QWindowPrivate::setCursor(const QCursor *newCursor)
+{
+
+ Q_Q(QWindow);
+ if (newCursor) {
+ const Qt::CursorShape newShape = newCursor->shape();
+ if (newShape <= Qt::LastCursor && hasCursor && newShape == cursor.shape())
+ return; // Unchanged and no bitmap/custom cursor.
+ cursor = *newCursor;
+ hasCursor = true;
+ } else {
+ if (!hasCursor)
+ return;
+ cursor = QCursor(Qt::ArrowCursor);
+ hasCursor = false;
+ }
+ // Only attempt to set cursor and emit signal if there is an actual platform cursor
+ if (screen->handle()->cursor()) {
+ applyCursor();
+ QEvent event(QEvent::CursorChange);
+ QGuiApplication::sendEvent(q, &event);
+ }
+}
+
void QWindowPrivate::applyCursor()
{
Q_Q(QWindow);
if (platformWindow) {
if (QPlatformCursor *platformCursor = screen->handle()->cursor()) {
- QCursor *oc = QGuiApplication::overrideCursor();
- QCursor c = oc ? *oc : cursor;
- platformCursor->changeCursor(&c, q);
+ QCursor *c = QGuiApplication::overrideCursor();
+ if (!c && hasCursor)
+ c = &cursor;
+ platformCursor->changeCursor(c, q);
}
}
}
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 2e2f12a8ab..1b63e185f8 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -59,8 +59,6 @@
#include <QtGui/qcursor.h>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -93,12 +91,18 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_OBJECT
Q_DECLARE_PRIVATE(QWindow)
+ Q_ENUMS(Visibility)
+
// All properties which are declared here are inherited by QQuickWindow and therefore available in QML.
// So please think carefully about what it does to the QML namespace if you add any new ones,
// particularly the possible meanings these names might have in any specializations of Window.
// For example "state" (meaning windowState) is not a good property to declare, because it has
// a different meaning in QQuickItem, and users will tend to assume it is the same for Window.
+ // Any new properties which you add here MUST be versioned and MUST be documented both as
+ // C++ properties in qwindow.cpp AND as QML properties in qquickwindow.cpp.
+ // http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-definetypes.html#type-revisions-and-versions
+
Q_PROPERTY(QString title READ title WRITE setTitle)
Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged)
Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFlags)
@@ -106,14 +110,24 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
- Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged)
- Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged)
- Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
- Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged)
+ Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged REVISION 1)
+ Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged REVISION 1)
+ Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged REVISION 1)
+ Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged REVISION 1)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
- Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
+ Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged REVISION 1)
+ Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged REVISION 1)
+ Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged REVISION 1)
public:
+ enum Visibility {
+ Hidden = 0,
+ AutomaticVisibility,
+ Windowed,
+ Minimized,
+ Maximized,
+ FullScreen
+ };
explicit QWindow(QScreen *screen = 0);
explicit QWindow(QWindow *parent);
@@ -124,6 +138,9 @@ public:
bool isVisible() const;
+ Visibility visibility() const;
+ void setVisibility(Visibility v);
+
void create();
WId winId() const;
@@ -148,6 +165,11 @@ public:
QString title() const;
void setOpacity(qreal level);
+ qreal opacity() const;
+
+ void setMask(const QRegion &region);
+ QRegion mask() const;
+
void requestActivate();
bool isActive() const;
@@ -239,6 +261,8 @@ public:
void unsetCursor();
#endif
+ static QWindow *fromWinId(WId id);
+
public Q_SLOTS:
void setVisible(bool visible);
@@ -261,10 +285,10 @@ public Q_SLOTS:
void setWidth(int arg);
void setHeight(int arg);
- void setMinimumWidth(int w);
- void setMinimumHeight(int h);
- void setMaximumWidth(int w);
- void setMaximumHeight(int h);
+ Q_REVISION(1) void setMinimumWidth(int w);
+ Q_REVISION(1) void setMinimumHeight(int h);
+ Q_REVISION(1) void setMaximumWidth(int w);
+ Q_REVISION(1) void setMaximumHeight(int h);
Q_SIGNALS:
void screenChanged(QScreen *screen);
@@ -277,16 +301,19 @@ Q_SIGNALS:
void widthChanged(int arg);
void heightChanged(int arg);
- void minimumWidthChanged(int arg);
- void minimumHeightChanged(int arg);
- void maximumWidthChanged(int arg);
- void maximumHeightChanged(int arg);
+ Q_REVISION(1) void minimumWidthChanged(int arg);
+ Q_REVISION(1) void minimumHeightChanged(int arg);
+ Q_REVISION(1) void maximumWidthChanged(int arg);
+ Q_REVISION(1) void maximumHeightChanged(int arg);
void visibleChanged(bool arg);
- void contentOrientationChanged(Qt::ScreenOrientation orientation);
+ Q_REVISION(1) void visibilityChanged(QWindow::Visibility visibility);
+ Q_REVISION(1) void contentOrientationChanged(Qt::ScreenOrientation orientation);
void focusObjectChanged(QObject *object);
+ Q_REVISION(1) void opacityChanged(qreal opacity);
+
private Q_SLOTS:
void screenDestroyed(QObject *screen);
@@ -330,6 +357,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWINDOW_H
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 26bf0700f2..e32d45acca 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -59,8 +59,6 @@
#include <QtCore/private/qobject_p.h>
#include <QtGui/QIcon>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
#define QWINDOWSIZE_MAX ((1<<24)-1)
@@ -85,6 +83,7 @@ public:
, visible(false)
, exposed(false)
, windowState(Qt::WindowNoState)
+ , visibility(QWindow::Hidden)
, resizeEventPending(true)
, receivedExpose(false)
, positionPolicy(WindowFrameExclusive)
@@ -99,6 +98,7 @@ public:
, screen(0)
#ifndef QT_NO_CURSOR
, cursor(Qt::ArrowCursor)
+ , hasCursor(false)
#endif
{
isWindow = true;
@@ -110,6 +110,7 @@ public:
void maybeQuitOnLastWindowClosed();
#ifndef QT_NO_CURSOR
+ void setCursor(const QCursor *c = 0);
void applyCursor();
#endif
@@ -123,6 +124,8 @@ public:
virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; }
+ void updateVisibility();
+
QWindow::SurfaceType surfaceType;
Qt::WindowFlags windowFlags;
QWindow *parentWindow;
@@ -135,12 +138,14 @@ public:
QIcon windowIcon;
QRect geometry;
Qt::WindowState windowState;
+ QWindow::Visibility visibility;
bool resizeEventPending;
bool receivedExpose;
PositionPolicy positionPolicy;
bool positionAutomatic;
Qt::ScreenOrientation contentOrientation;
qreal opacity;
+ QRegion mask;
QSize minimumSize;
QSize maximumSize;
@@ -155,12 +160,11 @@ public:
#ifndef QT_NO_CURSOR
QCursor cursor;
+ bool hasCursor;
#endif
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWINDOW_P_H
diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h
index 9aaca3ff60..42f4bc7c9b 100644
--- a/src/gui/kernel/qwindowdefs.h
+++ b/src/gui/kernel/qwindowdefs.h
@@ -46,7 +46,6 @@
#include <QtCore/qobjectdefs.h>
#include <QtCore/qnamespace.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -88,7 +87,6 @@ typedef QList<QWidget *> QWidgetList;
typedef QList<QWindow *> QWindowList;
QT_END_NAMESPACE
-QT_END_HEADER
// Window system dependent definitions
@@ -104,7 +102,6 @@ typedef QT_PREPEND_NAMESPACE(quintptr) WId;
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
template<class K, class V> class QHash;
@@ -114,7 +111,6 @@ template<class V> class QSet;
typedef QSet<QWidget *> QWidgetSet;
QT_END_NAMESPACE
-QT_END_HEADER
#if defined(QT_NEEDS_QMAIN)
#define main qMain
diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/gui/kernel/qwindowdefs_win.h
index 8f551900ae..fea995a0f5 100644
--- a/src/gui/kernel/qwindowdefs_win.h
+++ b/src/gui/kernel/qwindowdefs_win.h
@@ -44,8 +44,6 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -124,6 +122,4 @@ Q_WIDGETS_EXPORT HDC qt_win_display_dc();
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWINDOWDEFS_WIN_H
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 27bb4bae00..d2add91d66 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -46,6 +46,7 @@
#include "private/qtouchdevice_p.h"
#include <QAbstractEventDispatcher>
#include <qpa/qplatformdrag.h>
+#include <qpa/qplatformintegration.h>
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -53,6 +54,8 @@ QT_BEGIN_NAMESPACE
QElapsedTimer QWindowSystemInterfacePrivate::eventTime;
bool QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents = false;
+QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed;
+QMutex QWindowSystemInterfacePrivate::flushEventMutex;
//------------------------------------------------------------
//
@@ -109,9 +112,10 @@ void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leav
}
}
-void QWindowSystemInterface::handleWindowActivated(QWindow *tlw)
+void QWindowSystemInterface::handleWindowActivated(QWindow *tlw, Qt::FocusReason r)
{
- QWindowSystemInterfacePrivate::ActivatedWindowEvent *e = new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw);
+ QWindowSystemInterfacePrivate::ActivatedWindowEvent *e =
+ new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw, r);
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
@@ -122,6 +126,14 @@ void QWindowSystemInterface::handleWindowStateChanged(QWindow *tlw, Qt::WindowSt
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
+void QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState newState)
+{
+ Q_ASSERT(QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState));
+ QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e =
+ new QWindowSystemInterfacePrivate::ApplicationStateChangedEvent(newState);
+ QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+}
+
void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect)
{
QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
@@ -505,9 +517,35 @@ void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion &regi
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
+void QWindowSystemInterface::deferredFlushWindowSystemEvents()
+{
+ Q_ASSERT(QThread::currentThread() == QGuiApplication::instance()->thread());
+
+ QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
+ flushWindowSystemEvents();
+ QWindowSystemInterfacePrivate::eventsFlushed.wakeOne();
+}
+
void QWindowSystemInterface::flushWindowSystemEvents()
{
- sendWindowSystemEventsImplementation(QEventLoop::AllEvents);
+ const int count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count();
+ if (!count)
+ return;
+ if (!QGuiApplication::instance()) {
+ qWarning().nospace()
+ << "QWindowSystemInterface::flushWindowSystemEvents() invoked after "
+ "QGuiApplication destruction, discarding " << count << " events.";
+ QWindowSystemInterfacePrivate::windowSystemEventQueue.clear();
+ return;
+ }
+ if (QThread::currentThread() != QGuiApplication::instance()->thread()) {
+ QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
+ QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent();
+ QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex);
+ } else {
+ sendWindowSystemEventsImplementation(QEventLoop::AllEvents);
+ }
}
bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
@@ -575,6 +613,12 @@ void QWindowSystemInterface::handleFileOpenEvent(const QString& fileName)
QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
+void QWindowSystemInterface::handleFileOpenEvent(const QUrl &url)
+{
+ QWindowSystemInterfacePrivate::FileOpenEvent e(url);
+ QGuiApplicationPrivate::processWindowSystemEvent(&e);
+}
+
void QWindowSystemInterface::handleTabletEvent(QWindow *w, ulong timestamp, bool down, const QPointF &local, const QPointF &global,
int device, int pointerType, qreal pressure, int xTilt, int yTilt,
qreal tangentialPressure, qreal rotation, int z, qint64 uid,
@@ -641,6 +685,13 @@ void QWindowSystemInterface::handleContextMenuEvent(QWindow *w, bool mouseTrigge
}
#endif
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p) {
+ dbg.nospace() << "TouchPoint(" << p.id << " @" << p.normalPosition << " press " << p.pressure << " vel " << p.velocity << " state " << (int)p.state;
+ return dbg.space();
+}
+#endif
+
Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) {
QWindowSystemInterface::handleMouseEvent(w, local, global, b, mods);
}
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index 5715b69ee5..212259c113 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -62,8 +62,6 @@
#include <QtCore/QEventLoop>
#include <QtGui/QVector2D>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QMimeData;
@@ -137,9 +135,12 @@ public:
static void handleEnterEvent(QWindow *w, const QPointF &local = QPointF(), const QPointF& global = QPointF());
static void handleLeaveEvent(QWindow *w);
static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF& global = QPointF());
- static void handleWindowActivated(QWindow *w);
+ static void handleWindowActivated(QWindow *w, Qt::FocusReason r = Qt::OtherFocusReason);
+
static void handleWindowStateChanged(QWindow *w, Qt::WindowState newState);
+ static void handleApplicationStateChanged(Qt::ApplicationState newState);
+
static void handleExposeEvent(QWindow *tlw, const QRegion &region);
#ifndef QT_NO_DRAGANDDROP
@@ -160,6 +161,7 @@ public:
static void handleThemeChange(QWindow *tlw);
static void handleFileOpenEvent(const QString& fileName);
+ static void handleFileOpenEvent(const QUrl &url);
static void handleTabletEvent(QWindow *w, ulong timestamp, bool down, const QPointF &local, const QPointF &global,
int device, int pointerType, qreal pressure, int xTilt, int yTilt,
@@ -185,12 +187,17 @@ public:
static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
static void setSynchronousWindowsSystemEvents(bool enable);
static void flushWindowSystemEvents();
+ static void deferredFlushWindowSystemEvents();
static int windowSystemEventsQueued();
private:
static bool sendWindowSystemEventsImplementation(QEventLoop::ProcessEventsFlags flags);
};
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p);
+#endif
+
QT_END_NAMESPACE
-QT_END_HEADER
+
#endif // QWINDOWSYSTEMINTERFACE_H
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 4131568461..f1bc4667f7 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -58,8 +58,7 @@
#include <QPointer>
#include <QMutex>
#include <QList>
-
-QT_BEGIN_HEADER
+#include <QWaitCondition>
QT_BEGIN_NAMESPACE
@@ -90,7 +89,9 @@ public:
TabletEnterProximity = UserInputEvent | 0x15,
TabletLeaveProximity = UserInputEvent | 0x16,
PlatformPanel = UserInputEvent | 0x17,
- ContextMenu = UserInputEvent | 0x18
+ ContextMenu = UserInputEvent | 0x18,
+ ApplicationStateChanged = 0x19,
+ FlushEvents = 0x20
};
class WindowSystemEvent {
@@ -138,10 +139,11 @@ public:
class ActivatedWindowEvent : public WindowSystemEvent {
public:
- explicit ActivatedWindowEvent(QWindow *activatedWindow)
- : WindowSystemEvent(ActivatedWindow), activated(activatedWindow)
+ explicit ActivatedWindowEvent(QWindow *activatedWindow, Qt::FocusReason r)
+ : WindowSystemEvent(ActivatedWindow), activated(activatedWindow), reason(r)
{ }
QPointer<QWindow> activated;
+ Qt::FocusReason reason;
};
class WindowStateChangedEvent : public WindowSystemEvent {
@@ -154,6 +156,22 @@ public:
Qt::WindowState newState;
};
+ class ApplicationStateChangedEvent : public WindowSystemEvent {
+ public:
+ ApplicationStateChangedEvent(Qt::ApplicationState newState)
+ : WindowSystemEvent(ApplicationStateChanged), newState(newState)
+ { }
+
+ Qt::ApplicationState newState;
+ };
+
+ class FlushEventsEvent : public WindowSystemEvent {
+ public:
+ FlushEventsEvent()
+ : WindowSystemEvent(FlushEvents)
+ { }
+ };
+
class UserEvent : public WindowSystemEvent {
public:
UserEvent(QWindow * w, ulong time, EventType t)
@@ -287,9 +305,12 @@ public:
class FileOpenEvent : public WindowSystemEvent {
public:
FileOpenEvent(const QString& fileName)
- : WindowSystemEvent(FileOpen), fileName(fileName)
+ : WindowSystemEvent(FileOpen), url(QUrl::fromLocalFile(fileName))
+ { }
+ FileOpenEvent(const QUrl &url)
+ : WindowSystemEvent(FileOpen), url(url)
{ }
- QString fileName;
+ QUrl url;
};
class TabletEvent : public InputEvent {
@@ -367,9 +388,10 @@ public:
mutable QMutex mutex;
public:
WindowSystemEventList() : impl(), mutex() {}
- ~WindowSystemEventList()
- { const QMutexLocker locker(&mutex); qDeleteAll(impl); impl.clear(); }
+ ~WindowSystemEventList() { clear(); }
+ void clear()
+ { const QMutexLocker locker(&mutex); qDeleteAll(impl); impl.clear(); }
void prepend(WindowSystemEvent *e)
{ const QMutexLocker locker(&mutex); impl.prepend(e); }
WindowSystemEvent *takeFirstOrReturnNull()
@@ -400,7 +422,7 @@ public:
const QMutexLocker locker(&mutex);
for (int i = 0; i < impl.size(); ++i) {
if (impl.at(i) == e) {
- impl.removeAt(i);
+ delete impl.takeAt(i);
break;
}
}
@@ -421,10 +443,12 @@ public:
static QElapsedTimer eventTime;
static bool synchronousWindowsSystemEvents;
+ static QWaitCondition eventsFlushed;
+ static QMutex flushEventMutex;
+
static QList<QTouchEvent::TouchPoint> convertTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points, QEvent::Type *type);
};
-QT_END_HEADER
QT_END_NAMESPACE
#endif // QWINDOWSYSTEMINTERFACE_P_H