diff options
author | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-04-12 13:21:35 (GMT) |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-04-12 16:31:22 (GMT) |
commit | 80c3790501df2ce3a8edf022e469317bc6f66246 (patch) | |
tree | 49af67ebb865701db9b46e500505fd16bca11318 /src/plugins/platforms/fb_base | |
parent | 1d768c1deb98a8e32cdbd7790186e1d6a81acc29 (diff) | |
download | Qt-80c3790501df2ce3a8edf022e469317bc6f66246.zip Qt-80c3790501df2ce3a8edf022e469317bc6f66246.tar.gz Qt-80c3790501df2ce3a8edf022e469317bc6f66246.tar.bz2 |
Make the VNC plugin compile and largely work
Diffstat (limited to 'src/plugins/platforms/fb_base')
-rw-r--r-- | src/plugins/platforms/fb_base/fb_base.cpp | 98 | ||||
-rw-r--r-- | src/plugins/platforms/fb_base/fb_base.h | 58 |
2 files changed, 117 insertions, 39 deletions
diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index d30746a..422222c 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -6,7 +6,7 @@ #include <QGraphicsSystemCursor> #include <QWindowSystemInterface> -QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr) +QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QPlatformScreen *scr) : QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect()) { graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); @@ -126,6 +126,8 @@ QGraphicsSystemFbScreen::~QGraphicsSystemFbScreen() void QGraphicsSystemFbScreen::setDirty(const QRect &rect) { + +// qDebug() << "QGraphicsSystemFbScreen::setDirty" << rect; repaintRegion += rect; if (!redrawTimer.isActive()) { redrawTimer.start(); @@ -140,7 +142,7 @@ void QGraphicsSystemFbScreen::generateRects() for (int i = 0; i < windowStack.length(); i++) { if (remainingScreen.isEmpty()) break; - if (!windowStack[i]->window()->testAttribute(Qt::WA_TranslucentBackground)) { + if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) { remainingScreen -= windowStack[i]->geometry(); QRegion windowRegion(windowStack[i]->geometry()); windowRegion -= remainingScreen; @@ -197,12 +199,13 @@ QRegion QGraphicsSystemFbScreen::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 +227,29 @@ QRegion QGraphicsSystemFbScreen::doRedraw() touchedRegion += repaintRegion; repaintRegion = QRegion(); + + +// qDebug() << "QGraphicsSystemFbScreen::doRedraw" << windowStack.size() << mScreenImage->size() << touchedRegion; + + return touchedRegion; } -void QGraphicsSystemFbScreen::removeWindowSurface(QGraphicsSystemFbWindowSurface * surface) +void QGraphicsSystemFbScreen::removeWindow(QFbWindow * surface) { windowStack.removeOne(surface); invalidateRectCache(); setDirty(surface->geometry()); } -void QGraphicsSystemFbWindowSurface::raise() +void QFbWindow::raise() { mScreen->raise(this); } -void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) +void QGraphicsSystemFbScreen::raise(QPlatformWindow * surface) { - QGraphicsSystemFbWindowSurface *s = static_cast<QGraphicsSystemFbWindowSurface *>(surface); + QFbWindow *s = static_cast<QFbWindow *>(surface); int index = windowStack.indexOf(s); if (index <= 0) return; @@ -250,14 +258,14 @@ void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) setDirty(s->geometry()); } -void QGraphicsSystemFbWindowSurface::lower() +void QFbWindow::lower() { mScreen->lower(this); } -void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) +void QGraphicsSystemFbScreen::lower(QPlatformWindow * surface) { - QGraphicsSystemFbWindowSurface *s = static_cast<QGraphicsSystemFbWindowSurface *>(surface); + QFbWindow *s = static_cast<QFbWindow *>(surface); int index = windowStack.indexOf(s); if (index == -1 || index == (windowStack.size() - 1)) return; @@ -271,34 +279,61 @@ QWidget * QGraphicsSystemFbScreen::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; } -QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window) - : QWindowSurface(window), + + +QFbWindow::QFbWindow(QGraphicsSystemFbScreen *screen, QWidget *window) + :QPlatformWindow(window), mScreen(screen), visibleFlag(false) { static QAtomicInt winIdGenerator(1); + windowId = winIdGenerator.fetchAndAddRelaxed(1); +} + + +QFbWindow::~QFbWindow() +{ + mScreen->removeWindow(this); +} + +QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *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; } QGraphicsSystemFbWindowSurface::~QGraphicsSystemFbWindowSurface() { - mScreen->removeWindowSurface(this); } + void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); Q_UNUSED(offset); + +// qDebug() << "QGraphicsSystemFbWindowSurface::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,21 +349,30 @@ void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®io mScreen->setDirty(dirtyRegion); } -void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect) +void QGraphicsSystemFbWindowSurface::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 QGraphicsSystemFbWindowSurface::scroll(const QRegion &area, int dx, int dy) { return QWindowSurface::scroll(area, dx, dy); @@ -344,21 +388,21 @@ void QGraphicsSystemFbWindowSurface::endPaint(const QRegion ®ion) Q_UNUSED(region); } -void QGraphicsSystemFbWindowSurface::setVisible(bool visible) +void QFbWindow::setVisible(bool visible) { visibleFlag = visible; mScreen->invalidateRectCache(); mScreen->setDirty(geometry()); } -Qt::WindowFlags QGraphicsSystemFbWindowSurface::setWindowFlags(Qt::WindowFlags type) +Qt::WindowFlags QFbWindow::setWindowFlags(Qt::WindowFlags type) { flags = type; mScreen->invalidateRectCache(); return flags; } -Qt::WindowFlags QGraphicsSystemFbWindowSurface::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 7f9b005..8df6b8e 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -1,12 +1,14 @@ #ifndef QLIGHTHOUSEGRAPHICSSCREEN_H #define QLIGHTHOUSEGRAPHICSSCREEN_H -#include <QtGui/private/qgraphicssystem_p.h> +//#include <QtGui/private/qgraphicssystem_p.h> #include <qrect.h> #include <qimage.h> #include <qtimer.h> #include <qpainter.h> #include <QGraphicsSystemCursor> +#include <QPlatformScreen> +#include <QPlatformWindow> class QMouseEvent; class QSize; @@ -17,7 +19,7 @@ class QGraphicsSystemFbScreen; class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor { public: - QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen * scr); + QGraphicsSystemSoftwareCursor(QPlatformScreen * scr); // output methods QRect dirtyRect(); @@ -39,6 +41,9 @@ private: QRect getCurrentRect(); }; + +class QFbWindow; + class QGraphicsSystemFbWindowSurface : public QWindowSurface { public: @@ -51,30 +56,58 @@ 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; + + QGraphicsSystemFbScreen *mScreen; + QImage mImage; +}; + + +class QFbWindow : public QPlatformWindow +{ +public: + + QFbWindow(QGraphicsSystemFbScreen *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: + friend class QGraphicsSystemFbWindowSurface; + friend class QGraphicsSystemFbScreen; + QGraphicsSystemFbWindowSurface *surface; QGraphicsSystemFbScreen *mScreen; QRect oldGeometry; - QImage mImage; bool visibleFlag; Qt::WindowFlags flags; + WId windowId; }; -class QGraphicsSystemFbScreen : public QGraphicsSystemScreen + +class QGraphicsSystemFbScreen : public QPlatformScreen { Q_OBJECT public: @@ -93,18 +126,18 @@ public: virtual void setDirty(const QRect &rect); - virtual void removeWindowSurface(QGraphicsSystemFbWindowSurface * surface); - virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * 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<QGraphicsSystemFbWindowSurface *> windowStack; + QList<QFbWindow *> windowStack; QRegion repaintRegion; QGraphicsSystemSoftwareCursor * cursor; QTimer redrawTimer; @@ -126,6 +159,7 @@ private: void invalidateRectCache() { isUpToDate = false; } friend class QGraphicsSystemFbWindowSurface; + friend class QFbWindow; bool isUpToDate; }; |