[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
This commit is contained in:
Martin Gräßlin 2016-08-03 08:31:58 +02:00
parent 6a6af0e8b5
commit 4c6c4e6717
3 changed files with 24 additions and 7 deletions

View file

@ -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

View file

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

View file

@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#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);
}
);
}