summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeremy Katz <jeremy.katz@nokia.com>2009-10-14 11:45:21 (GMT)
committerJeremy Katz <jeremy.katz@nokia.com>2009-10-14 14:27:28 (GMT)
commit7750f3821c7cd526c33bfa09378378da3980a2e6 (patch)
treeab13db332dc17d8bdccea953fb363672323caebf /src
parent1dcdfda53128e745edc3aaa16e659c273cc77cd7 (diff)
downloadQt-7750f3821c7cd526c33bfa09378378da3980a2e6.zip
Qt-7750f3821c7cd526c33bfa09378378da3980a2e6.tar.gz
Qt-7750f3821c7cd526c33bfa09378378da3980a2e6.tar.bz2
basic support for multiple top level windows in the VNC backend
This supports a simple stack of windows, with the most recently created sitting on top.
Diffstat (limited to 'src')
-rw-r--r--src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp28
-rw-r--r--src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h7
-rw-r--r--src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp32
-rw-r--r--src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h3
4 files changed, 59 insertions, 11 deletions
diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp
index 9a7c198..b50e5b5 100644
--- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp
+++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp
@@ -45,6 +45,7 @@
#include <QtCore/qdebug.h>
#include <qvncserver.h>
+#include <QtGui/QPainter>
@@ -77,6 +78,23 @@ QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap()
void QVNCGraphicsSystemScreen::setDirty(const QRect &rect)
{
+ QPainter compositePainter(mScreenImage);
+
+ // Blank the affected area, just in case there's nothing to display here
+ // Question - What's the background color?
+ // Another option would be to push a base level window that is the size of the display
+
+ compositePainter.fillRect(rect, Qt::black);
+
+ for (int i = 0; i < windowStack.length(); i++) {
+ QRect windowRect = windowStack[i]->geometry();
+ QRect intersect = windowRect.intersected(rect);
+ QRect windowIntersect = intersect.translated(-windowRect.left(),
+ -windowRect.top());
+ compositePainter.drawImage(intersect, windowStack[i]->image(),
+ windowIntersect);
+ }
+
d_ptr->setDirty(rect);
}
@@ -104,6 +122,14 @@ QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const
{
if (widget->windowType() == Qt::Desktop)
return 0; // Don't create an explicit window surface for the destkop.
- return new QVNCWindowSurface
+ QVNCWindowSurface * newSurface = new QVNCWindowSurface
(const_cast<QVNCGraphicsSystem *>(this), mPrimaryScreen, widget);
+ mPrimaryScreen->addWindowSurface(newSurface);
+ return newSurface;
+}
+
+void QVNCGraphicsSystemScreen::removeWindowSurface(QVNCWindowSurface * surface)
+{
+ windowStack.removeOne(surface);
+ setDirty(surface->geometry());
}
diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h
index 375b467..d593096 100644
--- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h
+++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h
@@ -43,6 +43,7 @@
#define QGRAPHICSSYSTEM_VNC_H
#include <QtGui/private/qgraphicssystem_p.h>
+#include "qwindowsurface_vnc.h"
QT_BEGIN_NAMESPACE
@@ -68,6 +69,9 @@ public:
void setDirty(const QRect &rect);
+ void removeWindowSurface(QVNCWindowSurface * surface);
+ void addWindowSurface(QVNCWindowSurface * surface) { windowStack.append(surface); }
+
public:
QRect mGeometry;
int mDepth;
@@ -77,6 +81,8 @@ public:
QVNCServer *server;
QVNCGraphicsSystemScreenPrivate *d_ptr;
+private:
+ QList<QVNCWindowSurface *> windowStack;
};
class QVNCGraphicsSystemPrivate;
@@ -92,6 +98,7 @@ public:
QList<QGraphicsSystemScreen *> screens() const { return mScreens; }
+
private:
QVNCGraphicsSystemScreen *mPrimaryScreen;
QList<QGraphicsSystemScreen *> mScreens;
diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp
index 07668fb..af171f5 100644
--- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp
+++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp
@@ -53,15 +53,17 @@ QVNCWindowSurface::QVNCWindowSurface(QVNCGraphicsSystem *graphicsSystem,
: QWindowSurface(window),
mScreen(screen)
{
+ mImage = QImage(window->size(), mScreen->format());
}
QVNCWindowSurface::~QVNCWindowSurface()
{
+ mScreen->removeWindowSurface(this);
}
QPaintDevice *QVNCWindowSurface::paintDevice()
{
- return mScreen->mScreenImage;
+ return &mImage;
}
void QVNCWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
@@ -69,20 +71,30 @@ void QVNCWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoi
Q_UNUSED(widget);
Q_UNUSED(offset);
- QRect rect = geometry();
- QPoint topLeft = rect.topLeft();
-
- mScreen->setDirty(region.boundingRect());
- // server->flush(region);
-
+ QRect currentGeometry = geometry();
+ // If this is a move, redraw the previous location
+ if (oldGeometry != currentGeometry) {
+ mScreen->setDirty(oldGeometry);
+ oldGeometry = currentGeometry;
+ }
+
+ QRect dirtyClient = region.boundingRect();
+ QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(),
+ currentGeometry.top() + dirtyClient.top(),
+ dirtyClient.width(),
+ dirtyClient.height());
+ mScreen->setDirty(dirtyRegion);
}
-void QVNCWindowSurface::setGeometry(const QRect &)
+void QVNCWindowSurface::setGeometry(const QRect &rect)
{
+ // store previous geometry for screen update
+ oldGeometry = geometry();
-// any size you like as long as it's full-screen...
+ // change the widget's QImage if this is a resize
+ if (mImage.size() != rect.size())
+ mImage = QImage(rect.size(), mScreen->format());
- QRect rect(mScreen->availableGeometry());
QApplicationPrivate::handleGeometryChange(this->window(), rect);
QWindowSurface::setGeometry(rect);
diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h
index 3fd1f12..b9af493 100644
--- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h
+++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h
@@ -64,10 +64,13 @@ public:
void beginPaint(const QRegion &region);
void endPaint(const QRegion &region);
+ inline const QImage image() { return mImage; }
private:
QVNCGraphicsSystem *mGraphicsSystem;
QVNCGraphicsSystemScreen *mScreen;
+ QRect oldGeometry;
+ QImage mImage;
};
QT_END_NAMESPACE