diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-07-21 13:50:28 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-07-25 13:52:09 +0200 |
commit | c3da77798b876716ce038a30e9aa8517ec158c47 (patch) | |
tree | 99ac6cf5ce37fcb626a12857bb18cf9b444b27f2 /src/gui/kernel/qplatformscreen_qpa.cpp | |
parent | e80b6619524a3720efb5fbe4c2307bec25a12ab8 (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/qplatformscreen_qpa.cpp')
-rw-r--r-- | src/gui/kernel/qplatformscreen_qpa.cpp | 63 |
1 files changed, 61 insertions, 2 deletions
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(); } /*! |