macOS/iOS: set focus reason when handling window deactivation

Otherwise, the focusOutEvent to e.g. a QQuickItem losting focus will
be OtherFocusReason when the window it's becomes inactive.

Task-number: QTBUG-70319
Change-Id: Ic3762e68d92a88becd2b35612b14f6af64ee934e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Volker Hilsheimer 2020-04-28 17:22:53 +02:00 committed by Tor Arne Vestbø
parent 062b50abff
commit 1337e8fe46
3 changed files with 7 additions and 5 deletions

View File

@ -1199,7 +1199,8 @@ void QCocoaWindow::windowDidBecomeKey()
}
if (!windowIsPopupType())
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(window());
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(
window(), Qt::ActiveWindowFocusReason);
}
void QCocoaWindow::windowDidResignKey()
@ -1217,7 +1218,8 @@ void QCocoaWindow::windowDidResignKey()
if (!keyWindow || keyWindow == m_view.window) {
// No new key window, go ahead and set the active window to zero
if (!windowIsPopupType())
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(0);
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(
nullptr, Qt::ActiveWindowFocusReason);
}
}

View File

@ -308,7 +308,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMouseMoveHelper);
if ([self isTransparentForUserInput])
return NO;
if (!m_platformWindow->windowIsPopupType())
QWindowSystemInterface::handleWindowActivated([self topLevelWindow]);
QWindowSystemInterface::handleWindowActivated([self topLevelWindow], Qt::ActiveWindowFocusReason);
return YES;
}

View File

@ -286,7 +286,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
}
if (qGuiApp->focusWindow() != self.platformWindow->window())
QWindowSystemInterface::handleWindowActivated(self.platformWindow->window());
QWindowSystemInterface::handleWindowActivated(self.platformWindow->window(), Qt::ActiveWindowFocusReason);
else
qImDebug() << self.platformWindow->window() << "already active, not sending window activation";
@ -323,7 +323,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
UIResponder *newResponder = FirstResponderCandidate::currentCandidate();
if ([self responderShouldTriggerWindowDeactivation:newResponder])
QWindowSystemInterface::handleWindowActivated(0);
QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason);
return YES;
}