}
// 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();
// 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
// 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);
delete m_navigatorEventHandler;
// Destroy all displays
- QQnxScreen::destroyDisplays();
+ destroyDisplays();
// Close connection to QNX composition manager
screen_destroy_context(m_screenContext);
#if defined(QQNXINTEGRATION_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
- // New windows are created on the primary display.
return new QQnxWindow(window, m_screenContext);
}
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)
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
class QQnxAbstractVirtualKeyboard;
class QQnxWindow;
class QQnxServices;
+class QQnxScreen;
#ifndef QT_NO_CLIPBOARD
class QQnxClipboard;
QPlatformInputContext *inputContext() const;
- QList<QPlatformScreen *> screens() const;
void moveToScreen(QWindow *window, int screen);
QAbstractEventDispatcher *guiThreadEventDispatcher() const;
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);
bool m_paintUsingOpenGL;
QAbstractEventDispatcher *m_eventDispatcher;
QQnxServices *m_services;
+ QList<QQnxScreen*> m_screens;
#ifndef QT_NO_CLIPBOARD
mutable QQnxClipboard* m_clipboard;
#endif
#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),
#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;
m_currentGeometry.width(), m_currentGeometry.height() - m_keyboardHeight);
}
+int QQnxScreen::depth() const
+{
+ return defaultDepth();
+}
+
/*!
Check if the supplied angles are perpendicular to each other.
*/
}
}
+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)
qDebug() << Q_FUNC_INFO << "window =" << window;
#endif
- ms_childWindows.removeAll(window);
- QQnxScreen::updateHierarchy();
+ m_childWindows.removeAll(window);
+ updateHierarchy();
}
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)
#endif
removeWindow(window);
- ms_childWindows.push_front(window);
- QQnxScreen::updateHierarchy();
+ m_childWindows.push_front(window);
+ updateHierarchy();
}
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)
#include "qqnxrootwindow.h"
-#include <QtCore/QByteArray>
#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
{
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; }
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);
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;
QRect m_currentGeometry;
QPlatformOpenGLContext *m_platformContext;
- static QList<QPlatformScreen *> ms_screens;
- static QList<QQnxWindow *> ms_childWindows;
+ QList<QQnxWindow *> m_childWindows;
};
QT_END_NAMESPACE
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);
// 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?
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
(*it)->setScreen(platformScreen);
}
- QQnxScreen::updateHierarchy();
+ m_screen->updateHierarchy();
}
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);
}
}
m_parentWindow->m_childWindows.push_back(this);
} else {
- QQnxScreen::addWindow(this);
+ m_screen->addWindow(this);
}
- QQnxScreen::updateHierarchy();
+ m_screen->updateHierarchy();
}
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()
removeFromParent();
oldParent->m_childWindows.push_front(this);
} else {
- QQnxScreen::lowerWindow(this);
+ m_screen->lowerWindow(this);
}
- QQnxScreen::updateHierarchy();
+ m_screen->updateHierarchy();
}
void QQnxWindow::requestActivateWindow()
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;
void setPlatformOpenGLContext(QQnxGLContext *platformOpenGLContext);
QQnxGLContext *platformOpenGLContext() const { return m_platformOpenGLContext; }
+ QQnxWindow *findWindow(screen_window_t windowHandle);
+
private:
void removeFromParent();
void offset(const QPoint &offset);