macOS: Implement QPlatformInputContext::setFocusObject()

Instead of handling the update manually.

Pick-to: 6.2
Change-Id: Iffb28d893146f5d3f6eae8e8c43aaf7fa5281516
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Tor Arne Vestbø 2021-08-18 21:05:19 +02:00
parent e5bebd883c
commit e42eefe044
2 changed files with 3 additions and 13 deletions

View File

@ -57,15 +57,13 @@ public:
bool isValid() const override { return true; }
void setFocusObject(QObject *object) override;
void reset() override;
QLocale locale() const override { return m_locale; }
void updateLocale();
private Q_SLOTS:
void connectSignals();
void focusObjectChanged(QObject *focusObject);
private:
QPointer<QWindow> m_focusWindow;
QLocale m_locale;

View File

@ -84,8 +84,6 @@ QCocoaInputContext::QCocoaInputContext()
: QPlatformInputContext()
, m_focusWindow(QGuiApplication::focusWindow())
{
QMetaObject::invokeMethod(this, "connectSignals", Qt::QueuedConnection);
m_inputSourceObserver = QMacNotificationObserver(nil,
NSTextInputContextKeyboardSelectionDidChangeNotification, [&]() {
qCDebug(lcQpaInputMethods) << "Text input source changed";
@ -123,13 +121,7 @@ void QCocoaInputContext::reset()
}
}
void QCocoaInputContext::connectSignals()
{
connect(qApp, SIGNAL(focusObjectChanged(QObject*)), this, SLOT(focusObjectChanged(QObject*)));
focusObjectChanged(qApp->focusObject());
}
void QCocoaInputContext::focusObjectChanged(QObject *focusObject)
void QCocoaInputContext::setFocusObject(QObject *focusObject)
{
qCDebug(lcQpaInputMethods) << "Focus object changed to" << focusObject;