inputmethod: Also update the trackingClient when there's none set

Also moves the setting code to a separate method for readability
This commit is contained in:
Aleix Pol 2021-05-21 18:26:49 +02:00
parent f60b9176da
commit 8fad7aa4f3
2 changed files with 21 additions and 16 deletions

View file

@ -166,25 +166,29 @@ void InputMethod::clientAdded(AbstractClient* client)
connect(m_inputClient, &AbstractClient::windowClosed, this, &InputMethod::hide);
}
void InputMethod::handleFocusedSurfaceChanged()
void InputMethod::setTrackedClient(AbstractClient* trackedClient)
{
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 == trackedClient) {
return;
}
if (m_trackedClient) {
m_trackedClient->setVirtualKeyboardGeometry(QRect());
disconnect(m_trackedClient, &AbstractClient::frameGeometryChanged, this, &InputMethod::updateInputPanelState);
}
m_trackedClient = focusedClient;
m_trackedClient = trackedClient;
if (m_trackedClient) {
connect(m_trackedClient, &AbstractClient::frameGeometryChanged, this, &InputMethod::updateInputPanelState, Qt::QueuedConnection);
}
}
updateInputPanelState();
} else {
}
void InputMethod::handleFocusedSurfaceChanged()
{
SurfaceInterface *focusedSurface = waylandServer()->seat()->focusedTextInputSurface();
setTrackedClient(waylandServer()->findClient(focusedSurface));
if (!focusedSurface) {
setActive(false);
}
}

View file

@ -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();