diff options
author | Kevin Krammer <kevin.krammer.qnx@kdab.com> | 2012-04-03 10:34:42 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-04 12:51:35 (GMT) |
commit | d4858c581eaf23c57577dc7e12b48f392ed0463f (patch) | |
tree | 2e759019f4cd45bed705c5e1397baea40560e5fe | |
parent | cd626dad3e92475c2a8f6a894046a14c95711d50 (diff) | |
download | Qt-d4858c581eaf23c57577dc7e12b48f392ed0463f.zip Qt-d4858c581eaf23c57577dc7e12b48f392ed0463f.tar.gz Qt-d4858c581eaf23c57577dc7e12b48f392ed0463f.tar.bz2 |
Move handling of rotation changes from event handler to screen
Have the navigator event handler emit the new rotation as a signal argument
and let the screen class handle all parts of the change, i.e. also notifying
the window system about the geometry change.
This also allows to rotate all screens, not just the primary screen, if this
should be necessary.
Backport of 45b7b0599cd1ebdfe17487215b36ff766068f0e8
Change-Id: Ia3e3ff321bc2d7a23e64950d15d88d007f9766dd
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
5 files changed, 25 insertions, 20 deletions
diff --git a/src/plugins/platforms/blackberry/qbbintegration.cpp b/src/plugins/platforms/blackberry/qbbintegration.cpp index 76a47dc..4482e8e 100644 --- a/src/plugins/platforms/blackberry/qbbintegration.cpp +++ b/src/plugins/platforms/blackberry/qbbintegration.cpp @@ -99,22 +99,20 @@ QBBIntegration::QBBIntegration() : qFatal("QBB: failed to connect to composition manager, errno=%d", errno); } - // Create displays for all possible screens (which may not be attached) - createDisplays(); - - // create/start event thread - mEventThread = new QBBEventThread(mContext, mScreenEventHandler); - mEventThread->start(); - // Create/start navigator event handler // Not on BlackBerry, it has specialised event dispatcher which also handles navigator events -#ifndef Q_OS_BLACKBERRY - mNavigatorEventHandler = new QBBNavigatorEventHandler(*primaryDisplay()); + mNavigatorEventHandler = new QBBNavigatorEventHandler; // delay invocation of start() to the time the event loop is up and running // needed to have the QThread internals of the main thread properly initialized QMetaObject::invokeMethod(mNavigatorEventHandler, "start", Qt::QueuedConnection); -#endif + + // Create displays for all possible screens (which may not be attached) + createDisplays(); + + // create/start event thread + mEventThread = new QBBEventThread(mContext, mScreenEventHandler); + mEventThread->start(); #ifdef QBBLOCALETHREAD_ENABLED // Start the locale change monitoring thread. @@ -313,6 +311,8 @@ void QBBIntegration::createDisplays() screen, SLOT(newWindowCreated(screen_window_t))); QObject::connect(mScreenEventHandler, SIGNAL(windowClosed(screen_window_t)), screen, SLOT(windowClosed(screen_window_t))); + + QObject::connect(mNavigatorEventHandler, SIGNAL(rotationChanged(int)), screen, SLOT(setRotation(int))); } } diff --git a/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.cpp b/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.cpp index 877e91c..bac680a 100644 --- a/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.cpp +++ b/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.cpp @@ -41,7 +41,6 @@ #include "qbbnavigatoreventhandler.h" -#include "qbbscreen.h" #include <QtCore/private/qcore_unix_p.h> #include <QtGui/QApplication> @@ -61,8 +60,8 @@ #define NAV_CONTROL_PATH "/pps/services/navigator/control" #define PPS_BUFFER_SIZE 4096 -QBBNavigatorEventHandler::QBBNavigatorEventHandler(QBBScreen& primaryScreen) - : mPrimaryScreen(primaryScreen), +QBBNavigatorEventHandler::QBBNavigatorEventHandler(QObject *parent) + : QObject(parent), mFd(-1), mReadNotifier(0) { @@ -201,8 +200,7 @@ void QBBNavigatorEventHandler::handleMessage(const QByteArray &msg, const QByteA #if defined(QBBNAVIGATOREVENTHANDLER_DEBUG) qDebug() << "PPS: orientation, o=" << dat; #endif - mPrimaryScreen.setRotation( dat.toInt() ); - QWindowSystemInterface::handleScreenGeometryChange(0); + emit rotationChanged(dat.toInt()); replyPPS(msg, id, ""); } else if (msg == "SWIPE_DOWN") { diff --git a/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.h b/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.h index 4bac909..948f6e3 100644 --- a/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.h +++ b/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.h @@ -44,15 +44,17 @@ QT_BEGIN_NAMESPACE -class QBBScreen; class QSocketNotifier; class QBBNavigatorEventHandler : public QObject { Q_OBJECT public: - QBBNavigatorEventHandler(QBBScreen& primaryScreen); - virtual ~QBBNavigatorEventHandler(); + explicit QBBNavigatorEventHandler(QObject *parent = 0); + ~QBBNavigatorEventHandler(); + +Q_SIGNALS: + void rotationChanged(int angle); public Q_SLOTS: void start(); @@ -61,7 +63,6 @@ private Q_SLOTS: void readData(); private: - QBBScreen& mPrimaryScreen; int mFd; QSocketNotifier *mReadNotifier; diff --git a/src/plugins/platforms/blackberry/qbbscreen.cpp b/src/plugins/platforms/blackberry/qbbscreen.cpp index 5c91979..30630f1 100644 --- a/src/plugins/platforms/blackberry/qbbscreen.cpp +++ b/src/plugins/platforms/blackberry/qbbscreen.cpp @@ -222,6 +222,12 @@ void QBBScreen::setRotation(int rotation) // save new rotation mCurrentRotation = rotation; + + // TODO: check if other screens are supposed to rotate as well and/or whether this depends + // on if clone mode is being used. + // Rotating only the primary screen is what we had in the navigator event handler before refactoring + if (mPrimaryDisplay) + QWindowSystemInterface::handleScreenGeometryChange(mScreenIndex); } } diff --git a/src/plugins/platforms/blackberry/qbbscreen.h b/src/plugins/platforms/blackberry/qbbscreen.h index 22d210a..e353de1 100644 --- a/src/plugins/platforms/blackberry/qbbscreen.h +++ b/src/plugins/platforms/blackberry/qbbscreen.h @@ -64,7 +64,6 @@ public: virtual QSize physicalSize() const { return mCurrentPhysicalSize; } int rotation() const { return mCurrentRotation; } - void setRotation(int rotation); int nativeFormat() const { return (depth() == 32) ? SCREEN_FORMAT_RGBA8888 : SCREEN_FORMAT_RGB565; } screen_display_t nativeDisplay() const { return mDisplay; } @@ -86,6 +85,7 @@ public: QSharedPointer<QBBRootWindow> rootWindow() const { return mRootWindow; } public Q_SLOTS: + void setRotation(int rotation); void newWindowCreated(screen_window_t window); void windowClosed(screen_window_t window); |