summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-07-21 13:50:28 +0200
committerJørgen Lind <jorgen.lind@nokia.com>2011-07-25 13:52:09 +0200
commitc3da77798b876716ce038a30e9aa8517ec158c47 (patch)
tree99ac6cf5ce37fcb626a12857bb18cf9b444b27f2 /src/gui/kernel
parente80b6619524a3720efb5fbe4c2307bec25a12ab8 (diff)
Added workable QScreen API on top of QPlatformScreen.
QPlatformIntegration::screens() no longer has to be implemented, implementations should call QPlatformIntegration::screenAdded() for each screen instead. This is for being able to support adding screens at run-time later on, by connecting it to a signal in QGuiApplication. The QGuiGLContext API has changed a bit, by not sending in all the parameters in the constructor but instead having a create() function. The createPlatformGLContext() factory in QPlatformIntegration takes a QGuiGLContext * instead of a QSurfaceFormat and a share context, similar to how the window and backing store factory functions work. The XCB plugin has experimental support for connecting to multiple X displays simultaneously, creating one or more QScreen for each. Change-Id: I248a22a4fd3481280710110272c04a30a8021e8f Reviewed-on: http://codereview.qt.nokia.com/2103 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri2
-rw-r--r--src/gui/kernel/qdnd_p.h2
-rw-r--r--src/gui/kernel/qguiapplication.cpp27
-rw-r--r--src/gui/kernel/qguiapplication.h5
-rw-r--r--src/gui/kernel/qguiapplication_p.h1
-rw-r--r--src/gui/kernel/qguiglcontext_qpa.cpp85
-rw-r--r--src/gui/kernel/qguiglcontext_qpa.h18
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp59
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h15
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.cpp63
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.h33
-rw-r--r--src/gui/kernel/qscreen.h95
-rw-r--r--src/gui/kernel/qwindow.cpp34
-rw-r--r--src/gui/kernel/qwindow.h7
-rw-r--r--src/gui/kernel/qwindow_p.h2
15 files changed, 379 insertions, 69 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 7f9434e9b4..58291f5237 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -20,6 +20,7 @@ HEADERS += \
kernel/qpalette.h \
kernel/qsessionmanager.h \
kernel/qwindowdefs.h \
+ kernel/qscreen.h
SOURCES += \
kernel/qclipboard.cpp \
@@ -33,6 +34,7 @@ SOURCES += \
kernel/qmime.cpp \
kernel/qpalette.cpp \
kernel/qguivariant.cpp \
+ kernel/qscreen.cpp
qpa {
HEADERS += \
diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h
index 2eebcf6158..7159acf594 100644
--- a/src/gui/kernel/qdnd_p.h
+++ b/src/gui/kernel/qdnd_p.h
@@ -113,7 +113,7 @@ class QShapedPixmapWindow : public QWindow {
QPixmap pixmap;
public:
QShapedPixmapWindow() :
- QWindow(0)
+ QWindow()
{
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
// ### Should we set the surface type to raster?
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index ad01a72a45..a54dab6398 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -52,6 +52,7 @@
#include <QtCore/qmutex.h>
#include <QtDebug>
#include <qpalette.h>
+#include <qscreen.h>
#include <QtGui/QPlatformIntegration>
#include <QtGui/QGenericPluginFactory>
@@ -103,6 +104,8 @@ QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0;
QClipboard *QGuiApplicationPrivate::qt_clipboard = 0;
#endif
+QList<QScreen *> QGuiApplicationPrivate::screen_list;
+
QWindowList QGuiApplicationPrivate::window_list;
QWindow *QGuiApplicationPrivate::active_window = 0;
@@ -179,21 +182,27 @@ QWindowList QGuiApplication::topLevelWindows()
return QGuiApplicationPrivate::window_list;
}
-QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
+QScreen *QGuiApplication::primaryScreen()
{
- QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+ if (QGuiApplicationPrivate::screen_list.isEmpty())
+ return 0;
+ return QGuiApplicationPrivate::screen_list.at(0);
+}
- QList<QPlatformScreen *> screens = pi->screens();
- QList<QPlatformScreen *>::const_iterator screen = screens.constBegin();
- QList<QPlatformScreen *>::const_iterator end = screens.constEnd();
+QList<QScreen *> QGuiApplication::screens()
+{
+ return QGuiApplicationPrivate::screen_list;
+}
- // The first screen in a virtual environment should know about all top levels
- if (pi->isVirtualDesktop())
- return (*screen)->topLevelAt(pos);
+QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
+{
+ QList<QScreen *> screens = QGuiApplication::screens();
+ QList<QScreen *>::const_iterator screen = screens.constBegin();
+ QList<QScreen *>::const_iterator end = screens.constEnd();
while (screen != end) {
if ((*screen)->geometry().contains(pos))
- return (*screen)->topLevelAt(pos);
+ return (*screen)->handle()->topLevelAt(pos);
++screen;
}
return 0;
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index 4557b946a8..8338fa1f9a 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -57,6 +57,7 @@ QT_MODULE(Gui)
class QGuiApplicationPrivate;
class QPlatformNativeInterface;
class QPalette;
+class QScreen;
#if defined(qApp)
#undef qApp
@@ -83,6 +84,8 @@ public:
static QWindow *topLevelAt(const QPoint &pos);
static QWindow *activeWindow();
+ static QScreen *primaryScreen();
+ static QList<QScreen *> screens();
#ifndef QT_NO_CURSOR
static QCursor *overrideCursor();
@@ -125,6 +128,7 @@ public:
Q_SIGNALS:
void fontDatabaseChanged();
+ void screenAdded(QScreen *screen);
protected:
bool event(QEvent *);
@@ -140,6 +144,7 @@ private:
friend class QGestureManager;
#endif
friend class QFontDatabasePrivate;
+ friend class QPlatformIntegration;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 6d44caa35a..8391662a4a 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -162,6 +162,7 @@ public:
#ifndef QT_NO_CURSOR
QList<QCursor> cursor_list;
#endif
+ static QList<QScreen *> screen_list;
static QFont *app_font;
private:
diff --git a/src/gui/kernel/qguiglcontext_qpa.cpp b/src/gui/kernel/qguiglcontext_qpa.cpp
index fd827966c4..61a0479bd3 100644
--- a/src/gui/kernel/qguiglcontext_qpa.cpp
+++ b/src/gui/kernel/qguiglcontext_qpa.cpp
@@ -47,6 +47,7 @@
#include <QtCore/QThread>
#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/QScreen>
#include <QDebug>
@@ -69,6 +70,7 @@ public:
: qGLContextHandle(0)
, platformGLContext(0)
, shareContext(0)
+ , screen(0)
{
}
@@ -79,8 +81,11 @@ public:
}
void *qGLContextHandle;
void (*qGLContextDeleteFunction)(void *handle);
+
+ QSurfaceFormat requestedFormat;
QPlatformGLContext *platformGLContext;
QGuiGLContext *shareContext;
+ QScreen *screen;
static void setCurrentContext(QGuiGLContext *context);
};
@@ -117,29 +122,87 @@ QPlatformGLContext *QGuiGLContext::handle() const
return d->platformGLContext;
}
+QPlatformGLContext *QGuiGLContext::shareHandle() const
+{
+ Q_D(const QGuiGLContext);
+ if (d->shareContext)
+ return d->shareContext->handle();
+ return 0;
+}
+
/*!
- Creates a new GL context with the given format and shared context.
+ Creates a new GL context instance, you need to call create() before it can be used.
*/
-QGuiGLContext::QGuiGLContext(const QSurfaceFormat &format, QGuiGLContext *shareContext)
+QGuiGLContext::QGuiGLContext()
: d_ptr(new QGuiGLContextPrivate())
{
Q_D(QGuiGLContext);
- QPlatformGLContext *share = shareContext ? shareContext->handle() : 0;
+ d->screen = QGuiApplication::primaryScreen();
+}
+
+/*!
+ Sets the format the GL context should be compatible with. You need to call create() before it takes effect.
+*/
+void QGuiGLContext::setFormat(const QSurfaceFormat &format)
+{
+ Q_D(QGuiGLContext);
+ d->requestedFormat = format;
+}
+
+/*!
+ Sets the context to share textures, shaders, and other GL resources with. You need to call create() before it takes effect.
+*/
+void QGuiGLContext::setShareContext(QGuiGLContext *shareContext)
+{
+ Q_D(QGuiGLContext);
d->shareContext = shareContext;
- d->platformGLContext = QGuiApplicationPrivate::platformIntegration()->createPlatformGLContext(format, share);
}
/*!
- If this is the current context for the thread, doneCurrent is called
+ Sets the screen the GL context should be valid for. You need to call create() before it takes effect.
*/
-QGuiGLContext::~QGuiGLContext()
+void QGuiGLContext::setScreen(QScreen *screen)
+{
+ Q_D(QGuiGLContext);
+ d->screen = screen;
+ if (!d->screen)
+ d->screen = QGuiApplication::primaryScreen();
+}
+
+/*!
+ Attempts to create the GL context with the desired parameters.
+
+ Returns true if the native context was successfully created and is ready to be used.d
+*/
+bool QGuiGLContext::create()
+{
+ destroy();
+
+ Q_D(QGuiGLContext);
+ d->platformGLContext = QGuiApplicationPrivate::platformIntegration()->createPlatformGLContext(this);
+ return d->platformGLContext;
+}
+
+void QGuiGLContext::destroy()
{
Q_D(QGuiGLContext);
if (QGuiGLContext::currentContext() == this)
doneCurrent();
delete d->platformGLContext;
+ d->platformGLContext = 0;
+}
+
+/*!
+ If this is the current context for the thread, doneCurrent is called
+*/
+QGuiGLContext::~QGuiGLContext()
+{
+ destroy();
}
+/*!
+ Returns if this context is valid, i.e. has been successfully created.
+*/
bool QGuiGLContext::isValid() const
{
Q_D(const QGuiGLContext);
@@ -210,18 +273,22 @@ QSurfaceFormat QGuiGLContext::format() const
{
Q_D(const QGuiGLContext);
if (!d->platformGLContext)
- return QSurfaceFormat();
+ return d->requestedFormat;
return d->platformGLContext->format();
}
QGuiGLContext *QGuiGLContext::shareContext() const
{
Q_D(const QGuiGLContext);
- if (!d->platformGLContext)
- return 0;
return d->shareContext;
}
+QScreen *QGuiGLContext::screen() const
+{
+ Q_D(const QGuiGLContext);
+ return d->screen;
+}
+
/*
internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant
have any type information.
diff --git a/src/gui/kernel/qguiglcontext_qpa.h b/src/gui/kernel/qguiglcontext_qpa.h
index 9e62905b68..db3d6f29e6 100644
--- a/src/gui/kernel/qguiglcontext_qpa.h
+++ b/src/gui/kernel/qguiglcontext_qpa.h
@@ -61,24 +61,30 @@ class Q_GUI_EXPORT QGuiGLContext
{
Q_DECLARE_PRIVATE(QGuiGLContext);
public:
- QGuiGLContext(const QSurfaceFormat &format = QSurfaceFormat(), QGuiGLContext *shareContext = 0);
+ QGuiGLContext();
~QGuiGLContext();
+ void setFormat(const QSurfaceFormat &format);
+ void setShareContext(QGuiGLContext *shareContext);
+ void setScreen(QScreen *screen);
+
+ bool create();
bool isValid() const;
+ QSurfaceFormat format() const;
+ QGuiGLContext *shareContext() const;
+ QScreen *screen() const;
+
bool makeCurrent(QSurface *surface);
void doneCurrent();
void swapBuffers(QSurface *surface);
void (*getProcAddress(const QByteArray &procName)) ();
- QSurfaceFormat format() const;
-
- QGuiGLContext *shareContext() const;
-
static QGuiGLContext *currentContext();
QPlatformGLContext *handle() const;
+ QPlatformGLContext *shareHandle() const;
private:
QScopedPointer<QGuiGLContextPrivate> d_ptr;
@@ -91,6 +97,8 @@ private:
void setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *));
void deleteQGLContext();
+ void destroy();
+
Q_DISABLE_COPY(QGuiGLContext);
};
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
index ab0d5100c3..c190c4f481 100644
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -44,21 +44,12 @@
#include <QtGui/QPlatformFontDatabase>
#include <QtGui/QPlatformClipboard>
#include <QtGui/QPlatformPrinterSupport>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/private/qpixmap_raster_p.h>
#include <private/qdnd_p.h>
QT_BEGIN_NAMESPACE
-QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, int height) const
-{
- Q_UNUSED(window);
- Q_UNUSED(x);
- Q_UNUSED(y);
- Q_UNUSED(width);
- Q_UNUSED(height);
- return QPixmap();
-}
-
-
/*!
Accessor for the platform integrations fontdatabase.
@@ -177,12 +168,6 @@ QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
*/
-QPlatformGLContext *QPlatformIntegration::createPlatformGLContext(const QSurfaceFormat &, QPlatformGLContext *) const
-{
- qWarning("This plugin does not support createPlatformGLContext!");
- return 0;
-}
-
/*!
\fn void QPlatformIntegration::moveToScreen(QWindow *window, int screen)
@@ -212,15 +197,6 @@ QPlatformGLContext *QPlatformIntegration::createPlatformGLContext(const QSurface
*/
/*!
- \fn QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, int height) const
-
- This function is called when Qt needs to be able to grab the content of a window.
-
- Returnes the content of the window specified with the WId handle within the boundaries of
- QRect(x,y,width,height).
-*/
-
-/*!
\fn QAbstractEventDispatcher *createEventDispatcher() const
Factory function for the event dispatcher. The platform plugin
@@ -234,6 +210,17 @@ bool QPlatformIntegration::hasCapability(Capability cap) const
return false;
}
+QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
+{
+ return new QRasterPlatformPixmap(type);
+}
+
+QPlatformGLContext *QPlatformIntegration::createPlatformGLContext(QGuiGLContext *context) const
+{
+ qWarning("This plugin does not support createPlatformGLContext!");
+ return 0;
+}
+
/*!
Returns the platform's printing support.
@@ -261,4 +248,24 @@ QPlatformInputContext *QPlatformIntegration::inputContext() const
return 0;
}
+/*!
+ Should be called by the implementation whenever a new screen is added.
+
+ The first screen added will be the primary screen, used for default-created
+ windows, GL contexts, and other resources unless otherwise specified.
+
+ This adds the screen to QGuiApplication::screens(), and emits the
+ QGuiApplication::screenAdded() signal.
+
+ The screen is automatically removed when the QPlatformScreen is destroyed.
+*/
+void QPlatformIntegration::screenAdded(QPlatformScreen *ps)
+{
+ QScreen *screen = ps ? ps->screen() : 0;
+ if (screen && !QGuiApplicationPrivate::screen_list.contains(screen)) {
+ QGuiApplicationPrivate::screen_list << screen;
+ emit qGuiApp->screenAdded(screen);
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
index 092186c160..35dfe07140 100644
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -43,7 +43,6 @@
#define QPLATFORMINTEGRATION_H
#include <QtGui/qwindowdefs.h>
-#include <QtGui/qplatformpixmap_qpa.h>
#include <QtGui/qplatformscreen_qpa.h>
#include <QtGui/qsurfaceformat.h>
@@ -78,17 +77,10 @@ public:
virtual bool hasCapability(Capability cap) const;
-// GraphicsSystem functions
- virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const = 0;
+ virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const;
virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0;
virtual QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const = 0;
- virtual QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &format, QPlatformGLContext *share) const;
-
-// Window System functions
- virtual QList<QPlatformScreen *> screens() const = 0;
- virtual void moveToScreen(QWindow *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);}
- virtual bool isVirtualDesktop() { return false; }
- virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+ virtual QPlatformGLContext *createPlatformGLContext(QGuiGLContext *context) const;
// Event dispatcher:
virtual QAbstractEventDispatcher *createEventDispatcher() const = 0;
@@ -107,6 +99,9 @@ public:
virtual QPlatformNativeInterface *nativeInterface() const;
virtual QPlatformPrinterSupport *printerSupport() const;
+
+protected:
+ void screenAdded(QPlatformScreen *screen);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp
index 16b2557a15..ae1c6dcf06 100644
--- a/src/gui/kernel/qplatformscreen_qpa.cpp
+++ b/src/gui/kernel/qplatformscreen_qpa.cpp
@@ -43,8 +43,47 @@
#include <QtGui/qguiapplication.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qplatformintegration_qpa.h>
+#include <QtGui/qscreen.h>
#include <QtGui/qwindow.h>
+struct QPlatformScreenPrivate
+{
+ QScreen *screen;
+};
+
+QPlatformScreen::QPlatformScreen()
+ : d_ptr(new QPlatformScreenPrivate)
+{
+ Q_D(QPlatformScreen);
+ d->screen = new QScreen(this);
+}
+
+QPlatformScreen::~QPlatformScreen()
+{
+ Q_D(QPlatformScreen);
+
+ QGuiApplicationPrivate::screen_list.removeOne(d->screen);
+ delete d->screen;
+}
+
+/*!
+ \fn QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const
+
+ This function is called when Qt needs to be able to grab the content of a window.
+
+ Returnes the content of the window specified with the WId handle within the boundaries of
+ QRect(x,y,width,height).
+*/
+QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const
+{
+ Q_UNUSED(window);
+ Q_UNUSED(x);
+ Q_UNUSED(y);
+ Q_UNUSED(width);
+ Q_UNUSED(height);
+ return QPixmap();
+}
+
/*!
Return the given top level window for a given position.
@@ -64,6 +103,26 @@ QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const
}
/*!
+ Returns a list of all the platform screens that are part of the same
+ virtual desktop.
+
+ Screens part of the same virtual desktop share a common coordinate system,
+ and windows can be freely moved between them.
+*/
+QList<QPlatformScreen *> QPlatformScreen::virtualSiblings() const
+{
+ QList<QPlatformScreen *> list;
+ list << const_cast<QPlatformScreen *>(this);
+ return list;
+}
+
+QScreen *QPlatformScreen::screen() const
+{
+ Q_D(const QPlatformScreen);
+ return d->screen;
+}
+
+/*!
Reimplement this function in subclass to return the physical size of the
screen. This function is used by QFont to convert point sizes to pixel
sizes.
@@ -81,9 +140,9 @@ QSize QPlatformScreen::physicalSize() const
return QSize(width,height);
}
-QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *)
+QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window)
{
- return QGuiApplicationPrivate::platformIntegration()->screens().at(0);
+ return window->screen()->handle();
}
/*!
diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h
index 16e62dd6c6..8d3dd4cc71 100644
--- a/src/gui/kernel/qplatformscreen_qpa.h
+++ b/src/gui/kernel/qplatformscreen_qpa.h
@@ -52,6 +52,7 @@
#include <QtGui/qcursor.h>
#include <QtGui/qimage.h>
#include <QtGui/qwindowdefs.h>
+#include <QtGui/qplatformpixmap_qpa.h>
QT_BEGIN_HEADER
@@ -59,24 +60,46 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-class Q_GUI_EXPORT QPlatformScreen : public QObject
+class QPlatformBackingStore;
+class QPlatformGLContext;
+class QPlatformScreenPrivate;
+class QPlatformWindow;
+class QScreen;
+class QSurfaceFormat;
+
+class Q_GUI_EXPORT QPlatformScreen
{
- Q_OBJECT
+ Q_DECLARE_PRIVATE(QPlatformScreen)
+
public:
- virtual ~QPlatformScreen() { }
+ QPlatformScreen();
+ virtual ~QPlatformScreen();
+
+ virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
virtual QRect geometry() const = 0;
virtual QRect availableGeometry() const {return geometry();}
+
virtual int depth() const = 0;
virtual QImage::Format format() const = 0;
virtual QSize physicalSize() const;
- //jl: should setDirty be removed.
- virtual void setDirty(const QRect &) {}
+
virtual QWindow *topLevelAt(const QPoint &point) const;
+ virtual QList<QPlatformScreen *> virtualSiblings() const;
+
+ QScreen *screen() const;
//jl: should this function be in QPlatformIntegration
//jl: maybe screenForWindow is a better name?
static QPlatformScreen *platformScreenForWindow(const QWindow *window);
+
+ virtual QString name() const { return QString(); }
+
+protected:
+ QScopedPointer<QPlatformScreenPrivate> d_ptr;
+
+private:
+ Q_DISABLE_COPY(QPlatformScreen)
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h
new file mode 100644
index 0000000000..f96056e45a
--- /dev/null
+++ b/src/gui/kernel/qscreen.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCREEN_H
+#define QSCREEN_H
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#include <QList>
+
+class QPlatformScreen;
+class QScreenPrivate;
+class QWindow;
+
+class Q_GUI_EXPORT QScreen : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QScreen)
+
+public:
+ QPlatformScreen *handle() const;
+
+ QString name() const;
+
+ int depth() const;
+
+ QSize size() const;
+ QRect geometry() const;
+
+ QSize availableSize() const;
+ QRect availableGeometry() const;
+
+ QList<QScreen *> virtualSiblings() const;
+
+ QSize virtualSize() const;
+ QRect virtualGeometry() const;
+
+ QSize availableVirtualSize() const;
+ QRect availableVirtualGeometry() const;
+
+private:
+ QScreen(QPlatformScreen *screen);
+
+ Q_DISABLE_COPY(QScreen)
+ friend class QPlatformScreen;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSCREEN_H
+
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 7fa9316878..018474aba7 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -45,6 +45,7 @@
#include "qsurfaceformat.h"
#include "qplatformglcontext_qpa.h"
#include "qguiglcontext_qpa.h"
+#include "qscreen.h"
#include "qwindow_p.h"
#include "qguiapplication_p.h"
@@ -55,12 +56,27 @@
QT_BEGIN_NAMESPACE
+QWindow::QWindow(QScreen *targetScreen)
+ : QObject(*new QWindowPrivate(), 0)
+ , QSurface(QSurface::Window)
+{
+ Q_D(QWindow);
+ d->screen = targetScreen;
+ if (!d->screen)
+ d->screen = QGuiApplication::primaryScreen();
+ QGuiApplicationPrivate::window_list.prepend(this);
+}
+
QWindow::QWindow(QWindow *parent)
: QObject(*new QWindowPrivate(), parent)
, QSurface(QSurface::Window)
{
Q_D(QWindow);
d->parentWindow = parent;
+ if (parent)
+ d->screen = parent->screen();
+ if (!d->screen)
+ d->screen = QGuiApplication::primaryScreen();
QGuiApplicationPrivate::window_list.prepend(this);
}
@@ -439,6 +455,23 @@ bool QWindow::setMouseGrabEnabled(bool grab)
return false;
}
+QScreen *QWindow::screen() const
+{
+ Q_D(const QWindow);
+ return d->screen;
+}
+
+void QWindow::setScreen(QScreen *newScreen)
+{
+ Q_D(QWindow);
+ bool wasCreated = d->platformWindow != 0;
+ if (wasCreated)
+ destroy();
+ d->screen = newScreen ? newScreen : QGuiApplication::primaryScreen();
+ if (wasCreated)
+ create();
+}
+
void QWindow::showMinimized()
{
qDebug() << "unimplemented:" << __FILE__ << __LINE__;
@@ -486,7 +519,6 @@ void QWindow::hideEvent(QHideEvent *)
bool QWindow::event(QEvent *event)
{
- Q_D(QWindow);
switch (event->type()) {
case QEvent::MouseMove:
mouseMoveEvent(static_cast<QMouseEvent*>(event));
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 67330e5291..adf948b65e 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -71,6 +71,7 @@ class QWheelEvent;
class QPlatformSurface;
class QPlatformWindow;
class QBackingStore;
+class QScreen;
class Q_GUI_EXPORT QSurface
{
@@ -102,7 +103,8 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
public:
enum SurfaceType { RasterSurface, OpenGLSurface };
- QWindow(QWindow *parent = 0);
+ QWindow(QScreen *screen = 0);
+ QWindow(QWindow *parent);
virtual ~QWindow();
void setSurfaceType(SurfaceType surfaceType);
@@ -166,6 +168,9 @@ public:
bool setKeyboardGrabEnabled(bool grab);
bool setMouseGrabEnabled(bool grab);
+ QScreen *screen() const;
+ void setScreen(QScreen *screen);
+
public Q_SLOTS:
inline void show() { setVisible(true); }
inline void hide() { setVisible(false); }
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index cca20bc30a..2016c42d7e 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -68,6 +68,7 @@ public:
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
, modality(Qt::NonModal)
, transientParent(0)
+ , screen(0)
{
isWindow = true;
}
@@ -93,6 +94,7 @@ public:
Qt::WindowModality modality;
QPointer<QWindow> transientParent;
+ QScreen *screen;
};