diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index da49870bad..93ad0fc207 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -166,25 +166,29 @@ void InputMethod::clientAdded(AbstractClient* client) connect(m_inputClient, &AbstractClient::windowClosed, this, &InputMethod::hide); } +void InputMethod::setTrackedClient(AbstractClient* trackedClient) +{ + // Reset the old client virtual keybaord geom if necessary + // Old and new clients could be the same if focus moves between subsurfaces + if (m_trackedClient == trackedClient) { + return; + } + if (m_trackedClient) { + m_trackedClient->setVirtualKeyboardGeometry(QRect()); + disconnect(m_trackedClient, &AbstractClient::frameGeometryChanged, this, &InputMethod::updateInputPanelState); + } + m_trackedClient = trackedClient; + if (m_trackedClient) { + connect(m_trackedClient, &AbstractClient::frameGeometryChanged, this, &InputMethod::updateInputPanelState, Qt::QueuedConnection); + } + updateInputPanelState(); +} + void InputMethod::handleFocusedSurfaceChanged() { SurfaceInterface *focusedSurface = waylandServer()->seat()->focusedTextInputSurface(); - if (focusedSurface) { - AbstractClient *focusedClient = waylandServer()->findClient(focusedSurface); - // Reset the old client virtual keybaord geom if necessary - // Old and new clients could be the same if focus moves between subsurfaces - if (m_trackedClient != focusedClient) { - if (m_trackedClient) { - m_trackedClient->setVirtualKeyboardGeometry(QRect()); - disconnect(m_trackedClient, &AbstractClient::frameGeometryChanged, this, &InputMethod::updateInputPanelState); - } - m_trackedClient = focusedClient; - if (m_trackedClient) { - connect(m_trackedClient, &AbstractClient::frameGeometryChanged, this, &InputMethod::updateInputPanelState, Qt::QueuedConnection); - } - } - updateInputPanelState(); - } else { + setTrackedClient(waylandServer()->findClient(focusedSurface)); + if (!focusedSurface) { setActive(false); } } diff --git a/src/inputmethod.h b/src/inputmethod.h index c739d54722..6a57219aaf 100644 --- a/src/inputmethod.h +++ b/src/inputmethod.h @@ -80,6 +80,7 @@ private: void setTextDirection(uint32_t serial, Qt::LayoutDirection direction); void startInputMethod(); void stopInputMethod(); + void setTrackedClient(AbstractClient *trackedClient); struct { QString text = QString();