Skip to content

Commit

Permalink
Fixed composition with preEdit string, make it really works with swyp…
Browse files Browse the repository at this point in the history
…e keyboard
  • Loading branch information
tmeshkova committed Jan 22, 2013
1 parent 64781fb commit 5189a2d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 47 deletions.
40 changes: 28 additions & 12 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ EmbedLiteViewThreadChild::EmbedLiteViewThreadChild(uint32_t aId)
, mDispatchSynthMouseEvents(true)
, mHadResizeSinceLastFrameUpdate(false)
, mModalDepth(0)
, mIsComposition(false)
{
LOGT();
AddRef();
Expand Down Expand Up @@ -347,31 +348,46 @@ EmbedLiteViewThreadChild::RecvHandleTextEvent(const nsString& commit, const nsSt
if (!widget)
return false;

{
nsCompositionEvent event(true, NS_COMPOSITION_START, widget);
mHelper->InitEvent(event, nullptr);
event.data = commit;
mHelper->DispatchWidgetEvent(event);
// probably logic here is over engineered, but clean enough
bool prevIsComposition = mIsComposition;
bool StartComposite = !prevIsComposition && commit.IsEmpty() && !preEdit.IsEmpty();
bool UpdateComposite = prevIsComposition && commit.IsEmpty() && !preEdit.IsEmpty();
bool EndComposite = prevIsComposition && !commit.IsEmpty() && preEdit.IsEmpty();
mIsComposition = UpdateComposite || StartComposite;
nsString pushStr = preEdit.IsEmpty() ? commit : preEdit;
if (!commit.IsEmpty() && !EndComposite) {
StartComposite = UpdateComposite = EndComposite = true;
}

if (StartComposite)
{
nsCompositionEvent event(true, NS_COMPOSITION_UPDATE, widget);
nsCompositionEvent event(true, NS_COMPOSITION_START, widget);
mHelper->InitEvent(event, nullptr);
event.data = commit;
event.data = pushStr;
mHelper->DispatchWidgetEvent(event);
}

if (StartComposite || UpdateComposite || EndComposite)
{
nsTextEvent event(true, NS_TEXT_TEXT, widget);
mHelper->InitEvent(event, nullptr);
event.theText = commit;
mHelper->DispatchWidgetEvent(event);
{
nsCompositionEvent event(true, NS_COMPOSITION_UPDATE, widget);
mHelper->InitEvent(event, nullptr);
event.data = pushStr;
mHelper->DispatchWidgetEvent(event);
}
{
nsTextEvent event(true, NS_TEXT_TEXT, widget);
mHelper->InitEvent(event, nullptr);
event.theText = pushStr;
mHelper->DispatchWidgetEvent(event);
}
}

if (EndComposite)
{
nsCompositionEvent event(true, NS_COMPOSITION_END, widget);
mHelper->InitEvent(event, nullptr);
event.data = commit;
event.data = pushStr;
mHelper->DispatchWidgetEvent(event);
}

Expand Down
1 change: 1 addition & 0 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class EmbedLiteViewThreadChild : public PEmbedLiteViewChild,
bool mDispatchSynthMouseEvents;
bool mHadResizeSinceLastFrameUpdate;
int mModalDepth;
bool mIsComposition;
std::map<uint64_t, EmbedLiteViewPromptResponse*> modalWinMap;

DISALLOW_EVIL_CONSTRUCTORS(EmbedLiteViewThreadChild);
Expand Down
37 changes: 2 additions & 35 deletions embedding/embedlite/tests/qt/qtwidget/qgraphicsmozview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,39 +645,6 @@ void QGraphicsMozView::keyReleaseEvent(QKeyEvent* event)
QVariant
QGraphicsMozView::inputMethodQuery(Qt::InputMethodQuery aQuery) const
{
if (aQuery == 10001) {
// LOGT("VisualizationPriorityQuery");
}
if (aQuery == 10003) {
// LOGT("ImCorrectionEnabledQuery");
}
if (aQuery == 10004) {
// LOGT("ImModeQuery");
}
if (aQuery == 10005) {
// LOGT("InputMethodToolbarIdQuery");
}
if (aQuery == 10006) {
// LOGT("InputMethodAttributeExtensionIdQuery");
}
if (aQuery == 10007) {
// LOGT("InputMethodToolbarQuery");
}
if (aQuery == Qt::ImCurrentSelection) {
// LOGT("Qt::ImCurrentSelection");
}
if (aQuery == Qt::ImMicroFocus) {
// LOGT("Qt::ImMicroFocus");
}
if (aQuery == Qt::ImSurroundingText) {
// LOGT("Qt::ImSurroundingText");
}
if (aQuery == Qt::ImCursorPosition) {
// LOGT("Qt::ImCursorPosition");
}
if (aQuery == Qt::ImAnchorPosition) {
// LOGT("Qt::ImAnchorPosition");
}

return QVariant(0);
static bool commitNow = getenv("DO_FAST_COMMIT") != 0;
return commitNow ? QVariant(0) : QVariant();
}

0 comments on commit 5189a2d

Please sign in to comment.