summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire@kdab.com>2012-03-29 15:23:57 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-30 21:51:14 +0200
commitb5f343b3677a7c7f09d91d7d60f310717325e840 (patch)
tree9c2bf3b9858f88ad3d2b7943686a75566c6fc9c2 /src/plugins
parent5d7f7e6559bb78795c0572a605c2e635d28ec017 (diff)
Remove static methods in QQnxScreen
Change-Id: If0fd910848ba70d3b0a2d948065b09337f8e51c3 Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp67
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.h7
-rw-r--r--src/plugins/platforms/qnx/qqnxscreen.cpp95
-rw-r--r--src/plugins/platforms/qnx/qqnxscreen.h30
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp39
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.h2
6 files changed, 130 insertions, 110 deletions
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<QQnxWindow *>(window->handle());
// lookup platform screen by index
- QQnxScreen *platformScreen = static_cast<QQnxScreen*>(QQnxScreen::screens().at(screen));
+ QQnxScreen *platformScreen = m_screens.at(screen);
// move the platform window to the platform screen
platformWindow->setScreen(platformScreen);
}
-QList<QPlatformScreen *> 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<displayCount; i++) {
+#if defined(QQNXINTEGRATION_DEBUG)
+ qDebug() << "QQnxIntegration::Creating screen for display " << i;
+#endif
+ QQnxScreen *screen = new QQnxScreen(m_screenContext, displays[i], i==0);
+ m_screens.append(screen);
+ screenAdded(screen);
+ }
+}
+
+void QQnxIntegration::destroyDisplays()
+{
+#if defined(QQNXINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ qDeleteAll(m_screens);
+ m_screens.clear();
+}
+
+QQnxScreen *QQnxIntegration::primaryDisplay() const
+{
+ return m_screens.first();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h
index 12fb60ab19..ef654bf746 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.h
+++ b/src/plugins/platforms/qnx/qqnxintegration.h
@@ -56,6 +56,7 @@ class QQnxNavigatorEventHandler;
class QQnxAbstractVirtualKeyboard;
class QQnxWindow;
class QQnxServices;
+class QQnxScreen;
#ifndef QT_NO_CLIPBOARD
class QQnxClipboard;
@@ -78,7 +79,6 @@ public:
QPlatformInputContext *inputContext() const;
- QList<QPlatformScreen *> 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<QQnxScreen*> 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 <QtCore/QDebug>
-#include <QtCore/QUuid>
+#ifdef QQNXSCREEN_DEBUG
+# include <QtCore/QDebug>
+#endif
#include <QtGui/QWindowSystemInterface>
#include <errno.h>
QT_BEGIN_NAMESPACE
-QList<QPlatformScreen *> QQnxScreen::ms_screens;
-QList<QQnxWindow*> 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; i<displayCount; i++) {
-#if defined(QQNXSCREEN_DEBUG)
- qDebug() << "QQnxScreen::Creating screen for display " << i;
-#endif
- QQnxScreen *screen = new QQnxScreen(context, displays[i], i==0);
- ms_screens.append(screen);
- }
-}
-
-/* static */
-void QQnxScreen::destroyDisplays()
-{
-#if defined(QQNXSCREEN_DEBUG)
- qDebug() << Q_FUNC_INFO;
-#endif
- qDeleteAll(ms_screens);
- ms_screens.clear();
-
- // We're not managing the child windows anymore so we need to clear the list.
- ms_childWindows.clear();
-}
-
-/* static */
-int QQnxScreen::defaultDepth()
+static int defaultDepth()
{
#if defined(QQNXSCREEN_DEBUG)
qDebug() << Q_FUNC_INFO;
@@ -187,6 +140,11 @@ QRect QQnxScreen::availableGeometry() const
m_currentGeometry.width(), m_currentGeometry.height() - m_keyboardHeight);
}
+int QQnxScreen::depth() const
+{
+ return defaultDepth();
+}
+
/*!
Check if the supplied angles are perpendicular to each other.
*/
@@ -234,17 +192,28 @@ void QQnxScreen::setRotation(int rotation)
}
}
+QQnxWindow *QQnxScreen::findWindow(screen_window_t windowHandle)
+{
+ Q_FOREACH (QQnxWindow *window, m_childWindows) {
+ QQnxWindow * const result = window->findWindow(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<QQnxWindow*>::iterator it;
+ QList<QQnxWindow*>::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 <QtCore/QByteArray>
#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
@@ -60,15 +59,12 @@ class QQnxScreen : public QObject, public QPlatformScreen
{
Q_OBJECT
public:
- static QList<QPlatformScreen *> screens() { return ms_screens; }
- static void createDisplays(screen_context_t context);
- static void destroyDisplays();
- static QQnxScreen *primaryDisplay() { return static_cast<QQnxScreen*>(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<QQnxRootWindow> m_rootWindow;
@@ -117,8 +110,7 @@ private:
QRect m_currentGeometry;
QPlatformOpenGLContext *m_platformContext;
- static QList<QPlatformScreen *> ms_screens;
- static QList<QQnxWindow *> ms_childWindows;
+ QList<QQnxWindow *> 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<QQnxScreen *>(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);