summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qnx/qqnxwindow.cpp
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2014-01-18 18:38:04 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-29 00:18:15 +0100
commitfc24452fbf24205657179f990dfbfdcd2cfc3fd9 (patch)
tree07347291d44ff8cdda97d76cb00bc46676f4b2fc /src/plugins/platforms/qnx/qqnxwindow.cpp
parentb7396dc39f0ed693698039910a94d7dda3f8d92a (diff)
[QNX] Implement the requestActivate function
This allows manually transferring focus from one window to another, if the application has focus. Change-Id: If73ddca6ffbb735eaf4ee9fd322d978f9366fb4c Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxwindow.cpp')
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp54
1 files changed, 51 insertions, 3 deletions
diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp
index fe66d547f3..90b00efc13 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxwindow.cpp
@@ -202,8 +202,6 @@ void QQnxWindow::setVisible(bool visible)
root->updateVisibility(root->m_visible);
- window()->requestActivate();
-
QWindowSystemInterface::handleExposeEvent(window(), window()->geometry());
if (visible) {
@@ -435,9 +433,59 @@ void QQnxWindow::lower()
void QQnxWindow::requestActivateWindow()
{
- // Overwrite the default implementation where the window is activated
+ QQnxWindow *focusWindow = 0;
+ if (QGuiApplication::focusWindow())
+ focusWindow = static_cast<QQnxWindow*>(QGuiApplication::focusWindow()->handle());
+
+ if (focusWindow == this)
+ return;
+
+ if (screen()->rootWindow() == this ||
+ (focusWindow && findWindow(focusWindow->nativeHandle()))) {
+ // If the focus window is a child, we can just set the focus of our own window
+ // group to our window handle
+ setFocus(nativeHandle());
+ } else {
+ // In order to receive focus the parent's window group has to give focus to the
+ // child. If we have several hierarchy layers, we have to do that several times
+ QQnxWindow *currentWindow = this;
+ QList<QQnxWindow*> windowList;
+ while (currentWindow) {
+ windowList.prepend(currentWindow);
+ // If we find the focus window, we don't have to go further
+ if (currentWindow == focusWindow)
+ break;
+
+ if (currentWindow->parent()){
+ currentWindow = static_cast<QQnxWindow*>(currentWindow->parent());
+ } else if (screen()->rootWindow() &&
+ screen()->rootWindow()->m_windowGroupName == currentWindow->m_parentGroupName) {
+ currentWindow = screen()->rootWindow();
+ } else {
+ currentWindow = 0;
+ }
+ }
+
+ // We have to apply the focus from parent to child windows
+ for (int i = 1; i < windowList.size(); ++i)
+ windowList.at(i-1)->setFocus(windowList.at(i)->nativeHandle());
+
+ windowList.last()->setFocus(windowList.last()->nativeHandle());
+ }
+
+ screen_flush_context(m_screenContext, 0);
}
+void QQnxWindow::setFocus(screen_window_t newFocusWindow)
+{
+ screen_group_t screenGroup = 0;
+ screen_get_window_property_pv(nativeHandle(), SCREEN_PROPERTY_GROUP,
+ reinterpret_cast<void**>(&screenGroup));
+ if (screenGroup) {
+ screen_set_group_property_pv(screenGroup, SCREEN_PROPERTY_KEYBOARD_FOCUS,
+ reinterpret_cast<void**>(&newFocusWindow));
+ }
+}
void QQnxWindow::setWindowState(Qt::WindowState state)
{