aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@digia.com>2014-05-21 10:49:07 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-21 12:35:21 +0200
commit7c1ee572770bdac445eb6a647b6a82a7dc2da407 (patch)
tree23c52ce27a555eec3fe95a13146d08e28aea36b9 /src/quick/items
parent7ccdf8d11675e963b70b565e421309e09c019343 (diff)
Focus event fix for QQuickWidget
Relay focus in/out events to the offscreen QQuickWindow, and also make the offscreen window believe it has the focus when the render window has it. Task-number: QTBUG-39033 Change-Id: Ib50b134e635833ad3813693ca272f04607c525b8 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickwindow.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 6220ea2e1f..e78f9141a8 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -687,6 +687,13 @@ void QQuickWindowPrivate::translateTouchEvent(QTouchEvent *touchEvent)
touchEvent->setTouchPoints(touchPoints);
}
+
+static inline bool windowHasFocus(QQuickWindow *win)
+{
+ const QWindow *focusWindow = QGuiApplication::focusWindow();
+ return win == focusWindow || QQuickRenderControl::renderWindowFor(win) == focusWindow;
+}
+
/*!
Set the focus inside \a scope to be \a item.
If the scope contains the active focus item, it will be changed to \a item.
@@ -762,7 +769,7 @@ void QQuickWindowPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *item, Q
}
if (!(options & DontChangeFocusProperty)) {
- if (item != contentItem || QGuiApplication::focusWindow() == q) {
+ if (item != contentItem || windowHasFocus(q)) {
itemPrivate->focus = true;
changed << item;
}