void IBusInputContext::hidePreedit () { if (!preedit_visible) return; updatePreedit (preedit_string, preedit_attrs, preedit_cursor_pos, FALSE); }
bool QHangulPlatformInputContext::backspace() { bool ret = hangul_ic_backspace(m_hic); if (ret) { QString str = getPreeditString(); updatePreedit(str); } return ret; }
void IBusInputContext::showPreedit () { if (preedit_visible) return; updatePreedit (preedit_string, preedit_attrs, preedit_cursor_pos, TRUE); }
void GtkInputMethodFilter::handlePreeditEnd() { if (m_preventNextCommit || !m_enabled) return; m_preedit = String(); m_cursorOffset = 0; m_preeditChanged = true; if (!m_filteringKeyEvent) updatePreedit(); }
void QUimInputContext::reset() { #ifdef ENABLE_DEBUG qDebug( "QUimInputContext::reset()" ); #endif QInputContext::reset(); candwinIsActive = FALSE; cwin->hide(); uim_reset_context( m_uc ); #ifdef Q_WS_X11 mCompose->reset(); #endif clearPreedit(); updatePreedit(); }
void QHangulPlatformInputContext::reset() { if (m_candidateList != NULL && m_candidateList->isVisible()) { m_candidateList->close(); } const ucschar *flushed = hangul_ic_flush(m_hic); // we do not send preedit update IMEvent // because commit() send InputMethodEnd event and it remove preedit string QString commitString = ucsToQString(flushed); if (!commitString.isEmpty()) { commitText(commitString); } else { updatePreedit(""); } }
bool QHangulPlatformInputContext::filterEvent(const QEvent *event) { if (event->type() != QEvent::KeyPress) return false; const QKeyEvent *keyevent = static_cast<const QKeyEvent*>(event); if (m_candidateList != NULL && m_candidateList->isVisible()) { if (m_candidateList->filterEvent(keyevent)) { if (m_candidateList->isSelected()) { hangul_ic_reset(m_hic); QString candidate(m_candidateList->getCandidate()); commitText(candidate); } m_candidateList->close(); } return true; } if (keyevent->key() == Qt::Key_Shift) return false; if (keyevent->key() == Qt::Key_Backspace) return backspace(); if (isTriggerKey(keyevent)) { if (m_mode == MODE_DIRECT) { m_mode = MODE_HANGUL; } else { reset(); m_mode = MODE_DIRECT; } setModeInfo(m_mode); return true; } if (isCandidateKey(keyevent)) { return popupCandidateList(); } if (keyevent->modifiers() & Qt::ControlModifier || keyevent->modifiers() & Qt::AltModifier || keyevent->modifiers() & Qt::MetaModifier) { reset(); return false; } if (m_mode == MODE_HANGUL) { QString text = keyevent->text(); if (keyevent->modifiers() & Qt::ShiftModifier) text = text.toUpper(); else text = text.toLower(); int ascii = 0; if (!text.isEmpty()) ascii = text[0].unicode(); bool ret = hangul_ic_process(m_hic, ascii); QString commitString = getCommitString(); if (!commitString.isEmpty()) commitText(commitString); QString preeditString = getPreeditString(); if (!preeditString.isEmpty()) updatePreedit(preeditString); return ret; } return false; }
void QUimInputContext::restoreContext() { updatePreedit(); }
bool GtkInputMethodFilter::filterKeyEvent(GdkEventKey* event) { if (!canEdit() || !m_enabled) return sendSimpleKeyEvent(event); m_preeditChanged = false; m_filteringKeyEvent = true; unsigned int lastFilteredKeyPressCodeWithNoResults = m_lastFilteredKeyPressCodeWithNoResults; m_lastFilteredKeyPressCodeWithNoResults = GDK_KEY_VoidSymbol; bool filtered = gtk_im_context_filter_keypress(m_context.get(), event); m_filteringKeyEvent = false; bool justSentFakeKeyUp = m_justSentFakeKeyUp; m_justSentFakeKeyUp = false; if (justSentFakeKeyUp && event->type == GDK_KEY_RELEASE) return true; // Simple input methods work such that even normal keystrokes fire the // commit signal. We detect those situations and treat them as normal // key events, supplying the commit string as the key character. if (filtered && !m_composingTextCurrently && !m_preeditChanged && m_confirmedComposition.length() == 1) { bool result = sendSimpleKeyEvent(event, m_confirmedComposition); m_confirmedComposition = String(); return result; } if (filtered && event->type == GDK_KEY_PRESS) { if (!m_preeditChanged && m_confirmedComposition.isNull()) { m_composingTextCurrently = true; m_lastFilteredKeyPressCodeWithNoResults = event->keyval; return true; } bool result = sendKeyEventWithCompositionResults(event); if (!m_confirmedComposition.isEmpty()) { m_composingTextCurrently = false; m_confirmedComposition = String(); } return result; } // If we previously filtered a key press event and it yielded no results. Suppress // the corresponding key release event to avoid confusing the web content. if (event->type == GDK_KEY_RELEASE && lastFilteredKeyPressCodeWithNoResults == event->keyval) return true; // At this point a keystroke was either: // 1. Unfiltered // 2. A filtered keyup event. As the IME code in EditorClient.h doesn't // ever look at keyup events, we send any composition results before // the key event. // Both might have composition results or not. // // It's important to send the composition results before the event // because some IM modules operate that way. For example (taken from // the Chromium source), the latin-post input method gives this sequence // when you press 'a' and then backspace: // 1. keydown 'a' (filtered) // 2. preedit changed to "a" // 3. keyup 'a' (unfiltered) // 4. keydown Backspace (unfiltered) // 5. commit "a" // 6. preedit end if (!m_confirmedComposition.isEmpty()) confirmComposition(); if (m_preeditChanged) updatePreedit(); return sendSimpleKeyEvent(event); }