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 | |
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
-rw-r--r-- | src/gui/kernel/kernel.pri | 3 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_lite.cpp | 21 | ||||
-rw-r--r-- | src/gui/kernel/qdesktopwidget_lite.cpp | 43 | ||||
-rw-r--r-- | src/gui/kernel/qdesktopwidget_lite_p.h | 74 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration_lite.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_lite.cpp | 31 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/fb_base/fb_base.cpp | 61 | ||||
-rw-r--r-- | src/plugins/platforms/fb_base/fb_base.h | 7 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncintegration.cpp | 40 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncintegration.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncserver.cpp | 9 |
15 files changed, 264 insertions, 43 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 049637f..bc9e70c 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -50,7 +50,8 @@ HEADERS += \ kernel/qgesturemanager_p.h \ kernel/qsoftkeymanager_p.h \ kernel/qsoftkeymanager_common_p.h \ - kernel/qguiplatformplugin_p.h + kernel/qguiplatformplugin_p.h \ + kernel/qdesktopwidget_lite_p.h SOURCES += \ kernel/qaction.cpp \ diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 4b935ae..dd25cd4 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -63,6 +63,7 @@ #include <QWindowSystemInterface> #include <QPlatformIntegration> +#include "qdesktopwidget_lite_p.h" QT_BEGIN_NAMESPACE @@ -395,11 +396,16 @@ QWidget *QApplication::topLevelAt(const QPoint &pos) { QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - QPlatformScreen *screen = pi->screens().first(); - if (!screen) - return 0; - QWidget *w = screen->topLevelAt(pos); - return w; + QList<QPlatformScreen *> screens = pi->screens(); + QList<QPlatformScreen *>::const_iterator screen = screens.constBegin(); + QList<QPlatformScreen *>::const_iterator end = screens.constEnd(); + + while (screen != end) { + if ((*screen)->geometry().contains(pos)) + return (*screen)->topLevelAt(pos); + ++screen; + } + return 0; } void QApplication::beep() @@ -813,6 +819,7 @@ void QApplicationPrivate::reportScreenCount(int count) if (QCoreApplication::startingUp()) return; + QApplication::desktop()->d_func()->updateScreenList(); // signal anything listening for creation or deletion of screens QDesktopWidget *desktop = QApplication::desktop(); emit desktop->screenCountChanged(count); @@ -824,6 +831,8 @@ void QApplicationPrivate::reportGeometryChange(int screenIndex) if (QCoreApplication::startingUp()) return; + QApplication::desktop()->d_func()->updateScreenList(); + // signal anything listening for screen geometry changes QDesktopWidget *desktop = QApplication::desktop(); emit desktop->resized(screenIndex); @@ -845,6 +854,8 @@ void QApplicationPrivate::reportAvailableGeometryChange(int screenIndex) if (QCoreApplication::startingUp()) return; + QApplication::desktop()->d_func()->updateScreenList(); + // signal anything listening for screen geometry changes QDesktopWidget *desktop = QApplication::desktop(); emit desktop->workAreaResized(screenIndex); diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp index b077d57..3e37faf 100644 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -42,13 +42,43 @@ #include "qdesktopwidget.h" #include "private/qapplication_p.h" #include "private/qgraphicssystem_p.h" - +#include <QWidget> +#include "private/qwidget_p.h" +#include "private/qdesktopwidget_lite_p.h" QT_BEGIN_NAMESPACE QT_USE_NAMESPACE +void QDesktopWidgetPrivate::updateScreenList() +{ + QList<QPlatformScreen *> screenList = QApplicationPrivate::platformIntegration()->screens(); + int targetLength = screenList.length(); + int currentLength = screens.length(); + + // Add or remove screen widgets as necessary + if(currentLength > targetLength) { + QDesktopScreenWidget *screen; + while (currentLength-- > targetLength) { + screen = screens.takeLast(); + delete screen; + } + } + else if (currentLength < targetLength) { + QDesktopScreenWidget *screen; + while (currentLength < targetLength) { + screen = new QDesktopScreenWidget(currentLength++); + screens.append(screen); + } + } + + // update the geometry of each screen widget + for (int i = 0; i < screens.length(); i++) { + screens.at(i)->setGeometry(screenList.at(i)->geometry()); + } +} + QDesktopWidget::QDesktopWidget() - : QWidget(0, Qt::Desktop) + : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop) { setObjectName(QLatin1String("desktop")); } @@ -59,7 +89,7 @@ QDesktopWidget::~QDesktopWidget() bool QDesktopWidget::isVirtualDesktop() const { - return true; + return QApplicationPrivate::platformIntegration()->isVirtualDesktop(); } int QDesktopWidget::primaryScreen() const @@ -73,9 +103,12 @@ int QDesktopWidget::numScreens() const return qMax(pi->screens().size(), 1); } -QWidget *QDesktopWidget::screen(int) +QWidget *QDesktopWidget::screen(int screen) { - return this; + Q_D(QDesktopWidget); + if (screen < 0 || screen >= d->screens.length()) + return d->screens.at(0); + return d->screens.at(screen); } const QRect QDesktopWidget::availableGeometry(int screenNo) const diff --git a/src/gui/kernel/qdesktopwidget_lite_p.h b/src/gui/kernel/qdesktopwidget_lite_p.h new file mode 100644 index 0000000..c04e172 --- /dev/null +++ b/src/gui/kernel/qdesktopwidget_lite_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QDESKTOPWIDGET_LITE_P_H +#define QDESKTOPWIDGET_LITE_P_H + +#include "QDesktopWidget" +#include "private/qwidget_p.h" + +class QDesktopScreenWidget : public QWidget { + Q_OBJECT +public: + QDesktopScreenWidget(int screenNumber) { setWindowFlags(Qt::Desktop); setVisible(false); d_func()->screenNumber = screenNumber; } +}; + +class QDesktopWidgetPrivate : public QWidgetPrivate { +public: + QDesktopWidgetPrivate() { updateScreenList(); } + ~QDesktopWidgetPrivate() {foreach(QDesktopScreenWidget *s, screens) delete s; } + void updateScreenList(); + + QList<QDesktopScreenWidget *> screens; +}; + +#endif // QDESKTOPWIDGET_LITE_P_H diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index a509b52..aa71c3d 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -66,9 +66,11 @@ public: virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0; virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const = 0; virtual QBlittable *createBlittable(const QSize &size) const; + virtual void moveToScreen(QWidget *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);} // Window System functions virtual QList<QPlatformScreen *> screens() const = 0; + virtual bool isVirtualDesktop() { return false; } virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; // OpenGL Integration functions diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 2c9730b..611bd50 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -211,6 +211,8 @@ QWidgetPrivate::QWidgetPrivate(int version) , hasAlienChildren(0) , window_event(0) , qd_hd(0) +#elif defined (Q_WS_LITE) + , screenNumber(0) #endif { if (!qApp) { @@ -1154,6 +1156,12 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) // programmer specified desktop widget xinfo = desktopWidget->d_func()->xinfo; } +#elif defined(Q_WS_LITE) + if (desktopWidget) { + int screen = desktopWidget->d_func()->screenNumber; + QPlatformIntegration *platform = QApplicationPrivate::platformIntegration(); + platform->moveToScreen(q, screen); + } #else Q_UNUSED(desktopWidget); #endif diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 7dff703..598e877 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -629,6 +629,7 @@ public: #if defined(Q_WS_LITE) void setPlatformWindow(QPlatformWindow *window); QPlatformWindow *platformWindow() const; + friend class QDesktopScreenWidget; #endif Q_SIGNALS: diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index d281bec..25cd0f6 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -85,6 +85,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO setWinId(q->platformWindow()->winId()); + QApplicationPrivate::platformIntegration()->moveToScreen(q, screenNumber); // qDebug() << "create_sys" << q << q->internalWinId(); } @@ -119,14 +120,31 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) { Q_Q(QWidget); -// QWidget *oldParent = q->parentWidget(); + + // QWidget *oldParent = q->parentWidget(); Qt::WindowFlags oldFlags = data.window_flags; + + int targetScreen = -1; + // Handle a request to move the widget to a particular screen + if (newparent && newparent->windowType() == Qt::Desktop) { + // make sure the widget is created on the same screen as the + // programmer specified desktop widget + + // get the desktop's screen number + targetScreen = newparent->d_func()->screenNumber; + newparent = 0; + } + if (parent != newparent) { QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? - } + if (!newparent) { f |= Qt::Window; + if (targetScreen == -1) { + if (parent) + targetScreen = qobject_cast<QWidget *>(parent)->d_func()->screenNumber; + } } bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); @@ -153,6 +171,15 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) q->setAttribute(Qt::WA_WState_Hidden); q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); + // move the window to the selected screen + if (!newparent && targetScreen != -1) { + screenNumber = targetScreen; + // only if it is already created + if (q->testAttribute(Qt::WA_WState_Created)) { + QPlatformIntegration *platform = QApplicationPrivate::platformIntegration(); + platform->moveToScreen(q, targetScreen); + } + } } QPoint QWidget::mapToGlobal(const QPoint &pos) const diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index b5376a4..e0b8a67 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -815,6 +815,8 @@ public: #elif defined(Q_WS_LITE) void setMaxWindowState_helper(); void setFullScreenSize_helper(); + + int screenNumber; // screen the widget should be displayed on #ifndef QT_NO_CURSOR void updateCursor() const; #endif diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 88d6475..614f983 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -105,7 +105,7 @@ public: class UserEvent { public: UserEvent(QWidget * w, ulong time, QEvent::Type t) - { widget = QWeakPointer<QWidget>::QWeakPointer(w); type = t; timestamp = time; } + { widget = QWeakPointer<QWidget>(w); type = t; timestamp = time; } QWeakPointer<QWidget> widget; QEvent::Type type; unsigned long timestamp; 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; diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 69aea79..de6d81f 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -50,7 +50,6 @@ #include <QtCore/QTimer> - QVNCScreen::QVNCScreen(QRect screenSize, int screenId) : QFbScreen::QFbScreen() { @@ -99,6 +98,8 @@ QVNCIntegration::QVNCIntegration(const QStringList& paramList) { int sizeX = defaultWidth(); int sizeY = defaultHeight(); + int offsetX = 0; + int offsetY = 0; int display = defaultDisplay(); bool showUsage = false; @@ -111,6 +112,19 @@ QVNCIntegration::QVNCIntegration(const QStringList& paramList) else if (confString.startsWith(QLatin1String("display="))) { display = confString.section(QLatin1Char('='), 1, 1).toInt(); } + else if (confString.startsWith(QLatin1String("offset="))) { + QString val = confString.section(QLatin1Char('='), 1, 1); + offsetX = val.section(QLatin1Char('x'), 0, 0).toInt(); + offsetY = val.section(QLatin1Char('x'), 1, 1).toInt(); + } + else if (confString == QLatin1String("vnc")) { + QRect screenRect(offsetX, offsetY, sizeX, sizeY); + QVNCScreen *screen = new QVNCScreen(screenRect, display); + mScreens.append(screen); + screen->setObjectName(QString("screen %1").arg(display)); + screen->setDirty(screenRect); + ++display; + } else { qWarning() << "Unknown VNC option:" << confString; showUsage = true; @@ -120,9 +134,12 @@ QVNCIntegration::QVNCIntegration(const QStringList& paramList) if (showUsage) usage(); - mPrimaryScreen = new QVNCScreen(QRect(0, 0, sizeX, sizeY), display); - - mScreens.append(mPrimaryScreen); + QRect screenRect(offsetX, offsetY, sizeX, sizeY); + QVNCScreen *screen = new QVNCScreen(screenRect, display); + mScreens.append(screen); + mPrimaryScreen = qobject_cast<QVNCScreen *>(mScreens.first()); + screen->setObjectName(QString("screen %1").arg(display)); + screen->setDirty(screenRect); } QPixmapData *QVNCIntegration::createPixmapData(QPixmapData::PixelType type) const @@ -155,3 +172,18 @@ QPlatformWindow *QVNCIntegration::createPlatformWindow(QWidget *widget, WId /*wi return w; } +void QVNCIntegration::moveToScreen(QWidget *window, int screen) +{ + if (screen < 0 || screen > mScreens.size()) + return; + QVNCScreen * newScreen = qobject_cast<QVNCScreen *>(mScreens.at(screen)); + for(int i = 0; i < mScreens.size(); i++) { + QVNCScreen *oldScreen = qobject_cast<QVNCScreen *>(mScreens.at(i)); + if (oldScreen->windowStack.contains(static_cast<QFbWindow *>(window->platformWindow()))) { + oldScreen->removeWindow(static_cast<QFbWindow *>(window->platformWindow())); + break; + } + } + window->platformWindow()->setGeometry(window->geometry()); // this should be unified elsewhere + newScreen->addWindow(static_cast<QFbWindow *>(window->platformWindow())); +} diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h index dcb5419..3436e51 100644 --- a/src/plugins/platforms/vnc/qvncintegration.h +++ b/src/plugins/platforms/vnc/qvncintegration.h @@ -55,6 +55,7 @@ class QVNCScreenPrivate; class QVNCScreen : public QFbScreen { + Q_OBJECT public: QVNCScreen(QRect screenSize, int screenId); @@ -68,6 +69,7 @@ public: private: QVNCServer *server; QRegion doRedraw(); + friend class QVNCIntegration; }; class QVNCIntegrationPrivate; @@ -84,6 +86,7 @@ public: QList<QPlatformScreen *> screens() const { return mScreens; } + void moveToScreen(QWidget *window, int screen); private: QVNCScreen *mPrimaryScreen; diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp index 6424083..fb6eaa8 100644 --- a/src/plugins/platforms/vnc/qvncserver.cpp +++ b/src/plugins/platforms/vnc/qvncserver.cpp @@ -831,14 +831,13 @@ static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::Mo void QVNCServer::pointerEvent() { + QPoint screenOffset = this->screen()->geometry().topLeft(); + QRfbPointerEvent ev; if (ev.read(client)) { -// const QPoint offset = qvnc_screen->offset(); -// QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons); - QPoint eventPoint(ev.x, ev.y); - eventPoint += screen()->geometry().topLeft(); - //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; + eventPoint += screenOffset; // local to global translation + if (ev.wheelDirection == ev.WheelNone) { QEvent::Type type = QEvent::MouseMove; Qt::MouseButton button = Qt::NoButton; |