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. Change-Id: I304a80232b84d2d9130e38e955d5a75b1ccad775 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>bb10
parent
b4ec80ac87
commit
45b7b0599c
|
|
@ -103,16 +103,6 @@ QQnxIntegration::QQnxIntegration()
|
|||
qFatal("QQnx: failed to connect to composition manager, errno=%d", errno);
|
||||
}
|
||||
|
||||
// Create displays for all possible screens (which may not be attached)
|
||||
createDisplays();
|
||||
|
||||
// Initialize global OpenGL resources
|
||||
QQnxGLContext::initialize();
|
||||
|
||||
// Create/start event thread
|
||||
m_eventThread = new QQnxEventThread(m_screenContext, m_screenEventHandler);
|
||||
m_eventThread->start();
|
||||
|
||||
// Create/start navigator event handler
|
||||
// Not on BlackBerry, it has specialised event dispatcher which also handles navigator events
|
||||
#ifndef Q_OS_BLACKBERRY
|
||||
|
|
@ -123,6 +113,16 @@ QQnxIntegration::QQnxIntegration()
|
|||
QMetaObject::invokeMethod(m_navigatorEventHandler, "start", Qt::QueuedConnection);
|
||||
#endif
|
||||
|
||||
// Create displays for all possible screens (which may not be attached)
|
||||
createDisplays();
|
||||
|
||||
// Initialize global OpenGL resources
|
||||
QQnxGLContext::initialize();
|
||||
|
||||
// Create/start event thread
|
||||
m_eventThread = new QQnxEventThread(m_screenContext, m_screenEventHandler);
|
||||
m_eventThread->start();
|
||||
|
||||
// Create/start the keyboard class.
|
||||
m_virtualKeyboard = new QQnxVirtualKeyboard();
|
||||
|
||||
|
|
@ -360,6 +360,10 @@ void QQnxIntegration::createDisplays()
|
|||
screen, SLOT(newWindowCreated(void *)));
|
||||
QObject::connect(m_screenEventHandler, SIGNAL(windowClosed(void *)),
|
||||
screen, SLOT(windowClosed(void *)));
|
||||
|
||||
#ifndef Q_OS_BLACKBERRY
|
||||
QObject::connect(m_navigatorEventHandler, SIGNAL(rotationChanged(int)), screen, SLOT(setRotation(int)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "qqnxnavigatoreventhandler.h"
|
||||
#include "qqnxscreen.h"
|
||||
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QWindow>
|
||||
|
|
@ -61,8 +60,8 @@
|
|||
static const char *navigatorControlPath = "/pps/services/navigator/control";
|
||||
static const int ppsBufferSize = 4096;
|
||||
|
||||
QQnxNavigatorEventHandler::QQnxNavigatorEventHandler(QQnxScreen& primaryScreen)
|
||||
: m_primaryScreen(primaryScreen),
|
||||
QQnxNavigatorEventHandler::QQnxNavigatorEventHandler(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_fd(-1),
|
||||
m_readNotifier(0)
|
||||
{
|
||||
|
|
@ -202,8 +201,7 @@ void QQnxNavigatorEventHandler::handleMessage(const QByteArray &msg, const QByte
|
|||
#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
|
||||
qDebug() << "PPS: orientation, o=" << dat;
|
||||
#endif
|
||||
m_primaryScreen.setRotation( dat.toInt() );
|
||||
QWindowSystemInterface::handleScreenGeometryChange(0, m_primaryScreen.geometry());
|
||||
Q_EMIT rotationChanged(dat.toInt());
|
||||
replyPPS(msg, id, "");
|
||||
|
||||
} else if (msg == "SWIPE_DOWN") {
|
||||
|
|
|
|||
|
|
@ -46,15 +46,17 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QQnxScreen;
|
||||
class QSocketNotifier;
|
||||
|
||||
class QQnxNavigatorEventHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQnxNavigatorEventHandler(QQnxScreen &primaryScreen);
|
||||
virtual ~QQnxNavigatorEventHandler();
|
||||
explicit QQnxNavigatorEventHandler(QObject *parent = 0);
|
||||
~QQnxNavigatorEventHandler();
|
||||
|
||||
Q_SIGNALS:
|
||||
void rotationChanged(int angle);
|
||||
|
||||
public Q_SLOTS:
|
||||
void start();
|
||||
|
|
@ -67,7 +69,6 @@ private:
|
|||
void replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat);
|
||||
void handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id);
|
||||
|
||||
QQnxScreen &m_primaryScreen;
|
||||
int m_fd;
|
||||
QSocketNotifier *m_readNotifier;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -190,6 +190,12 @@ void QQnxScreen::setRotation(int rotation)
|
|||
|
||||
// Save new rotation
|
||||
m_currentRotation = 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 (m_primaryScreen)
|
||||
QWindowSystemInterface::handleScreenGeometryChange(screen(), m_currentGeometry);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ public:
|
|||
bool isPrimaryScreen() const { return m_primaryScreen; }
|
||||
|
||||
int rotation() const { return m_currentRotation; }
|
||||
void setRotation(int rotation);
|
||||
|
||||
int nativeFormat() const { return (depth() == 32) ? SCREEN_FORMAT_RGBA8888 : SCREEN_FORMAT_RGB565; }
|
||||
screen_display_t nativeDisplay() const { return m_display; }
|
||||
|
|
@ -92,6 +91,7 @@ public:
|
|||
QSharedPointer<QQnxRootWindow> rootWindow() const { return m_rootWindow; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void setRotation(int rotation);
|
||||
void newWindowCreated(void *window);
|
||||
void windowClosed(void *window);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue