diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-04-21 11:25:54 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-04-21 11:25:54 (GMT) |
commit | 6f5ad5dcab8e6f702894c4fa5c016d9837375626 (patch) | |
tree | 8951be47d1da0f836c461d0f844083f65880ebbb /src/plugins/platforms/fb_base | |
parent | 662eab575f3678364fbd3f317624fdd840e03c3c (diff) | |
parent | 66e4d48129d6baa405ed9a4a22b12913227a8c45 (diff) | |
download | Qt-6f5ad5dcab8e6f702894c4fa5c016d9837375626.zip Qt-6f5ad5dcab8e6f702894c4fa5c016d9837375626.tar.gz Qt-6f5ad5dcab8e6f702894c4fa5c016d9837375626.tar.bz2 |
Merge branch 'platform_window' into lighthouse
Conflicts:
src/gui/kernel/qplatformscreen_lite.h
src/plugins/platforms/fb_base/fb_base.cpp
src/plugins/platforms/fb_base/fb_base.h
src/plugins/platforms/linuxfb/main.cpp
src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp
src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h
src/plugins/platforms/testlite/qplatformintegration_testlite.cpp
src/plugins/platforms/vnc/main.cpp
src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp
src/plugins/platforms/vnc/qgraphicssystem_vnc.h
src/plugins/platforms/vnc/qvnccursor.cpp
src/plugins/platforms/vnc/qvnccursor.h
src/plugins/platforms/vnc/qvncserver.cpp
src/plugins/platforms/vnc/qvncserver.h
Diffstat (limited to 'src/plugins/platforms/fb_base')
-rw-r--r-- | src/plugins/platforms/fb_base/fb_base.cpp | 112 | ||||
-rw-r--r-- | src/plugins/platforms/fb_base/fb_base.h | 65 |
2 files changed, 124 insertions, 53 deletions
diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index a2a6609..f2009c1 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -81,7 +81,7 @@ void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget screen->setDirty(currentRect); } -QFbPlatformScreen::QFbPlatformScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) +QFbScreen::QFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) { mScreenImage = new QImage(mGeometry.size(), mFormat); redrawTimer.setSingleShot(true); @@ -89,7 +89,7 @@ QFbPlatformScreen::QFbPlatformScreen() : cursor(0), mGeometry(), mDepth(16), mFo QObject::connect(&redrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw())); } -void QFbPlatformScreen::setGeometry(QRect rect) +void QFbScreen::setGeometry(QRect rect) { delete mScreenImage; mGeometry = rect; @@ -99,17 +99,17 @@ void QFbPlatformScreen::setGeometry(QRect rect) invalidateRectCache(); } -void QFbPlatformScreen::setDepth(int depth) +void QFbScreen::setDepth(int depth) { mDepth = depth; } -void QFbPlatformScreen::setPhysicalSize(QSize size) +void QFbScreen::setPhysicalSize(QSize size) { mPhysicalSize = size; } -void QFbPlatformScreen::setFormat(QImage::Format format) +void QFbScreen::setFormat(QImage::Format format) { mFormat = format; delete mScreenImage; @@ -118,21 +118,23 @@ void QFbPlatformScreen::setFormat(QImage::Format format) compositePainter = 0; } -QFbPlatformScreen::~QFbPlatformScreen() +QFbScreen::~QFbScreen() { delete compositePainter; delete mScreenImage; } -void QFbPlatformScreen::setDirty(const QRect &rect) +void QFbScreen::setDirty(const QRect &rect) { + +// qDebug() << "QFbScreen::setDirty" << rect; repaintRegion += rect; if (!redrawTimer.isActive()) { redrawTimer.start(); } } -void QFbPlatformScreen::generateRects() +void QFbScreen::generateRects() { cachedRects.clear(); QRegion remainingScreen(mGeometry); @@ -140,7 +142,10 @@ void QFbPlatformScreen::generateRects() for (int i = 0; i < windowStack.length(); i++) { if (remainingScreen.isEmpty()) break; - if (!windowStack[i]->window()->testAttribute(Qt::WA_TranslucentBackground)) { + if (!windowStack[i]->visible()) + continue; + + if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) { remainingScreen -= windowStack[i]->geometry(); QRegion windowRegion(windowStack[i]->geometry()); windowRegion -= remainingScreen; @@ -157,7 +162,7 @@ void QFbPlatformScreen::generateRects() -QRegion QFbPlatformScreen::doRedraw() +QRegion QFbScreen::doRedraw() { QRegion touchedRegion; if (cursor) @@ -197,12 +202,13 @@ QRegion QFbPlatformScreen::doRedraw() for (int layerIndex = layer; layerIndex != -1; layerIndex--) { if (!windowStack[layerIndex]->visible()) continue; - if (windowStack[layerIndex]->window()->isMinimized()) + if (windowStack[layerIndex]->widget()->isMinimized()) continue; QRect windowRect = windowStack[layerIndex]->geometry(); QRect windowIntersect = rect.translated(-windowRect.left(), -windowRect.top()); - compositePainter->drawImage(rect, windowStack[layerIndex]->image(), +// qDebug() << " compositing" << layerIndex << windowStack[layerIndex]->surface->image().size(); + compositePainter->drawImage(rect, windowStack[layerIndex]->surface->image(), windowIntersect); if (firstLayer) { firstLayer = false; @@ -224,24 +230,29 @@ QRegion QFbPlatformScreen::doRedraw() touchedRegion += repaintRegion; repaintRegion = QRegion(); + + +// qDebug() << "QFbScreen::doRedraw" << windowStack.size() << mScreenImage->size() << touchedRegion; + + return touchedRegion; } -void QFbPlatformScreen::removeWindowSurface(QFbWindowSurface * surface) +void QFbScreen::removeWindow(QFbWindow * surface) { windowStack.removeOne(surface); invalidateRectCache(); setDirty(surface->geometry()); } -void QFbWindowSurface::raise() +void QFbWindow::raise() { mScreen->raise(this); } -void QFbPlatformScreen::raise(QWindowSurface * surface) +void QFbScreen::raise(QPlatformWindow * surface) { - QFbWindowSurface *s = static_cast<QFbWindowSurface *>(surface); + QFbWindow *s = static_cast<QFbWindow *>(surface); int index = windowStack.indexOf(s); if (index <= 0) return; @@ -250,14 +261,14 @@ void QFbPlatformScreen::raise(QWindowSurface * surface) setDirty(s->geometry()); } -void QFbWindowSurface::lower() +void QFbWindow::lower() { mScreen->lower(this); } -void QFbPlatformScreen::lower(QWindowSurface * surface) +void QFbScreen::lower(QPlatformWindow * surface) { - QFbWindowSurface *s = static_cast<QFbWindowSurface *>(surface); + QFbWindow *s = static_cast<QFbWindow *>(surface); int index = windowStack.indexOf(s); if (index == -1 || index == (windowStack.size() - 1)) return; @@ -266,32 +277,46 @@ void QFbPlatformScreen::lower(QWindowSurface * surface) setDirty(s->geometry()); } -QWidget * QFbPlatformScreen::topLevelAt(const QPoint & p) const +QWidget * QFbScreen::topLevelAt(const QPoint & p) const { for(int i = 0; i < windowStack.size(); i++) { if (windowStack[i]->geometry().contains(p, false) && windowStack[i]->visible() && - !windowStack[i]->window()->isMinimized()) { - return windowStack[i]->window(); + !windowStack[i]->widget()->isMinimized()) { + return windowStack[i]->widget(); } } return 0; } -QFbWindowSurface::QFbWindowSurface(QFbPlatformScreen *screen, QWidget *window) - : QWindowSurface(window), +QFbWindow::QFbWindow(QFbScreen *screen, QWidget *window) + :QPlatformWindow(window), mScreen(screen), visibleFlag(false) { static QAtomicInt winIdGenerator(1); + windowId = winIdGenerator.fetchAndAddRelaxed(1); +} + +QFbWindow::~QFbWindow() +{ + mScreen->removeWindow(this); +} + + +QFbWindowSurface::QFbWindowSurface(QFbScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen) +{ mImage = QImage(window->size(), mScreen->format()); - windowId = winIdGenerator.fetchAndAddRelaxed(1); + + platformWindow = static_cast<QFbWindow*>(window->platformWindow()); + platformWindow->surface = this; } QFbWindowSurface::~QFbWindowSurface() { - mScreen->removeWindowSurface(this); } void QFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) @@ -299,6 +324,16 @@ void QFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoin Q_UNUSED(widget); Q_UNUSED(offset); + +// qDebug() << "QFbWindowSurface::flush" << region; + + + platformWindow->repaint(region); +} + + +void QFbWindow::repaint(const QRegion ®ion) +{ QRect currentGeometry = geometry(); // If this is a move, redraw the previous location if (oldGeometry != currentGeometry) { @@ -314,19 +349,24 @@ void QFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoin mScreen->setDirty(dirtyRegion); } -void QFbWindowSurface::setGeometry(const QRect &rect) +void QFbWindowSurface::resize(const QSize &size) { - // store previous geometry for screen update + // change the widget's QImage if this is a resize + if (mImage.size() != size) + mImage = QImage(size, mScreen->format()); + QWindowSurface::resize(size); +} + +void QFbWindow::setGeometry(const QRect &rect) +{ +// store previous geometry for screen update oldGeometry = geometry(); - // change the widget's QImage if this is a resize - if (mImage.size() != rect.size()) - mImage = QImage(rect.size(), mScreen->format()); mScreen->invalidateRectCache(); - QWindowSystemInterface::handleGeometryChange(window(), rect); +//### QWindowSystemInterface::handleGeometryChange(window(), rect); - QWindowSurface::setGeometry(rect); + QPlatformWindow::setGeometry(rect); } bool QFbWindowSurface::scroll(const QRegion &area, int dx, int dy) @@ -344,21 +384,21 @@ void QFbWindowSurface::endPaint(const QRegion ®ion) Q_UNUSED(region); } -void QFbWindowSurface::setVisible(bool visible) +void QFbWindow::setVisible(bool visible) { visibleFlag = visible; mScreen->invalidateRectCache(); mScreen->setDirty(geometry()); } -Qt::WindowFlags QFbWindowSurface::setWindowFlags(Qt::WindowFlags type) +Qt::WindowFlags QFbWindow::setWindowFlags(Qt::WindowFlags type) { flags = type; mScreen->invalidateRectCache(); return flags; } -Qt::WindowFlags QFbWindowSurface::windowFlags() const +Qt::WindowFlags QFbWindow::windowFlags() const { return flags; } diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index fef769c..2b32209 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -1,18 +1,19 @@ #ifndef QLIGHTHOUSEGRAPHICSSCREEN_H #define QLIGHTHOUSEGRAPHICSSCREEN_H -#include <QtGui/QPlatformIntegration> #include <qrect.h> #include <qimage.h> #include <qtimer.h> #include <qpainter.h> -#include <QtGui/QGraphicsSystemCursor> +#include <QGraphicsSystemCursor> +#include <QPlatformScreen> +#include <QPlatformWindow> class QMouseEvent; class QSize; class QPainter; -class QFbPlatformScreen; +class QFbScreen; class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor { @@ -39,10 +40,12 @@ private: QRect getCurrentRect(); }; +class QFbWindow; + class QFbWindowSurface : public QWindowSurface { public: - QFbWindowSurface(QFbPlatformScreen *screen, QWidget *window); + QFbWindowSurface(QFbScreen *screen, QWidget *window); ~QFbWindowSurface(); virtual QPaintDevice *paintDevice() { return &mImage; } @@ -51,35 +54,62 @@ public: virtual void beginPaint(const QRegion ®ion); virtual void endPaint(const QRegion ®ion); - virtual void setVisible(bool visible); - virtual bool visible() { return visibleFlag; } + const QImage image() { return mImage; } - void setGeometry(const QRect &rect); + void resize(const QSize &size); + +protected: + friend class QFbWindow; + QFbWindow *platformWindow; + + QFbScreen *mScreen; + QImage mImage; +}; + + +class QFbWindow : public QPlatformWindow +{ +public: + + QFbWindow(QFbScreen *screen, QWidget *window); + ~QFbWindow(); + + + virtual void setVisible(bool visible); + virtual bool visible() { return visibleFlag; } virtual void raise(); virtual void lower(); + void setGeometry(const QRect &rect); + virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); virtual Qt::WindowFlags windowFlags() const; WId winId() const { return windowId; } + + virtual void repaint(const QRegion&); + protected: - QFbPlatformScreen *mScreen; + friend class QFbWindowSurface; + friend class QFbScreen; + QFbWindowSurface *surface; + QFbScreen *mScreen; QRect oldGeometry; - QImage mImage; bool visibleFlag; Qt::WindowFlags flags; + WId windowId; }; -class QFbPlatformScreen : public QPlatformScreen +class QFbScreen : public QPlatformScreen { Q_OBJECT public: - QFbPlatformScreen(); - ~QFbPlatformScreen(); + QFbScreen(); + ~QFbScreen(); virtual QRect geometry() const { return mGeometry; } virtual int depth() const { return mDepth; } @@ -93,18 +123,18 @@ public: virtual void setDirty(const QRect &rect); - virtual void removeWindowSurface(QFbWindowSurface * surface); - virtual void addWindowSurface(QFbWindowSurface * surface) { + virtual void removeWindow(QFbWindow * surface); + virtual void addWindow(QFbWindow * surface) { windowStack.prepend(surface); invalidateRectCache(); } - virtual void raise(QWindowSurface * surface); - virtual void lower(QWindowSurface * surface); + virtual void raise(QPlatformWindow * surface); + virtual void lower(QPlatformWindow * surface); virtual QWidget * topLevelAt(const QPoint & p) const; QImage * image() const { return mScreenImage; } QPaintDevice * paintDevice() const { return mScreenImage; } protected: - QList<QFbWindowSurface *> windowStack; + QList<QFbWindow *> windowStack; QRegion repaintRegion; QGraphicsSystemSoftwareCursor * cursor; QTimer redrawTimer; @@ -126,6 +156,7 @@ private: void invalidateRectCache() { isUpToDate = false; } friend class QFbWindowSurface; + friend class QFbWindow; bool isUpToDate; }; |