From c3da77798b876716ce038a30e9aa8517ec158c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 21 Jul 2011 13:50:28 +0200 Subject: Added workable QScreen API on top of QPlatformScreen. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jørgen Lind --- src/gui/kernel/qplatformscreen_qpa.cpp | 63 ++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'src/gui/kernel/qplatformscreen_qpa.cpp') 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 #include #include +#include #include +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. @@ -63,6 +102,26 @@ QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const return 0; } +/*! + 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::virtualSiblings() const +{ + QList list; + list << const_cast(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 @@ -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(); } /*! -- cgit v1.2.3