summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-01-22 14:17:31 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-17 10:59:47 +0200
commitd449c0e0e4e39606e0421090b9356c46bc29030c (patch)
treea953c04c27412f5218459f584fc5b08e933ea978 /src/gui/kernel
parent4dbef58c3d2a63f59c5ae32ba9dc47a2a9157474 (diff)
When a window loses focus to a popup, event has PopupFocusReason
Followup to debe31e047060d790fb32c06e514d9df476df8bf : a popup window can have focus, but a QQuickWindow needs to know why it loses focus when a menu is opened, so that for example copy/cut/paste Actions can apply to the text which did have focus before the menu opened. The event's focus reason provides enough information to deal with this situation. Task-number: QTBUG-36292 Task-number: QTBUG-36332 Change-Id: Ifae999a364a61b125a4764c9db204a167bddf0b7 Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index bdedc9d75f..ab71fe9081 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1872,7 +1872,11 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
return;
if (previous) {
- QFocusEvent focusOut(QEvent::FocusOut, e->reason);
+ Qt::FocusReason r = e->reason;
+ if ((r == Qt::OtherFocusReason || r == Qt::ActiveWindowFocusReason) &&
+ newFocus && (newFocus->flags() & Qt::Popup) == Qt::Popup)
+ r = Qt::PopupFocusReason;
+ QFocusEvent focusOut(QEvent::FocusOut, r);
QCoreApplication::sendSpontaneousEvent(previous, &focusOut);
QObject::disconnect(previous, SIGNAL(focusObjectChanged(QObject*)),
qApp, SLOT(_q_updateFocusObject(QObject*)));
@@ -1881,7 +1885,11 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
}
if (QGuiApplicationPrivate::focus_window) {
- QFocusEvent focusIn(QEvent::FocusIn, e->reason);
+ Qt::FocusReason r = e->reason;
+ if ((r == Qt::OtherFocusReason || r == Qt::ActiveWindowFocusReason) &&
+ previous && (previous->flags() & Qt::Popup) == Qt::Popup)
+ r = Qt::PopupFocusReason;
+ QFocusEvent focusIn(QEvent::FocusIn, r);
QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn);
QObject::connect(QGuiApplicationPrivate::focus_window, SIGNAL(focusObjectChanged(QObject*)),
qApp, SLOT(_q_updateFocusObject(QObject*)));