Commit 95d4311e authored by Bart Ribbers's avatar Bart Ribbers
Browse files

community/kwin: backport fix for virtual keyboard

parent b6c34b21
From c9a87b4cf8f135d3d0daff36e9d0ce22a20f4630 Mon Sep 17 00:00:00 2001
From: Bhushan Shah <bhush94@gmail.com>
Date: Thu, 18 Feb 2021 04:46:21 +0000
Subject: [PATCH] inputmethod: toggle the inputmethod if we get second show
request
This is in a way working around bad protocol, input-method-unstable-v1
and also input-method-unstable-v2 does not have a way for input-method
to mark itself as "deactivated". This can happen when e.g. user closes
the virtual keyboard using swiping down or "close keyboard" button in
keyboard.
When this happens, the state between compositor, text_input and
input_method gets out of sync, compositor does not know that input
method got deactivated and hence it will continue sending various events
to it. The quick way around it is to change focus, which makes
compositor send deactivate request to input-method, that puts compositor
and input-method in sync again.
This patch aims to solve this by tracking the last state of input
method, If we know that input method is active and text input sends us
the show event, we toggle the input-method.
I will re-iterate that this is in no way proper solution, ideally
input-method-unstable-v3 or input-method-unstable-v2 even (since it is
not upstream anyway) gains the new request which essentially allows
input-method to sync enabled/disabled state with compositor.
(cherry picked from commit 892b8cf6cbc05f21415f7b8ef0168876b5e8a4af)
---
inputmethod.cpp | 20 ++++++++++++++------
inputmethod.h | 1 +
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/inputmethod.cpp b/inputmethod.cpp
index 8b9bd89f8..548244740 100644
--- a/inputmethod.cpp
+++ b/inputmethod.cpp
@@ -111,13 +111,21 @@ void InputMethod::init()
void InputMethod::show()
{
+ if (m_shown) {
+ waylandServer()->inputMethod()->sendDeactivate();
+ }
waylandServer()->inputMethod()->sendActivate();
+ if (m_shown) {
+ adoptInputMethodContext();
+ }
+ m_shown = true;
}
void InputMethod::hide()
{
waylandServer()->inputMethod()->sendDeactivate();
updateInputPanelState();
+ m_shown = false;
}
void InputMethod::clientAdded(AbstractClient* client)
@@ -433,12 +441,12 @@ void InputMethod::adoptInputMethodContext()
inputContext->sendContentType(t3->contentHints(), t3->contentPurpose());
}
- connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::keysym, waylandServer(), &keysymReceived);
- connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::commitString, waylandServer(), &commitString);
- connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::deleteSurroundingText, waylandServer(), &deleteSurroundingText);
- connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::cursorPosition, waylandServer(), &setCursorPosition);
- connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditString, this, &InputMethod::setPreeditString);
- connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditCursor, this, &InputMethod::setPreeditCursor);
+ connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::keysym, waylandServer(), &keysymReceived, Qt::UniqueConnection);
+ connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::commitString, waylandServer(), &commitString, Qt::UniqueConnection);
+ connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::deleteSurroundingText, waylandServer(), &deleteSurroundingText, Qt::UniqueConnection);
+ connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::cursorPosition, waylandServer(), &setCursorPosition, Qt::UniqueConnection);
+ connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditString, this, &InputMethod::setPreeditString, Qt::UniqueConnection);
+ connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditCursor, this, &InputMethod::setPreeditCursor, Qt::UniqueConnection);
}
void InputMethod::updateSni()
diff --git a/inputmethod.h b/inputmethod.h
index 5d66f74e1..f4a11ed2e 100644
--- a/inputmethod.h
+++ b/inputmethod.h
@@ -68,6 +68,7 @@ private:
} preedit;
bool m_enabled = false;
+ bool m_shown = false;
KStatusNotifierItem *m_sni = nullptr;
QPointer<AbstractClient> m_inputClient;
QPointer<AbstractClient> m_trackedClient;
--
GitLab
......@@ -2,7 +2,7 @@
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=kwin
pkgver=5.21.0
pkgrel=0
pkgrel=1
pkgdesc="An easy to use, but flexible, composited Window Manager"
# armhf blocked by qt5-qtdeclarative
# s390x blocked by kscreenlocker
......@@ -78,7 +78,9 @@ case "$pkgver" in
*.90*) _rel=unstable;;
*) _rel=stable;;
esac
source="https://download.kde.org/$_rel/plasma/$pkgver/kwin-$pkgver.tar.xz"
source="https://download.kde.org/$_rel/plasma/$pkgver/kwin-$pkgver.tar.xz
0001-toggle-inputmethod-if-receive-second-show-request.patch
"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
options="!check" # Broken
......@@ -103,4 +105,5 @@ package() {
# Remove CAP_SYS_NICE from kwin_wayland to make them work again
setcap -r "$pkgdir"/usr/bin/kwin_wayland
}
sha512sums="f311861f6ffa364eaa09aeb8d3a1ef384ac955fd630dcd40dc506feae393bc05e3b71c69a5340a70ca1f6d34ac7070ba7af6f9bc7d7bd9bd82d8842ec1e594d9 kwin-5.21.0.tar.xz"
sha512sums="f311861f6ffa364eaa09aeb8d3a1ef384ac955fd630dcd40dc506feae393bc05e3b71c69a5340a70ca1f6d34ac7070ba7af6f9bc7d7bd9bd82d8842ec1e594d9 kwin-5.21.0.tar.xz
201eed93fd1d18ab5fb8882856f7a20a1e4bd3fbf3bc991bfb65a431e5c6b4288bd29930d9446809cb47283e8acbc859e3918bbad752d86f9f9271e7505a669b 0001-toggle-inputmethod-if-receive-second-show-request.patch"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment