diff options
author | Jeremy Katz <jeremy.katz@nokia.com> | 2010-06-11 10:50:27 (GMT) |
---|---|---|
committer | Jeremy Katz <jeremy.katz@nokia.com> | 2010-06-11 10:50:27 (GMT) |
commit | a498db43a02972e90df5f1cdd73e90260471f5f8 (patch) | |
tree | 1d8fe5409fe68eaf898ad54de87ce814669c836a /src/plugins/platforms/fb_base | |
parent | 28547949cc78d25884a76bf3c2112a6217ba5b66 (diff) | |
download | Qt-a498db43a02972e90df5f1cdd73e90260471f5f8.zip Qt-a498db43a02972e90df5f1cdd73e90260471f5f8.tar.gz Qt-a498db43a02972e90df5f1cdd73e90260471f5f8.tar.bz2 |
litehouse multiscreen support
This commit adds QPlatformIntegration::moveToScreen(), which requests that
a widget be moved to another screen. The default implementation ignores the
request.
The VNC plugin has been updated accordingly. It currently only supports
non-virtual desktops.
Review by: Jørgen
Diffstat (limited to 'src/plugins/platforms/fb_base')
-rw-r--r-- | src/plugins/platforms/fb_base/fb_base.cpp | 61 | ||||
-rw-r--r-- | src/plugins/platforms/fb_base/fb_base.h | 7 |
2 files changed, 48 insertions, 20 deletions
diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index cdcb608..0463a60 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -18,6 +18,8 @@ QRect QGraphicsSystemSoftwareCursor::getCurrentRect() QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(), -graphic->hotspot().y()); rect.translate(QCursor::pos()); + QPoint screenOffset = screen->geometry().topLeft(); + rect.translate(-screenOffset); // global to local translation return rect; } @@ -25,8 +27,12 @@ QRect QGraphicsSystemSoftwareCursor::getCurrentRect() void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e) { Q_UNUSED(e); + QPoint screenOffset = screen->geometry().topLeft(); currentRect = getCurrentRect(); - setDirty(); + // global to local translation + if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset))) { + setDirty(); + } } QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) @@ -35,7 +41,10 @@ QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) if (currentRect.isNull()) return QRect(); - if (!currentRect.intersects(screen->geometry())) + // We need this because the cursor might be dirty due to moving off screen + QPoint screenOffset = screen->geometry().topLeft(); + // global to local translation + if (!currentRect.translated(screenOffset).intersects(screen->geometry())) return QRect(); prevRect = currentRect; @@ -82,7 +91,9 @@ void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget setCursor(shape); } currentRect = getCurrentRect(); - setDirty(); + QPoint screenOffset = screen->geometry().topLeft(); // global to local translation + if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset))) + setDirty(); } QFbScreen::QFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) @@ -130,7 +141,9 @@ QFbScreen::~QFbScreen() void QFbScreen::setDirty(const QRect &rect) { - repaintRegion += rect; + QRect intersection = rect.intersected(mGeometry); + QPoint screenOffset = mGeometry.topLeft(); + repaintRegion += intersection.translated(-screenOffset); // global to local translation if (!redrawTimer.isActive()) { redrawTimer.start(); } @@ -139,7 +152,8 @@ void QFbScreen::setDirty(const QRect &rect) void QFbScreen::generateRects() { cachedRects.clear(); - QRegion remainingScreen(mGeometry); + QPoint screenOffset = mGeometry.topLeft(); + QRegion remainingScreen(mGeometry.translated(-screenOffset)); // global to local translation for (int i = 0; i < windowStack.length(); i++) { if (remainingScreen.isEmpty()) @@ -148,8 +162,8 @@ void QFbScreen::generateRects() continue; if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) { - remainingScreen -= windowStack[i]->geometry(); - QRegion windowRegion(windowStack[i]->geometry()); + remainingScreen -= windowStack[i]->localGeometry(); + QRegion windowRegion(windowStack[i]->localGeometry()); windowRegion -= remainingScreen; foreach(QRect rect, windowRegion.rects()) { cachedRects += QPair<QRect, int>(rect, i); @@ -166,11 +180,16 @@ void QFbScreen::generateRects() QRegion QFbScreen::doRedraw() { + QPoint screenOffset = mGeometry.topLeft(); // optimize me! + QRegion touchedRegion; - if (cursor && cursor->isDirty() && cursor->isOnScreen()) - repaintRegion += cursor->dirtyRect(); - if (repaintRegion.isEmpty() && !cursor->isDirty()) + if (cursor && cursor->isDirty() && cursor->isOnScreen()) { + QRect lastCursor = cursor->dirtyRect(); + repaintRegion += lastCursor; + } + if (repaintRegion.isEmpty() && !cursor->isDirty()) { return touchedRegion; + } QVector<QRect> rects = repaintRegion.rects(); @@ -206,10 +225,9 @@ QRegion QFbScreen::doRedraw() continue; if (windowStack[layerIndex]->widget()->isMinimized()) continue; - QRect windowRect = windowStack[layerIndex]->geometry(); + QRect windowRect = windowStack[layerIndex]->geometry().translated(-screenOffset); QRect windowIntersect = rect.translated(-windowRect.left(), - -windowRect.top()); -// qDebug() << " compositing" << layerIndex << windowStack[layerIndex]->surface->image().size(); + -windowRect.top()); compositePainter->drawImage(rect, windowStack[layerIndex]->surface->image(), windowIntersect); if (firstLayer) { @@ -218,10 +236,6 @@ QRegion QFbScreen::doRedraw() } } } - if (!rectRegion.isEmpty()) - qWarning() << "non-empty region!" << rectRegion; - // Everything on screen should be mapped to a sub-rectangle - // unless it's off the screen... } QRect cursorRect; @@ -240,6 +254,16 @@ QRegion QFbScreen::doRedraw() return touchedRegion; } +void QFbScreen::addWindow(QFbWindow *surface) +{ + windowStack.prepend(surface); + surface->mScreen = this; + QPoint screenOffset = mGeometry.topLeft(); + surface->localGeometry() = surface->geometry().translated(-screenOffset); // global to local translation + invalidateRectCache(); + setDirty(surface->geometry()); +} + void QFbScreen::removeWindow(QFbWindow * surface) { windowStack.removeOne(surface); @@ -369,6 +393,9 @@ void QFbWindow::setGeometry(const QRect &rect) //### QWindowSystemInterface::handleGeometryChange(window(), rect); QPlatformWindow::setGeometry(rect); + + QPoint screenOffset = mScreen->geometry().topLeft(); + mLocalGeometry = rect.translated(-screenOffset); // global to local translation } bool QFbWindowSurface::scroll(const QRegion &area, int dx, int dy) diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index d94462d..f1dd574 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -98,6 +98,8 @@ public: virtual void repaint(const QRegion&); + virtual QRect localGeometry() { return mLocalGeometry; } + protected: friend class QFbWindowSurface; friend class QFbScreen; @@ -106,7 +108,7 @@ protected: QRect oldGeometry; bool visibleFlag; Qt::WindowFlags flags; - + QRect mLocalGeometry; // local screen coordinates WId windowId; }; @@ -131,8 +133,7 @@ public: virtual void setDirty(const QRect &rect); virtual void removeWindow(QFbWindow * surface); - virtual void addWindow(QFbWindow * surface) { - windowStack.prepend(surface); invalidateRectCache(); } + virtual void addWindow(QFbWindow * surface); virtual void raise(QPlatformWindow * surface); virtual void lower(QPlatformWindow * surface); virtual QWidget * topLevelAt(const QPoint & p) const; |