When a window loses focus to a popup, event has PopupFocusReason
Followup to debe31e047 : 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>
bb10
parent
4dbef58c3d
commit
d449c0e0e4
|
|
@ -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*)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue