summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qnx/qqnxwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxwindow.cpp')
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp129
1 files changed, 63 insertions, 66 deletions
diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp
index 99071cf4f2..e28e5f40e5 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxwindow.cpp
@@ -86,9 +86,18 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, bool needRootW
QQnxScreen *platformScreen = static_cast<QQnxScreen *>(window->screen()->handle());
- m_isTopLevel = ( needRootWindow && !platformScreen->rootWindow())
- || (!needRootWindow && !parent())
- || window->type() == Qt::CoverWindow;
+ if (window->type() == Qt::CoverWindow) {
+ // Cover windows have to be top level to be accessible to window delegate (i.e. navigator)
+ m_isTopLevel = true;
+ } else if (parent() || (window->type() & Qt::Dialog) == Qt::Dialog) {
+ // If we have a parent we are a child window. Sometimes we have to be a child even if we
+ // don't have a parent e.g. our parent might be in a different process.
+ m_isTopLevel = false;
+ } else {
+ // We're parentless. If we're not using a root window, we'll always be a top-level window
+ // otherwise only the first window is.
+ m_isTopLevel = !needRootWindow || !platformScreen->rootWindow();
+ }
errno = 0;
if (m_isTopLevel) {
@@ -96,13 +105,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()
@@ -130,7 +140,7 @@ void QQnxWindow::setGeometry(const QRect &rect)
if (screen()->rootWindow() == this) //If this is the root window, it has to be shown fullscreen
newGeometry = screen()->geometry();
- const QRect oldGeometry = setGeometryHelper(newGeometry);
+ setGeometryHelper(newGeometry);
// Send a geometry change event to Qt (triggers resizeEvent() in QWindow/QWidget).
@@ -140,23 +150,15 @@ void QQnxWindow::setGeometry(const QRect &rect)
QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
QWindowSystemInterface::handleExposeEvent(window(), newGeometry);
QWindowSystemInterface::setSynchronousWindowsSystemEvents(false);
-
- // Now move all children.
- if (!oldGeometry.isEmpty()) {
- const QPoint offset = newGeometry.topLeft() - oldGeometry.topLeft();
- Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
- childWindow->setOffset(offset);
- }
}
-QRect QQnxWindow::setGeometryHelper(const QRect &rect)
+void QQnxWindow::setGeometryHelper(const QRect &rect)
{
qWindowDebug() << Q_FUNC_INFO << "window =" << window()
<< ", (" << rect.x() << "," << rect.y()
<< "," << rect.width() << "," << rect.height() << ")";
// Call base class method
- QRect oldGeometry = QPlatformWindow::geometry();
QPlatformWindow::setGeometry(rect);
// Set window geometry equal to widget geometry
@@ -181,30 +183,7 @@ QRect QQnxWindow::setGeometryHelper(const QRect &rect)
if (result != 0)
qFatal("QQnxWindow: failed to set window source size, errno=%d", errno);
- return oldGeometry;
-}
-
-void QQnxWindow::setOffset(const QPoint &offset)
-{
- qWindowDebug() << Q_FUNC_INFO << "window =" << window();
- // Move self and then children.
- QRect newGeometry = geometry();
- newGeometry.translate(offset);
-
- // Call the base class
- QPlatformWindow::setGeometry(newGeometry);
-
- int val[2];
-
- errno = 0;
- val[0] = newGeometry.x();
- val[1] = newGeometry.y();
- int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, val);
- if (result != 0)
- qFatal("QQnxWindow: failed to set window position, errno=%d", errno);
-
- Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
- childWindow->setOffset(offset);
+ screen_flush_context(m_screenContext, 0);
}
void QQnxWindow::setVisible(bool visible)
@@ -214,6 +193,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;
@@ -386,16 +371,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.
@@ -439,8 +414,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();
@@ -478,12 +455,7 @@ void QQnxWindow::lower()
void QQnxWindow::requestActivateWindow()
{
- qWindowDebug() << Q_FUNC_INFO << "window =" << window();
-
- // TODO: Tell screen to set keyboard focus to this window.
-
- // Notify that we gained focus.
- gainedFocus();
+ // Overwrite the default implementation where the window is activated
}
@@ -507,14 +479,6 @@ void QQnxWindow::propagateSizeHints()
qWindowDebug() << Q_FUNC_INFO << ": ignored";
}
-void QQnxWindow::gainedFocus()
-{
- qWindowDebug() << Q_FUNC_INFO << "window =" << window();
-
- // Got focus
- QWindowSystemInterface::handleWindowActivated(window());
-}
-
void QQnxWindow::setMMRendererWindowName(const QString &name)
{
m_mmRendererWindowName = name;
@@ -599,13 +563,18 @@ void QQnxWindow::initWindow()
qFatal("QQnxWindow: failed to set window sensitivity, errno=%d", errno);
}
- setScreen(static_cast<QQnxScreen *>(window()->screen()->handle()));
+ QQnxScreen *platformScreen = static_cast<QQnxScreen *>(window()->screen()->handle());
+ setScreen(platformScreen);
if (window()->type() == Qt::CoverWindow) {
#if defined(Q_OS_BLACKBERRY) && !defined(Q_OS_BLACKBERRY_TABLET)
- screen_set_window_property_pv(m_screen->rootWindow()->nativeHandle(),
- SCREEN_PROPERTY_ALTERNATE_WINDOW, (void**)&m_window);
- m_cover.reset(new QQnxNavigatorCover);
+ if (platformScreen->rootWindow()) {
+ screen_set_window_property_pv(m_screen->rootWindow()->nativeHandle(),
+ SCREEN_PROPERTY_ALTERNATE_WINDOW, (void**)&m_window);
+ m_cover.reset(new QQnxNavigatorCover);
+ } else {
+ qWarning("No root window for cover window");
+ }
#endif
m_exposed = false;
}
@@ -638,6 +607,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);