From 4c6c4e6717f38e7df279f86758485db3e44b51e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 3 Aug 2016 08:31:58 +0200 Subject: [PATCH] [wayland] Always have a keyboard on the Seat Summary: This is a workaround for QTBUG-54371 resulting in QtWayland never requesting the input methods panel without having keyboard focus. Thus also the virtual keyboard is not working. With this change we go back to always announcing a keyboard and binding the virtual keyboard to whether we don't have an alpha-numeric keyboard instead of whether there is a keyboard on the seat. Reviewers: #kwin, #plasma_on_wayland, bshah Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2343 --- input.cpp | 18 +++++++++++++++--- input.h | 4 ++++ virtualkeyboard.cpp | 9 +++++---- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/input.cpp b/input.cpp index 69deb308c8..17312c595a 100644 --- a/input.cpp +++ b/input.cpp @@ -1157,15 +1157,17 @@ void InputRedirection::setupLibInput() connect(kwinApp(), &Application::screensCreated, this, &InputRedirection::setupLibInputWithScreens); } if (auto s = findSeat()) { - s->setHasKeyboard(conn->hasAlphaNumericKeyboard()); + // Workaround for QTBUG-54371: if there is no real keyboard Qt doesn't request virtual keyboard + s->setHasKeyboard(true); s->setHasPointer(conn->hasPointer()); s->setHasTouch(conn->hasTouch()); connect(conn, &LibInput::Connection::hasAlphaNumericKeyboardChanged, this, - [this, s] (bool set) { + [this] (bool set) { if (m_libInput->isSuspended()) { return; } - s->setHasKeyboard(set); + // TODO: this should update the seat, only workaround for QTBUG-54371 + emit hasAlphaNumericKeyboardChanged(set); } ); connect(conn, &LibInput::Connection::hasPointerChanged, this, @@ -1196,6 +1198,16 @@ void InputRedirection::setupLibInput() #endif } +bool InputRedirection::hasAlphaNumericKeyboard() +{ +#if HAVE_INPUT + if (m_libInput) { + return m_libInput->hasAlphaNumericKeyboard(); + } +#endif + return true; +} + void InputRedirection::setupLibInputWithScreens() { #if HAVE_INPUT diff --git a/input.h b/input.h index 896aec2484..2829344a12 100644 --- a/input.h +++ b/input.h @@ -164,6 +164,8 @@ public: return m_touch; } + bool hasAlphaNumericKeyboard(); + Q_SIGNALS: /** * @brief Emitted when the global pointer position changed @@ -203,6 +205,8 @@ Q_SIGNALS: */ void keyStateChanged(quint32 keyCode, InputRedirection::KeyboardKeyState state); + void hasAlphaNumericKeyboardChanged(bool set); + private: void setupLibInput(); void setupLibInputWithScreens(); diff --git a/virtualkeyboard.cpp b/virtualkeyboard.cpp index a18a36c402..3ae3e12f91 100644 --- a/virtualkeyboard.cpp +++ b/virtualkeyboard.cpp @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "virtualkeyboard.h" +#include "input.h" #include "utils.h" #include "screens.h" #include "wayland_server.h" @@ -78,10 +79,10 @@ void VirtualKeyboard::init() m_inputWindow->setProperty("__kwin_input_method", true); if (waylandServer()) { - m_enabled = !waylandServer()->seat()->hasKeyboard(); - connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::hasKeyboardChanged, this, - [this] { - setEnabled(!waylandServer()->seat()->hasKeyboard()); + m_enabled = !input()->hasAlphaNumericKeyboard(); + connect(input(), &InputRedirection::hasAlphaNumericKeyboardChanged, this, + [this] (bool set) { + setEnabled(!set); } ); }