From b5f343b3677a7c7f09d91d7d60f310717325e840 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Thu, 29 Mar 2012 15:23:57 +0200 Subject: Remove static methods in QQnxScreen Change-Id: If0fd910848ba70d3b0a2d948065b09337f8e51c3 Reviewed-by: Kevin Krammer Reviewed-by: Sean Harmer Reviewed-by: Robin Burchell --- src/plugins/platforms/qnx/qqnxintegration.cpp | 67 ++++++++++++++----- src/plugins/platforms/qnx/qqnxintegration.h | 7 +- src/plugins/platforms/qnx/qqnxscreen.cpp | 95 +++++++++------------------ src/plugins/platforms/qnx/qqnxscreen.h | 30 ++++----- src/plugins/platforms/qnx/qqnxwindow.cpp | 39 ++++++++--- src/plugins/platforms/qnx/qqnxwindow.h | 2 + 6 files changed, 130 insertions(+), 110 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index bb31de874b..43f474a158 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -100,10 +100,7 @@ QQnxIntegration::QQnxIntegration() } // Create displays for all possible screens (which may not be attached) - QQnxScreen::createDisplays(m_screenContext); - Q_FOREACH (QPlatformScreen *screen, QQnxScreen::screens()) { - screenAdded(screen); - } + createDisplays(); // Initialize global OpenGL resources QQnxGLContext::initialize(); @@ -115,7 +112,7 @@ QQnxIntegration::QQnxIntegration() // Create/start navigator event handler // Not on BlackBerry, it has specialised event dispatcher which also handles navigator events #ifndef Q_OS_BLACKBERRY - m_navigatorEventHandler = new QQnxNavigatorEventHandler(*QQnxScreen::primaryDisplay()); + m_navigatorEventHandler = new QQnxNavigatorEventHandler(*primaryDisplay()); // 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 @@ -131,7 +128,7 @@ QQnxIntegration::QQnxIntegration() // TODO check if we need to do this for all screens or only the primary one QObject::connect(m_virtualKeyboard, SIGNAL(heightChanged(int)), - QQnxScreen::primaryDisplay(), SLOT(keyboardHeightChanged(int))); + primaryDisplay(), SLOT(keyboardHeightChanged(int))); // Set up the input context m_inputContext = new QQnxInputContext(*m_virtualKeyboard); @@ -166,7 +163,7 @@ QQnxIntegration::~QQnxIntegration() delete m_navigatorEventHandler; // Destroy all displays - QQnxScreen::destroyDisplays(); + destroyDisplays(); // Close connection to QNX composition manager screen_destroy_context(m_screenContext); @@ -204,7 +201,6 @@ QPlatformWindow *QQnxIntegration::createPlatformWindow(QWindow *window) const #if defined(QQNXINTEGRATION_DEBUG) qDebug() << Q_FUNC_INFO; #endif - // New windows are created on the primary display. return new QQnxWindow(window, m_screenContext); } @@ -245,20 +241,12 @@ void QQnxIntegration::moveToScreen(QWindow *window, int screen) QQnxWindow *platformWindow = static_cast(window->handle()); // lookup platform screen by index - QQnxScreen *platformScreen = static_cast(QQnxScreen::screens().at(screen)); + QQnxScreen *platformScreen = m_screens.at(screen); // move the platform window to the platform screen platformWindow->setScreen(platformScreen); } -QList QQnxIntegration::screens() const -{ -#if defined(QQNXINTEGRATION_DEBUG) - qDebug() << Q_FUNC_INFO; -#endif - return QQnxScreen::screens(); -} - QAbstractEventDispatcher *QQnxIntegration::guiThreadEventDispatcher() const { #if defined(QQNXINTEGRATION_DEBUG) @@ -326,4 +314,49 @@ void QQnxIntegration::removeWindow(screen_window_t qnxWindow) ms_windowMapper.remove(qnxWindow); } +void QQnxIntegration::createDisplays() +{ +#if defined(QQNXINTEGRATION_DEBUG) + qDebug() << Q_FUNC_INFO; +#endif + // Query number of displays + errno = 0; + int displayCount; + int result = screen_get_context_property_iv(m_screenContext, SCREEN_PROPERTY_DISPLAY_COUNT, &displayCount); + if (result != 0) { + qFatal("QQnxIntegration: failed to query display count, errno=%d", errno); + } + + // Get all displays + errno = 0; + screen_display_t *displays = (screen_display_t *)alloca(sizeof(screen_display_t) * displayCount); + result = screen_get_context_property_pv(m_screenContext, SCREEN_PROPERTY_DISPLAYS, (void **)displays); + if (result != 0) { + qFatal("QQnxIntegration: failed to query displays, errno=%d", errno); + } + + for (int i=0; i screens() const; void moveToScreen(QWindow *window, int screen); QAbstractEventDispatcher *guiThreadEventDispatcher() const; @@ -98,6 +98,10 @@ public: static QWindow *window(screen_window_t qnxWindow); private: + void createDisplays(); + void destroyDisplays(); + QQnxScreen *primaryDisplay() const; + static void addWindow(screen_window_t qnxWindow, QWindow *window); static void removeWindow(screen_window_t qnxWindow); @@ -110,6 +114,7 @@ private: bool m_paintUsingOpenGL; QAbstractEventDispatcher *m_eventDispatcher; QQnxServices *m_services; + QList m_screens; #ifndef QT_NO_CLIPBOARD mutable QQnxClipboard* m_clipboard; #endif diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index 1fef0bc0a7..c9ac00339b 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -42,17 +42,15 @@ #include "qqnxscreen.h" #include "qqnxwindow.h" -#include -#include +#ifdef QQNXSCREEN_DEBUG +# include +#endif #include #include QT_BEGIN_NAMESPACE -QList QQnxScreen::ms_screens; -QList QQnxScreen::ms_childWindows; - QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display, bool primaryScreen) : m_screenContext(screenContext), m_display(display), @@ -115,52 +113,7 @@ QQnxScreen::~QQnxScreen() #endif } -/* static */ -void QQnxScreen::createDisplays(screen_context_t context) -{ -#if defined(QQNXSCREEN_DEBUG) - qDebug() << Q_FUNC_INFO; -#endif - // Query number of displays - errno = 0; - int displayCount; - int result = screen_get_context_property_iv(context, SCREEN_PROPERTY_DISPLAY_COUNT, &displayCount); - if (result != 0) { - qFatal("QQnxScreen: failed to query display count, errno=%d", errno); - } - - // Get all displays - errno = 0; - screen_display_t *displays = (screen_display_t *)alloca(sizeof(screen_display_t) * displayCount); - result = screen_get_context_property_pv(context, SCREEN_PROPERTY_DISPLAYS, (void **)displays); - if (result != 0) { - qFatal("QQnxScreen: failed to query displays, errno=%d", errno); - } - - for (int i=0; ifindWindow(windowHandle); + if (result) + return result; + } + + return 0; +} + void QQnxScreen::addWindow(QQnxWindow *window) { #if defined(QQNXSCREEN_DEBUG) qDebug() << Q_FUNC_INFO << "window =" << window; #endif - if (ms_childWindows.contains(window)) + if (m_childWindows.contains(window)) return; - ms_childWindows.push_back(window); - QQnxScreen::updateHierarchy(); + m_childWindows.push_back(window); + updateHierarchy(); } void QQnxScreen::removeWindow(QQnxWindow *window) @@ -253,8 +222,8 @@ void QQnxScreen::removeWindow(QQnxWindow *window) qDebug() << Q_FUNC_INFO << "window =" << window; #endif - ms_childWindows.removeAll(window); - QQnxScreen::updateHierarchy(); + m_childWindows.removeAll(window); + updateHierarchy(); } void QQnxScreen::raiseWindow(QQnxWindow *window) @@ -264,8 +233,8 @@ void QQnxScreen::raiseWindow(QQnxWindow *window) #endif removeWindow(window); - ms_childWindows.push_back(window); - QQnxScreen::updateHierarchy(); + m_childWindows.push_back(window); + updateHierarchy(); } void QQnxScreen::lowerWindow(QQnxWindow *window) @@ -275,8 +244,8 @@ void QQnxScreen::lowerWindow(QQnxWindow *window) #endif removeWindow(window); - ms_childWindows.push_front(window); - QQnxScreen::updateHierarchy(); + m_childWindows.push_front(window); + updateHierarchy(); } void QQnxScreen::updateHierarchy() @@ -285,15 +254,15 @@ void QQnxScreen::updateHierarchy() qDebug() << Q_FUNC_INFO; #endif - QList::iterator it; + QList::const_iterator it; int topZorder = 1; // root window is z-order 0, all "top" level windows are "above" it - for (it = ms_childWindows.begin(); it != ms_childWindows.end(); it++) + for (it = m_childWindows.constBegin(); it != m_childWindows.constEnd(); ++it) (*it)->updateZorder(topZorder); // After a hierarchy update, we need to force a flush on all screens. // Right now, all screens share a context. - screen_flush_context( primaryDisplay()->m_screenContext, 0 ); + screen_flush_context( m_screenContext, 0 ); } void QQnxScreen::onWindowPost(QQnxWindow *window) diff --git a/src/plugins/platforms/qnx/qqnxscreen.h b/src/plugins/platforms/qnx/qqnxscreen.h index 081114a4fb..a39689dd2c 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.h +++ b/src/plugins/platforms/qnx/qqnxscreen.h @@ -46,7 +46,6 @@ #include "qqnxrootwindow.h" -#include #include #include @@ -60,15 +59,12 @@ class QQnxScreen : public QObject, public QPlatformScreen { Q_OBJECT public: - static QList screens() { return ms_screens; } - static void createDisplays(screen_context_t context); - static void destroyDisplays(); - static QQnxScreen *primaryDisplay() { return static_cast(ms_screens.at(0)); } - static int defaultDepth(); + QQnxScreen(screen_context_t context, screen_display_t display, bool primaryScreen); + ~QQnxScreen(); QRect geometry() const { return m_currentGeometry; } QRect availableGeometry() const; - int depth() const { return defaultDepth(); } + int depth() const; QImage::Format format() const { return (depth() == 32) ? QImage::Format_RGB32 : QImage::Format_RGB16; } QSizeF physicalSize() const { return m_currentPhysicalSize; } @@ -82,12 +78,14 @@ public: screen_context_t nativeContext() const { return m_screenContext; } const char *windowGroupName() const { return m_rootWindow->groupName().constData(); } + QQnxWindow *findWindow(screen_window_t windowHandle); + /* Window hierarchy management */ - static void addWindow(QQnxWindow *child); - static void removeWindow(QQnxWindow *child); - static void raiseWindow(QQnxWindow *window); - static void lowerWindow(QQnxWindow *window); - static void updateHierarchy(); + void addWindow(QQnxWindow *child); + void removeWindow(QQnxWindow *child); + void raiseWindow(QQnxWindow *window); + void lowerWindow(QQnxWindow *window); + void updateHierarchy(); void onWindowPost(QQnxWindow *window); @@ -97,11 +95,6 @@ private Q_SLOTS: void keyboardHeightChanged(int height); private: - QQnxScreen(screen_context_t context, screen_display_t display, bool primaryScreen); - ~QQnxScreen(); - - static bool orthogonal(int rotation1, int rotation2); - screen_context_t m_screenContext; screen_display_t m_display; QSharedPointer m_rootWindow; @@ -117,8 +110,7 @@ private: QRect m_currentGeometry; QPlatformOpenGLContext *m_platformContext; - static QList ms_screens; - static QList ms_childWindows; + QList m_childWindows; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index e0fff0cd6a..66eb1cf777 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -124,7 +124,7 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context) setScreen(static_cast(window->screen()->handle())); // Add the window to the root of the hierarchy - QQnxScreen::addWindow(this); + m_screen->addWindow(this); // Add window to plugin's window mapper QQnxIntegration::addWindow(m_window, window); @@ -140,7 +140,7 @@ QQnxWindow::~QQnxWindow() // Remove from parent's Hierarchy. removeFromParent(); - QQnxScreen::updateHierarchy(); + m_screen->updateHierarchy(); // We shouldn't allow this case unless QT allows it. Does it? Or should we send the // handleCloseEvent on all children when this window is deleted? @@ -415,6 +415,11 @@ void QQnxWindow::setScreen(QQnxScreen *platformScreen) if (m_screen == platformScreen) return; + if (m_screen && m_screen->findWindow(m_window)) { + m_screen->removeWindow(this); + platformScreen->addWindow(this); + } + m_screen = platformScreen; // Move window to proper screen/display @@ -440,7 +445,7 @@ void QQnxWindow::setScreen(QQnxScreen *platformScreen) (*it)->setScreen(platformScreen); } - QQnxScreen::updateHierarchy(); + m_screen->updateHierarchy(); } void QQnxWindow::removeFromParent() @@ -455,7 +460,7 @@ void QQnxWindow::removeFromParent() else qFatal("QQnxWindow: Window Hierarchy broken; window has parent, but parent hasn't got child."); } else { - QQnxScreen::removeWindow(this); + m_screen->removeWindow(this); } } @@ -483,10 +488,10 @@ void QQnxWindow::setParent(const QPlatformWindow *window) m_parentWindow->m_childWindows.push_back(this); } else { - QQnxScreen::addWindow(this); + m_screen->addWindow(this); } - QQnxScreen::updateHierarchy(); + m_screen->updateHierarchy(); } void QQnxWindow::raise() @@ -500,10 +505,10 @@ void QQnxWindow::raise() removeFromParent(); oldParent->m_childWindows.push_back(this); } else { - QQnxScreen::raiseWindow(this); + m_screen->raiseWindow(this); } - QQnxScreen::updateHierarchy(); + m_screen->updateHierarchy(); } void QQnxWindow::lower() @@ -517,10 +522,10 @@ void QQnxWindow::lower() removeFromParent(); oldParent->m_childWindows.push_front(this); } else { - QQnxScreen::lowerWindow(this); + m_screen->lowerWindow(this); } - QQnxScreen::updateHierarchy(); + m_screen->updateHierarchy(); } void QQnxWindow::requestActivateWindow() @@ -552,6 +557,20 @@ void QQnxWindow::setPlatformOpenGLContext(QQnxGLContext *platformOpenGLContext) m_platformOpenGLContext = platformOpenGLContext; } +QQnxWindow *QQnxWindow::findWindow(screen_window_t windowHandle) +{ + if (m_window == windowHandle) + return this; + + Q_FOREACH (QQnxWindow *window, m_childWindows) { + QQnxWindow * const result = window->findWindow(windowHandle); + if (result) + return result; + } + + return 0; +} + void QQnxWindow::updateZorder(int &topZorder) { errno = 0; diff --git a/src/plugins/platforms/qnx/qqnxwindow.h b/src/plugins/platforms/qnx/qqnxwindow.h index cbe4eba7a4..64fe9f61fa 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.h +++ b/src/plugins/platforms/qnx/qqnxwindow.h @@ -99,6 +99,8 @@ public: void setPlatformOpenGLContext(QQnxGLContext *platformOpenGLContext); QQnxGLContext *platformOpenGLContext() const { return m_platformOpenGLContext; } + QQnxWindow *findWindow(screen_window_t windowHandle); + private: void removeFromParent(); void offset(const QPoint &offset); -- cgit v1.2.3