From b4e4b26fa9260be921ee354e6d8f1e4754d04afe Mon Sep 17 00:00:00 2001 From: Brian Crowder Date: Fri, 19 Nov 2010 15:41:40 -0800 Subject: [PATCH] Bug 611466 - Minimal support for IME in Qt, r=dougt, a=dougt --- widget/src/qt/mozqwidget.cpp | 6 ++++++ widget/src/qt/nsWindow.cpp | 20 +++++++++----------- widget/src/qt/nsWindow.h | 4 +--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/widget/src/qt/mozqwidget.cpp b/widget/src/qt/mozqwidget.cpp index b66959cab89d..1956ffe8b527 100644 --- a/widget/src/qt/mozqwidget.cpp +++ b/widget/src/qt/mozqwidget.cpp @@ -238,6 +238,12 @@ bool MozQWidget::event ( QEvent * event ) mReceiver->OnGestureEvent(static_cast(event),handled); return handled; } + case QEvent::InputMethod: + { + PRBool handled = PR_FALSE; + mReceiver->imComposeEvent(static_cast(event),handled); + return handled; + } default: break; diff --git a/widget/src/qt/nsWindow.cpp b/widget/src/qt/nsWindow.cpp index f24b084667f2..364b891d4a30 100644 --- a/widget/src/qt/nsWindow.cpp +++ b/widget/src/qt/nsWindow.cpp @@ -2659,20 +2659,18 @@ nsWindow::contextMenuEvent(QGraphicsSceneContextMenuEvent *) } nsEventStatus -nsWindow::imStartEvent(QEvent *) +nsWindow::imComposeEvent(QInputMethodEvent *event, PRBool &handled) { - return nsEventStatus_eIgnore; -} + nsCompositionEvent start(PR_TRUE, NS_COMPOSITION_START, this); + DispatchEvent(&start); -nsEventStatus -nsWindow::imComposeEvent(QEvent *) -{ - return nsEventStatus_eIgnore; -} + nsTextEvent text(PR_TRUE, NS_TEXT_TEXT, this); + text.theText.Assign(event->commitString().utf16()); + DispatchEvent(&text); + + nsCompositionEvent end(PR_TRUE, NS_COMPOSITION_END, this); + DispatchEvent(&end); -nsEventStatus -nsWindow::imEndEvent(QEvent * ) -{ return nsEventStatus_eIgnore; } diff --git a/widget/src/qt/nsWindow.h b/widget/src/qt/nsWindow.h index 9cddee5807b0..06189f2f9790 100644 --- a/widget/src/qt/nsWindow.h +++ b/widget/src/qt/nsWindow.h @@ -277,9 +277,7 @@ protected: virtual nsEventStatus OnScrollEvent(QGraphicsSceneWheelEvent *); virtual nsEventStatus contextMenuEvent(QGraphicsSceneContextMenuEvent *); - virtual nsEventStatus imStartEvent(QEvent *); - virtual nsEventStatus imComposeEvent(QEvent *); - virtual nsEventStatus imEndEvent(QEvent *); + virtual nsEventStatus imComposeEvent(QInputMethodEvent *, PRBool &handled); virtual nsEventStatus OnDragEnter (QGraphicsSceneDragDropEvent *); virtual nsEventStatus OnDragMotionEvent(QGraphicsSceneDragDropEvent *); virtual nsEventStatus OnDragLeaveEvent(QGraphicsSceneDragDropEvent *);