Make access to xkbcommon_workaround.h more generic

It makes more sense to keep this workaround header together with the other
libxkbcommon files for a better access point since it's used by several *.pro
files.

Change-Id: I63d4eb58f6e7f3852834e41c4b6e058a2c962233
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
Gatis Paeglis 2013-04-29 20:26:25 +02:00 committed by The Qt Project
parent 43578e1901
commit a2a8a9ea01
6 changed files with 38 additions and 2 deletions

2
configure vendored
View File

@ -5290,9 +5290,11 @@ if [ "$CFG_XKBCOMMON" != "qt" ]; then
if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "xkbcommon >= 0.2.0" 2>/dev/null; then
QMAKE_CFLAGS_XKBCOMMON="`$PKG_CONFIG --cflags xkbcommon 2>/dev/null`"
QMAKE_LIBS_XKBCOMMON="`$PKG_CONFIG --libs xkbcommon 2>/dev/null`"
QMAKE_VERSION_XKBCOMMON="`$PKG_CONFIG --modversion xkbcommon 2>/dev/null`"
QMakeVar set QMAKE_CFLAGS_XKBCOMMON "$QMAKE_CFLAGS_XKBCOMMON"
QMakeVar set QMAKE_LIBS_XKBCOMMON "$QMAKE_LIBS_XKBCOMMON"
QMakeVar set QMAKE_VERSION_XKBCOMMON "$QMAKE_VERSION_XKBCOMMON"
CFG_XKBCOMMON=yes
else
CFG_XKBCOMMON=no

View File

@ -15,7 +15,6 @@ SOURCES += $$PWD/main.cpp \
HEADERS += $$PWD/qcomposeplatforminputcontext.h \
$$PWD/generator/qtablegenerator.h \
$$PWD/xkbcommon_workaround.h \
# libxkbcommon
contains(QT_CONFIG, xkbcommon-qt): {
@ -23,6 +22,10 @@ contains(QT_CONFIG, xkbcommon-qt): {
} else {
LIBS += $$QMAKE_LIBS_XKBCOMMON
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON
equals(QMAKE_VERSION_XKBCOMMON, "0.2.0") {
DEFINES += XKBCOMMON_0_2_0
INCLUDEPATH += ../../../3rdparty/xkbcommon/xkbcommon/
}
}
OTHER_FILES += $$PWD/compose.json

View File

@ -49,7 +49,10 @@
#include <QtCore/QString>
#include <xkbcommon/xkbcommon.h>
#ifdef XKBCOMMON_0_2_0
#include <xkbcommon_workaround.h>
#endif
//#define DEBUG_GENERATOR
@ -258,6 +261,7 @@ ushort TableGenerator::keysymToUtf8(quint32 sym)
int bytes;
chars.resize(8);
#ifdef XKBCOMMON_0_2_0
if (needWorkaround(sym)) {
quint32 codepoint;
if (sym == XKB_KEY_KP_Space)
@ -269,6 +273,9 @@ ushort TableGenerator::keysymToUtf8(quint32 sym)
} else {
bytes = xkb_keysym_to_utf8(sym, chars.data(), chars.size());
}
#else
bytes = xkb_keysym_to_utf8(sym, chars.data(), chars.size());
#endif
if (bytes == -1)
qWarning("TableGenerator::keysymToUtf8 - buffer too small");

View File

@ -53,6 +53,10 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformcursor.h>
#ifdef XKBCOMMON_0_2_0
#include <xkbcommon_workaround.h>
#endif
#ifndef XK_ISO_Left_Tab
#define XK_ISO_Left_Tab 0xFE20
#endif
@ -1311,7 +1315,23 @@ QString QXcbKeyboard::keysymToUnicode(xcb_keysym_t sym) const
int bytes;
chars.resize(7);
if ((bytes = xkb_keysym_to_utf8(sym, chars.data(), chars.size())) == -1)
#ifdef XKBCOMMON_0_2_0
if (needWorkaround(sym)) {
quint32 codepoint;
if (sym == XKB_KEY_KP_Space)
codepoint = XKB_KEY_space & 0x7f;
else
codepoint = sym & 0x7f;
bytes = utf32_to_utf8(codepoint, chars.data());
} else {
bytes = xkb_keysym_to_utf8(sym, chars.data(), chars.size());
}
#else
bytes = xkb_keysym_to_utf8(sym, chars.data(), chars.size());
#endif
if (bytes == -1)
qWarning("QXcbKeyboard::handleKeyEvent - buffer too small");
chars.resize(bytes-1);

View File

@ -124,4 +124,8 @@ contains(QT_CONFIG, xkbcommon-qt): {
} else {
LIBS += $$QMAKE_LIBS_XKBCOMMON
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON
equals(QMAKE_VERSION_XKBCOMMON, "0.2.0") {
DEFINES += XKBCOMMON_0_2_0
INCLUDEPATH += ../../../3rdparty/xkbcommon/xkbcommon/
}
}