Calculate Qt::Key from keysym for IBus ForwardKeyEvent signal
QKeyEvent instance requires Qt::Key but currently X11 keysym is assigned and the IBus QT module forwards the wrong key events. Now QXkbCommon::keysymToQtKey() can generate Qt::Key from keysym and forward the correct key events. Change-Id: I25f0a9e9319b4a5f42847f8592ad3a30f6c9349d Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
This commit is contained in:
parent
4d11fc1d22
commit
9b6222598c
@ -1,6 +1,6 @@
|
||||
TARGET = ibusplatforminputcontextplugin
|
||||
|
||||
QT += dbus gui-private
|
||||
QT += dbus gui-private xkbcommon_support-private
|
||||
SOURCES += $$PWD/qibusplatforminputcontext.cpp \
|
||||
$$PWD/qibusproxy.cpp \
|
||||
$$PWD/qibusproxyportal.cpp \
|
||||
|
@ -51,6 +51,8 @@
|
||||
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
|
||||
#include <QtXkbCommonSupport/private/qxkbcommon_p.h>
|
||||
|
||||
#include "qibusproxy.h"
|
||||
#include "qibusproxyportal.h"
|
||||
#include "qibusinputcontextproxy.h"
|
||||
@ -335,14 +337,12 @@ void QIBusPlatformInputContext::forwardKeyEvent(uint keyval, uint keycode, uint
|
||||
if (!input)
|
||||
return;
|
||||
|
||||
if (debug)
|
||||
qDebug() << "forwardKeyEvent" << keyval << keycode << state;
|
||||
|
||||
QEvent::Type type = QEvent::KeyPress;
|
||||
if (state & IBUS_RELEASE_MASK)
|
||||
type = QEvent::KeyRelease;
|
||||
|
||||
state &= ~IBUS_RELEASE_MASK;
|
||||
keycode += 8;
|
||||
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier;
|
||||
if (state & IBUS_SHIFT_MASK)
|
||||
@ -354,7 +354,13 @@ void QIBusPlatformInputContext::forwardKeyEvent(uint keyval, uint keycode, uint
|
||||
if (state & IBUS_META_MASK)
|
||||
modifiers |= Qt::MetaModifier;
|
||||
|
||||
QKeyEvent event(type, keyval, modifiers, QString(keyval));
|
||||
int qtcode = QXkbCommon::keysymToQtKey(keyval, modifiers);
|
||||
QString text = QXkbCommon::lookupStringNoKeysymTransformations(keyval);
|
||||
|
||||
if (debug)
|
||||
qDebug() << "forwardKeyEvent" << keyval << keycode << state << modifiers << qtcode << text;
|
||||
|
||||
QKeyEvent event(type, qtcode, modifiers, keycode, keyval, state, text);
|
||||
QCoreApplication::sendEvent(input, &event);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
TEMPLATE = subdirs
|
||||
QT_FOR_CONFIG += gui-private
|
||||
|
||||
qtHaveModule(dbus) {
|
||||
!mac:!win32:SUBDIRS += ibus
|
||||
qtConfig(xkbcommon) {
|
||||
SUBDIRS += compose
|
||||
|
||||
qtHaveModule(dbus) {
|
||||
!macos:!win32:SUBDIRS += ibus
|
||||
}
|
||||
}
|
||||
|
||||
qtConfig(xkbcommon): SUBDIRS += compose
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user