diff options
author | Roger Maclean <rmaclean@qnx.com> | 2014-01-07 14:10:32 -0500 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-17 14:32:36 +0100 |
commit | 6e836271fd851c31cb7408c183aa3fd193d1a835 (patch) | |
tree | 1c56b6a26ee9135c33b684c53f7169f6ebc9ab26 /src/plugins | |
parent | 5c3faa52d7aaab64d1aa6c3800466292a3c3ce18 (diff) |
QNX: Make window groups work reliably
Window group related code worked previously only for the 'root'
window and other windows that had no parents (which then joined
the window group of the root).
Introduced a new function joinGroup that makes the group related
calls, this can both join and leave groups.
Default group joining is performed in setVisible now rather than
setScreen. The advantage of setVisible is that one can rely on it
getting called at some point but it is also possible to create and
interact with a QQnxWindow before it is called. This allows
the default group handling to be overridden via the native
interface. If the group is set (or explicitly not set) then the
default handling is not done.
joinGroup is also called from setParent so that if the parent window
is changed the window joins the parent group.
Change-Id: I03e3801ecb4e4cf901c02e45f00472a87692c2ec
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/qnx/qqnxnativeinterface.cpp | 8 | ||||
-rw-r--r-- | src/plugins/platforms/qnx/qqnxscreen.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/qnx/qqnxwindow.cpp | 49 | ||||
-rw-r--r-- | src/plugins/platforms/qnx/qqnxwindow.h | 4 |
4 files changed, 50 insertions, 13 deletions
diff --git a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp index d1ceebfebc..df9d96739a 100644 --- a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp +++ b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp @@ -88,9 +88,15 @@ void *QQnxNativeInterface::nativeResourceForContext(const QByteArray &resource, void QQnxNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) { + QQnxWindow *qnxWindow = static_cast<QQnxWindow*>(window); + if (name == QStringLiteral("mmRendererWindowName")) { - QQnxWindow *qnxWindow = static_cast<QQnxWindow*>(window); qnxWindow->setMMRendererWindowName(value.toString()); + } else if (name == QStringLiteral("windowGroup")) { + if (value.isNull()) + qnxWindow->joinWindowGroup(QByteArray()); + else if (value.canConvert<QByteArray>()) + qnxWindow->joinWindowGroup(value.toByteArray()); } } diff --git a/src/plugins/platforms/qnx/qqnxscreen.h b/src/plugins/platforms/qnx/qqnxscreen.h index 61c47e6c72..d39a210d4b 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.h +++ b/src/plugins/platforms/qnx/qqnxscreen.h @@ -80,7 +80,7 @@ public: int nativeFormat() const { return (depth() == 32) ? SCREEN_FORMAT_RGBA8888 : SCREEN_FORMAT_RGB565; } screen_display_t nativeDisplay() const { return m_display; } screen_context_t nativeContext() const { return m_screenContext; } - const char *windowGroupName() const { return rootWindow()->groupName().constData(); } + const char *windowGroupName() const { return m_rootWindow ? m_rootWindow->groupName().constData() : 0; } QQnxWindow *findWindow(screen_window_t windowHandle); diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index aa7ec0e499..e782db75eb 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -96,13 +96,14 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, bool needRootW if (window->type() != Qt::CoverWindow) { if (needRootWindow) platformScreen->setRootWindow(this); - createWindowGroup(); } } else { result = screen_create_window_type(&m_window, m_screenContext, SCREEN_CHILD_WINDOW); } if (result != 0) qFatal("QQnxWindow: failed to create window, errno=%d", errno); + + createWindowGroup(); } QQnxWindow::~QQnxWindow() @@ -183,6 +184,12 @@ void QQnxWindow::setVisible(bool visible) if (m_visible == visible) return; + // The first time through we join a window group if appropriate. + if (m_parentGroupName.isNull() && !m_isTopLevel) { + joinWindowGroup(parent() ? static_cast<QQnxWindow*>(parent())->groupName() + : QByteArray(m_screen->windowGroupName())); + } + m_visible = visible; QQnxWindow *root = this; @@ -355,16 +362,6 @@ void QQnxWindow::setScreen(QQnxScreen *platformScreen) qFatal("QQnxWindow: failed to set window display, errno=%d", errno); } else { errno = 0; - int result; - if (!parent()) { - result = screen_join_window_group(m_window, platformScreen->windowGroupName()); - if (result != 0) - qFatal("QQnxWindow: failed to join window group, errno=%d", errno); - } else { - result = screen_join_window_group(m_window, static_cast<QQnxWindow*>(parent())->groupName().constData()); - if (result != 0) - qFatal("QQnxWindow: failed to join window group, errno=%d", errno); - } Q_FOREACH (QQnxWindow *childWindow, m_childWindows) { // Only subwindows and tooltips need necessarily be moved to another display with the window. @@ -408,8 +405,10 @@ void QQnxWindow::setParent(const QPlatformWindow *window) setScreen(m_parentWindow->m_screen); m_parentWindow->m_childWindows.push_back(this); + joinWindowGroup(m_parentWindow->groupName()); } else { m_screen->addWindow(this); + joinWindowGroup(QByteArray()); } adjustBufferSize(); @@ -599,6 +598,34 @@ void QQnxWindow::createWindowGroup() qFatal("QQnxRootWindow: failed to create app window group, errno=%d", errno); } +void QQnxWindow::joinWindowGroup(const QByteArray &groupName) +{ + bool changed = false; + + qWindowDebug() << Q_FUNC_INFO << "group:" << groupName; + + if (!groupName.isEmpty()) { + if (groupName != m_parentGroupName) { + screen_join_window_group(m_window, groupName); + m_parentGroupName = groupName; + changed = true; + } + } else { + if (!m_parentGroupName.isEmpty()) { + screen_leave_window_group(m_window); + changed = true; + } + // By setting to an empty string we'll stop setVisible from trying to + // change our group, we want that to happen only if joinWindowGroup has + // never been called. This allows windows to be created that are not initially + // part of any group. + m_parentGroupName = ""; + } + + if (changed) + screen_flush_context(m_screenContext, 0); +} + void QQnxWindow::updateZorder(int &topZorder) { updateZorder(m_window, topZorder); diff --git a/src/plugins/platforms/qnx/qqnxwindow.h b/src/plugins/platforms/qnx/qqnxwindow.h index 2120c07816..5fa7b32dc8 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.h +++ b/src/plugins/platforms/qnx/qqnxwindow.h @@ -111,6 +111,7 @@ public: void setRotation(int rotation); QByteArray groupName() const { return m_windowGroupName; } + void joinWindowGroup(const QByteArray &groupName); protected: virtual int pixelFormat() const = 0; @@ -144,7 +145,10 @@ private: QString m_mmRendererWindowName; screen_window_t m_mmRendererWindow; + // Group name of window group headed by this window QByteArray m_windowGroupName; + // Group name that we have joined or "" if we've not joined any group. + QByteArray m_parentGroupName; bool m_isTopLevel; }; |