iOS: Track virtual keyboard gestures via focus window instead of screen
We're moving away from the screen managing a UIWindow, so let's track the UIWindow via the focus window instead. Task-number: QTBUG-121781 Change-Id: I943b1d501f743c51b3f1484aecbe008c6dae8cd4 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Amr Elsayed <amr.elsayed@qt.io>
This commit is contained in:
parent
f9c9981524
commit
f480b59914
@ -22,13 +22,11 @@
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#if !defined(Q_OS_VISIONOS)
|
||||
static QUIView *focusView()
|
||||
{
|
||||
return qApp->focusWindow() ?
|
||||
reinterpret_cast<QUIView *>(qApp->focusWindow()->winId()) : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -305,11 +303,7 @@ QIOSInputContext::QIOSInputContext()
|
||||
, m_keyboardHideGesture([[QIOSKeyboardListener alloc] initWithQIOSInputContext:this])
|
||||
, m_textResponder(0)
|
||||
{
|
||||
if (isQtApplication()) {
|
||||
QIOSScreen *iosScreen = static_cast<QIOSScreen*>(QGuiApplication::primaryScreen()->handle());
|
||||
[iosScreen->uiWindow() addGestureRecognizer:m_keyboardHideGesture];
|
||||
}
|
||||
|
||||
Q_ASSERT(!qGuiApp->focusWindow());
|
||||
connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &QIOSInputContext::focusWindowChanged);
|
||||
}
|
||||
|
||||
@ -613,12 +607,15 @@ void QIOSInputContext::setFocusObject(QObject *focusObject)
|
||||
|
||||
void QIOSInputContext::focusWindowChanged(QWindow *focusWindow)
|
||||
{
|
||||
Q_UNUSED(focusWindow);
|
||||
|
||||
qImDebug() << "new focus window =" << focusWindow;
|
||||
|
||||
reset();
|
||||
|
||||
if (isQtApplication()) {
|
||||
[m_keyboardHideGesture.view removeGestureRecognizer:m_keyboardHideGesture];
|
||||
[focusView().window addGestureRecognizer:m_keyboardHideGesture];
|
||||
}
|
||||
|
||||
// The keyboard rectangle depend on the focus window, so
|
||||
// we need to re-evaluate the keyboard state.
|
||||
updateKeyboardState();
|
||||
|
Loading…
x
Reference in New Issue
Block a user