Commit 5d101ce2 authored by Martin Flöser's avatar Martin Flöser

Migrate Xkb::toQtKey away from KKeyServer

Summary:
Turn Xkb into a QObject

Reduced dependencies on other classes and allows to emit signal directly
instead of emitting a signal on another class.

Dependency inject KWayland::Server::SeatInterface into Xkb

No need to depend on WaylandServer from within Xkb.

[autotests] Add test case for Xkb::toQtKey

Tests all key codes KKeyServer is able to map to Qt.

Migrate Xkb::toQtKey away from KKeyServer

The regression in kwindowsystem in
32526718eae99ccb594360627586eebdf793372b showed once more that it's time
to migrate the xkb keysym to Qt::Key mapping away from KKeyServer. The
main problem with KKeyServer is that it's made for X11 and we don't have
X11 here. This causes warnings printed at runtime and the code only
works by accident at all because KKeyServer fails to initialise
modifiers. That is normally KKeyServer would include the modifiers, but
that is nothing we are interested in for mapping xkb keysyms to Qt::Key.

So to address this, KWin now implements the mapping itself. It's based
on the implementation in KKeyServer, but also improved by providing
faster xkb to Qt conversion (which matters for KWin more than the other
direction).

Long term plan is to extend this so that also on X11 it can be used.
Then it should be split out and be used in KKeyServer as a replacement
for the current implementation which could support both X11 and Wayland.

Test Plan:
New test case added which covers all keysyms supported by
existing KKeyserver mapping

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7336
parent 801fe410
......@@ -484,36 +484,6 @@ void XkbTest::testToQtKey()
{
Xkb xkb;
QFETCH(xkb_keysym_t, keySym);
QEXPECT_FAIL("e0", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("e1", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("e2", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("e3", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("e4", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("e5", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("e6", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("e7", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("e8", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("e9", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("ea", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("eb", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("ec", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("ed", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("ee", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("ef", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("f0", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("f1", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("f2", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("f3", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("f4", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("f5", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("f6", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("f8", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("f9", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("fa", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("fb", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("fc", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("fd", "Incorrectly mapped by KKeyServer", Continue);
QEXPECT_FAIL("fe", "Incorrectly mapped by KKeyServer", Continue);
QTEST(xkb.toQtKey(keySym), "qt");
}
......
......@@ -18,10 +18,10 @@ 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 "xkb.h"
#include "xkb_qt_mapping.h"
#include "utils.h"
// frameworks
#include <KConfigGroup>
#include <KKeyServer>
// KWayland
#include <KWayland/Server/seat_interface.h>
// Qt
......@@ -442,12 +442,7 @@ QString Xkb::toString(xkb_keysym_t keysym)
Qt::Key Xkb::toQtKey(xkb_keysym_t keysym) const
{
int key = Qt::Key_unknown;
KKeyServer::symXToKeyQt(keysym, &key);
if (key & Qt::KeyboardModifierMask) {
key &= ~Qt::KeyboardModifierMask;
}
return static_cast<Qt::Key>(key);
return xkbToQtKey(keysym);
}
bool Xkb::shouldKeyRepeat(quint32 key) const
......
This diff is collapsed.
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