summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qnx/qqnxintegration.cpp
diff options
context:
space:
mode:
authorJames Turner <james.turner.qnx@kdab.com>2012-10-08 14:29:51 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-09 17:48:37 +0200
commit1f0d430c3a660c9e72581b582fe16c440bcf9eac (patch)
tree47653e5659f11bb37effec755d67c9889a1192cf /src/plugins/platforms/qnx/qqnxintegration.cpp
parent3374f06af2085c372da7fb634b2f82d7440dcdd1 (diff)
QNX: Add and remove screens dynamically.
Watch for display events from libscreen, and dynamically add and remove QPlatformScreens (and hence QScreens) in response. Change-Id: I56dc7019a4d4c77798a0a88451d2f3060066f5d2 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxintegration.cpp')
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp63
1 files changed, 49 insertions, 14 deletions
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index 1f6539fd3f..a45c65db08 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -124,7 +124,7 @@ QQnxIntegration::QQnxIntegration()
, m_eventDispatcher(createUnixEventDispatcher())
#endif
, m_nativeInterface(new QQnxNativeInterface())
- , m_screenEventHandler(new QQnxScreenEventHandler())
+ , m_screenEventHandler(new QQnxScreenEventHandler(this))
#if !defined(QT_NO_CLIPBOARD)
, m_clipboard(0)
#endif
@@ -437,20 +437,45 @@ void QQnxIntegration::createDisplays()
}
for (int i=0; i<displayCount; i++) {
+ int isAttached = 0;
+ result = screen_get_display_property_iv(displays[i], SCREEN_PROPERTY_ATTACHED, &isAttached);
+ if (result != 0) {
+ qWarning("QQnxIntegration: failed to query display attachment, errno=%d", errno);
+ isAttached = 1; // assume attached
+ }
+
+ if (!isAttached) {
+ qIntegrationDebug() << Q_FUNC_INFO << "Skipping non-attached display" << i;
+ continue;
+ }
+
qIntegrationDebug() << Q_FUNC_INFO << "Creating screen for display" << i;
- QQnxScreen *screen = new QQnxScreen(m_screenContext, displays[i], i==0);
- m_screens.append(screen);
- screenAdded(screen);
-
- QObject::connect(m_screenEventHandler, SIGNAL(newWindowCreated(void*)),
- screen, SLOT(newWindowCreated(void*)));
- QObject::connect(m_screenEventHandler, SIGNAL(windowClosed(void*)),
- screen, SLOT(windowClosed(void*)));
-
- QObject::connect(m_navigatorEventHandler, SIGNAL(rotationChanged(int)), screen, SLOT(setRotation(int)));
- QObject::connect(m_navigatorEventHandler, SIGNAL(windowGroupActivated(QByteArray)), screen, SLOT(activateWindowGroup(QByteArray)));
- QObject::connect(m_navigatorEventHandler, SIGNAL(windowGroupDeactivated(QByteArray)), screen, SLOT(deactivateWindowGroup(QByteArray)));
- }
+ createDisplay(displays[i], i==0);
+ } // of displays iteration
+}
+
+void QQnxIntegration::createDisplay(screen_display_t display, bool isPrimary)
+{
+ QQnxScreen *screen = new QQnxScreen(m_screenContext, display, isPrimary);
+ m_screens.append(screen);
+ screenAdded(screen);
+
+ QObject::connect(m_screenEventHandler, SIGNAL(newWindowCreated(void*)),
+ screen, SLOT(newWindowCreated(void*)));
+ QObject::connect(m_screenEventHandler, SIGNAL(windowClosed(void*)),
+ screen, SLOT(windowClosed(void*)));
+
+ QObject::connect(m_navigatorEventHandler, SIGNAL(rotationChanged(int)), screen, SLOT(setRotation(int)));
+ QObject::connect(m_navigatorEventHandler, SIGNAL(windowGroupActivated(QByteArray)), screen, SLOT(activateWindowGroup(QByteArray)));
+ QObject::connect(m_navigatorEventHandler, SIGNAL(windowGroupDeactivated(QByteArray)), screen, SLOT(deactivateWindowGroup(QByteArray)));
+}
+
+void QQnxIntegration::removeDisplay(QQnxScreen *screen)
+{
+ Q_CHECK_PTR(screen);
+ Q_ASSERT(m_screens.contains(screen));
+ m_screens.removeAll(screen);
+ screen->deleteLater();
}
void QQnxIntegration::destroyDisplays()
@@ -460,6 +485,16 @@ void QQnxIntegration::destroyDisplays()
m_screens.clear();
}
+QQnxScreen *QQnxIntegration::screenForNative(screen_display_t qnxScreen) const
+{
+ Q_FOREACH (QQnxScreen *screen, m_screens) {
+ if (screen->nativeDisplay() == qnxScreen)
+ return screen;
+ }
+
+ return 0;
+}
+
QQnxScreen *QQnxIntegration::primaryDisplay() const
{
return m_screens.first();