Exemple #1
0
int InputContext::pushKey(keyState *k)
{
    int key = k->key();
    int rv = 1;

    if (key != UKey_Other) {
	if (k->is_push()) {
	    rv = uim_press_key(mUc, key, k->modifier());
	    if (!(g_option_mask & OPT_ON_DEMAND_SYNC)) {
		// Call uim_release_key here since we don't filter key
		// release event with full-synchronous-method for now.
		uim_release_key(mUc, key, k->modifier());
	    }
	}
	else
	    rv = uim_release_key(mUc, key, k->modifier());
    }

    if (rv) {
	if (k->check_compose())
	    return UPDATE_MODE;
	else
	    return COMMIT_RAW;
    } else {
	return UPDATE_MODE;
    }
}
Exemple #2
0
const char *
send_key(const char *args)
{
    ic_t *ic;
    int code;
    int mod;
    char *raw;
    int rawcommit;

    if (!vp_iobuf_get_args(iobuf, args, "pddb", &ic, &code, &mod, &raw, 0))
        return vp_iobuf_return(iobuf);

/*
 * @return 0 if IM not handle the event, otherwise the event is handled by IM so please stop key event handling.
 * uim_press_key()
 *
 * i don't understand.
 */
    rawcommit = uim_press_key(ic->cx, code, mod);
    uim_release_key(ic->cx, code, mod);
    if (rawcommit) {
        vp_iobuf_put_str(iobuf, "commit_raw");
        vp_iobuf_put_bin(iobuf, raw, strlen(raw));
    }
    return vp_iobuf_return(iobuf);
}
Exemple #3
0
static int
process_keyvector(int serial, int cid, uim_key ukey, const char *keyname)
{
  int ret, ret2;

  if (! focused ||
	  current == NULL || 
	  (current != NULL && current->context_id != cid)) {

	if (set_current_uim_agent_context(get_uim_agent_context(cid)) < 0) {
	  debug_printf(DEBUG_WARNING, "context %d not found\n", cid);
	  return -1;
	}
  }

  focused = 1;


  if (ukey.key >= 0) {
	/* key input is received by requested context */
	debug_printf(DEBUG_NOTE, "uim_press_key\n");
	ret = uim_press_key(current->context, ukey.key, ukey.mod);

	debug_printf(DEBUG_NOTE, "uim_release_key\n");
	ret2 = uim_release_key(current->context, ukey.key, ukey.mod);

	debug_printf(DEBUG_NOTE, "ret = %d, ret2 = %d\n", ret, ret2);

	show_commit_string_uim_agent_context(current);

	if (ret > 0) {
	  /* uim did not process the key */

	  if (ukey.mod & UMod_Shift && ukey.key >= 0x41 && ukey.key <= 0x5a)
		ukey.mod &= ~UMod_Shift;

	  if (ukey.mod != 0 || ukey.key > 255) {

		a_printf(" ( n [(");

		if (ukey.mod & UMod_Control) a_printf("control ");
		if (ukey.mod & UMod_Alt) a_printf("meta ");
		/* if (ukey->mod & UMod_Shift) a_printf("shift "); */
		if (ukey.mod & UMod_Hyper) a_printf("hyper ");
		if (ukey.mod & UMod_Super) a_printf("super ");

		if (ukey.key > 255)
		  a_printf("%s", keyname);
		else
		  a_printf("%d", ukey.key);

		a_printf(")] ) ");

	  } else {
		a_printf(" ( n [%d] ) ", ukey.key);
	  }
			
	}
	show_preedit_uim_agent_context(current);
	show_candidate_uim_agent_context(current);
  } else {
	/* ukey.key < 0 */
	show_commit_string_uim_agent_context(current);
	show_preedit_uim_agent_context(current);
	show_candidate_uim_agent_context(current);
	a_printf(" ( n ) "); /* dummy */
  }

  /*show_prop_uim_agent_context(current);*/
  check_prop_list_update(current);

  check_default_engine();

  return 1;
}
Exemple #4
0
bool QUimInputContext::filterEvent( const QEvent *event )
{
#ifdef ENABLE_DEBUG
    // qDebug("filterEvent");
#endif

    int type = event->type();

    if ( type != QEvent::KeyPress &&
            type != QEvent::KeyRelease )
        return FALSE;

    QKeyEvent *keyevent = ( QKeyEvent * ) event;
    int qkey = keyevent->key();

    int modifier = 0;
    if ( keyevent->state() & Qt::ShiftButton )
        modifier |= UMod_Shift;
    if ( keyevent->state() & Qt::ControlButton )
        modifier |= UMod_Control;
    if ( keyevent->state() & Qt::AltButton )
        modifier |= UMod_Alt;
#if defined(Q_WS_X11)
    if ( keyevent->state() & Qt::MetaButton )
        modifier |= UMod_Meta;
#endif

    int key = 0;
    if ( isascii( qkey ) && isprint( qkey ) )
    {
        int ascii = keyevent->ascii();
        if ( isalpha( ascii ) )
        {
            key = ascii;  // uim needs lower/upper encoded key
        }
        else
        {
            if ( keyevent->state() & Qt::ControlButton &&
                 ( ascii >= 0x01 && ascii <= 0x1a ) )
                if ( keyevent->state() & Qt::ShiftButton )
                    key = ascii + 0x40;
                else
                    key = ascii + 0x60;
            else
                key = qkey;
        }
    }
    else if ( qkey == Qt::Key_unknown )
    {
        QString text = keyevent->text();
        if ( !text.isNull() )
        {
            QChar s = text.at(0);
            key = unicodeToUKey ( s.unicode() );
        }
        else
        {
            key = UKey_Other;
        }
    }
    else
    {
        if ( qkey >= Qt::Key_F1 && qkey <= Qt::Key_F35 )
        {
            key = qkey - Qt::Key_F1 + UKey_F1;
        }
        else if ( qkey >= Qt::Key_Dead_Grave && qkey <= Qt::Key_Dead_Horn )
        {
            key = qkey - Qt::Key_Dead_Grave + UKey_Dead_Grave;
        }
        else if ( qkey >= Qt::Key_Kanji && qkey <= Qt::Key_Eisu_toggle )
        {
            key = qkey - Qt::Key_Kanji + UKey_Kanji;
        }
        else if ( qkey >= Qt::Key_Hangul && qkey <= Qt::Key_Hangul_Special )
        {
            key = qkey - Qt::Key_Hangul + UKey_Hangul;
        }
        else
        {
            switch ( qkey )
            {
            case Qt::Key_Tab: key = UKey_Tab; break;
            case Qt::Key_BackSpace: key = UKey_Backspace; break;
            case Qt::Key_Escape: key = UKey_Escape; break;
            case Qt::Key_Delete: key = UKey_Delete; break;
            case Qt::Key_Return: key = UKey_Return; break;
            case Qt::Key_Left: key = UKey_Left; break;
            case Qt::Key_Up: key = UKey_Up; break;
            case Qt::Key_Right: key = UKey_Right; break;
            case Qt::Key_Down: key = UKey_Down; break;
            case Qt::Key_Prior: key = UKey_Prior; break;
            case Qt::Key_Next: key = UKey_Next; break;
            case Qt::Key_Home: key = UKey_Home; break;
            case Qt::Key_End: key = UKey_End; break;
            case Qt::Key_Multi_key: key = UKey_Multi_key; break;
            case Qt::Key_Mode_switch: key = UKey_Mode_switch; break;
            case Qt::Key_Codeinput: key = UKey_Codeinput; break;
            case Qt::Key_SingleCandidate: key = UKey_SingleCandidate; break;
            case Qt::Key_MultipleCandidate: key = UKey_MultipleCandidate; break;
            case Qt::Key_PreviousCandidate: key = UKey_PreviousCandidate; break;
            case Qt::Key_Shift: key = UKey_Shift_key; break;
            case Qt::Key_Control: key = UKey_Control_key; break;
            case Qt::Key_Alt: key = UKey_Alt_key; break;
            case Qt::Key_Meta: key = UKey_Meta_key; break;
            case Qt::Key_CapsLock: key = UKey_Caps_Lock; break;
            case Qt::Key_NumLock: key = UKey_Num_Lock; break;
            case Qt::Key_ScrollLock: key = UKey_Scroll_Lock; break;
            default: key = UKey_Other;
            }
        }
    }

    int notFiltered;
    if ( type == QEvent::KeyPress )
    {
        notFiltered = uim_press_key( m_uc, key, modifier );
#ifdef Q_WS_X11
        if ( notFiltered )
            return mCompose->handle_qkey( keyevent );
#else
        if ( notFiltered )
            return FALSE;
#endif
    }
    else if ( type == QEvent::KeyRelease )
    {
        notFiltered = uim_release_key( m_uc, key, modifier );
#ifdef Q_WS_X11
        if ( notFiltered )
            return mCompose->handle_qkey( keyevent );
#else
        if ( notFiltered )
            return FALSE;
#endif
    }

    return TRUE;
}