qtbase/tests/auto/wayland/shared/textinput.cpp
Gatis Paeglis 9a782df3e7 client: rework input method handling
The existing solution was parsing compose tables on startup, it is
better to lazy initialize the compose table/state on a first key press,
instead of doing it on an application startup. This logic is inside of
the compose input plugin.

The existing code did not utilize correctly how Qt handles complex text
input. It used libxkbcommon-compose APIs to compose user input and then
passed the same input again to QPlatformInputContext (from
QWaylandInputDevice::Keyboard::sendKey), which was erroneous. This also
means that code was forcing "xkb compose", and did not respect QT_IM_MODULE
at client-side.

From commit that added compose key handling (dd13698a730594d9f40baa367dcfe05bc23f1016):

"We should expand on it in the future to handle things like resetting
the compose state on text field switching".

This is now handled by properly utilizing Qt IM framework.

Converted QWaylandInputDevice::Keyboard::sendKey into a class member function
to avoid adding one more arg (mXkbContext) to the already long argument list.
That whole function should be simplified, but that is out-of-scope for this
patch.

The reworked code uses qxkbcommon support library to reduce code duplication
between platforms and to unify behavior.

Some users might mistakenly think that this patch introduces a regression
with Qt on KDE, but it is actually a KWin/Wayland compositor bug:

https://bugs.kde.org/show_bug.cgi?id=405388

The work around on KDE is to use QT_IM_MODULE at client-side to select
input method, as KWin compositor over the wire  supports only the qtvirtualkeyboard
module. Setting this envvar is not someting out of the ordinary for users
on Linux. Input method handling at compositor-side is new feature and
clearly not very well supported yet.

Task-number: QTBUG-65503
Change-Id: Ie511d950396fa2fb6cbe6672996cee9791f3ab11
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-04-15 14:10:28 +00:00

46 lines
1.6 KiB
C++

/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "textinput.h"
namespace MockCompositor {
TextInputManager::TextInputManager(CoreCompositor *compositor)
{
init(compositor->m_display, 1);
}
void TextInputManager::zwp_text_input_manager_v2_get_text_input(Resource *resource, uint32_t id, wl_resource *seatResource)
{
Q_UNUSED(resource);
Q_UNUSED(id);
Q_UNUSED(seatResource);
}
} // namespace MockCompositor