Commit 19715fbc authored by Zeno Albisser's avatar Zeno Albisser Committed by The Qt Project
Browse files

Implement basic support for input method events.


This is needed to get text input working again on Mac.
Underlines are currently being ignored.

Change-Id: I2a1074a1151e9be6f96ebe12fd0bb40a0eb63d6a
Reviewed-by: default avatarZeno Albisser <zeno.albisser@digia.com>
Showing with 27 additions and 0 deletions
......@@ -62,6 +62,7 @@
#include <QEvent>
#include <QFocusEvent>
#include <QGuiApplication>
#include <QInputMethodEvent>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QScreen>
......@@ -703,6 +704,9 @@ bool RenderWidgetHostViewQt::forwardEvent(QEvent *event)
case QEvent::FocusOut:
handleFocusEvent(static_cast<QFocusEvent*>(event));
break;
case QEvent::InputMethod:
handleInputMethodEvent(static_cast<QInputMethodEvent*>(event));
break;
default:
return false;
}
......@@ -850,6 +854,22 @@ void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev)
m_host->ForwardKeyboardEvent(WebEventFactory::toWebKeyboardEvent(ev));
}
void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
{
if (!m_host)
return;
if (ev->commitString().length())
m_host->ImeConfirmComposition(toString16(ev->commitString()), gfx::Range::InvalidRange(), false);
if (ev->preeditString().length()) {
// FIXME: Implement translation from QInputMethodEvent::Attribute list to WebKit::WebCompositionUnderlines.
std::vector<WebKit::WebCompositionUnderline> underlines;
int start = ev->replacementStart();
m_host->ImeSetComposition(toString16(ev->preeditString()), underlines, start, start + ev->replacementLength());
}
}
void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *ev)
{
m_host->ForwardWheelEvent(WebEventFactory::toWebWheelEvent(ev, dpiScale()));
......
......@@ -180,6 +180,7 @@ public:
void handleTouchEvent(QTouchEvent*);
void handleHoverEvent(QHoverEvent*);
void handleFocusEvent(QFocusEvent*);
void handleInputMethodEvent(QInputMethodEvent*);
#if defined(OS_MACOSX)
virtual void SetTakesFocusOnlyOnMouseDown(bool flag) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
......
......@@ -55,6 +55,7 @@ class QQuickWindow;
class QSGNode;
class QVariant;
class QWindow;
class QInputMethodEvent;
QT_END_NAMESPACE
class WebContentsAdapterClient;
......
......@@ -202,6 +202,11 @@ public:
return m_client->inputMethodQuery(query);
}
virtual void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE
{
m_client->forwardEvent(event);
}
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
......
Supports Markdown
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