inputmethod: Expose VirtualKeyboard.willShowOnActive on dbus

It can help clients predict how KWin will react. Sometimes, the noise of
seeing a virtual keyboard pop up is reason enough not to focus an input
field.
This commit is contained in:
Aleix Pol 2021-11-30 15:52:47 +01:00 committed by Aleix Pol Gonzalez
parent 6a99bfd2f4
commit 13b85d77fc
4 changed files with 11 additions and 3 deletions

View file

@ -130,7 +130,7 @@ void InputMethod::hide()
inputContext->sendReset();
}
bool InputMethod::touchEventTriggered() const
bool InputMethod::shouldShowOnActive() const
{
return input()->touch()
&& input()->touch()->lastEventTime() > input()->keyboard()->lastEventTime()
@ -263,7 +263,7 @@ void InputMethod::textInputInterfaceV2StateUpdated(quint32 serial, KWaylandServe
if (!t2 || !t2->isEnabled()) {
return;
}
if (m_inputClient && touchEventTriggered()) {
if (m_inputClient && shouldShowOnActive()) {
m_inputClient->allow();
}
switch (reason) {
@ -608,7 +608,7 @@ void InputMethod::updateInputPanelState()
return;
}
if (m_inputClient && touchEventTriggered()) {
if (m_inputClient && shouldShowOnActive()) {
m_inputClient->allow();
}

View file

@ -61,6 +61,7 @@ public:
void setInputMethodCommand(const QString &path);
KWaylandServer::InputMethodGrabV1 *keyboardGrab();
bool shouldShowOnActive() const;
Q_SIGNALS:
void activeChanged(bool active);

View file

@ -58,4 +58,9 @@ bool VirtualKeyboardDBus::isAvailable() const
return m_inputMethod->isAvailable();
}
bool VirtualKeyboardDBus::willShowOnActive() const
{
return isAvailable() && isEnabled() && m_inputMethod->shouldShowOnActive();
}
}

View file

@ -33,6 +33,8 @@ public:
void setEnabled(bool enabled);
void setActive(bool active);
Q_SCRIPTABLE bool willShowOnActive() const;
Q_SIGNALS:
Q_SCRIPTABLE void enabledChanged();
Q_SCRIPTABLE void activeChanged();