Beispiel #1
0
static Status xi18n_commit (XIMS ims, XPointer xp)
{
    Xi18n i18n_core = ims->protocol;
    IMCommitStruct *call_data = (IMCommitStruct *)xp;
    FrameMgr fm;
    extern XimFrameRec commit_chars_fr[];
    extern XimFrameRec commit_both_fr[];
    register int total_size;
    unsigned char *reply = NULL;
    CARD16 str_length;

    call_data->flag |= XimSYNCHRONUS;  /* always sync */

    if (!(call_data->flag & XimLookupKeySym)
        &&
        (call_data->flag & XimLookupChars))
    {
        fm = FrameMgrInit (commit_chars_fr,
                           NULL,
                           _Xi18nNeedSwap (i18n_core, call_data->connect_id));

        /* set length of STRING8 */
        str_length = strlen (call_data->commit_string);
        FrameMgrSetSize (fm, str_length);
        total_size = FrameMgrGetTotalSize (fm);
        reply = (unsigned char *) malloc (total_size);
        if (!reply)
        {
            _Xi18nSendMessage (ims,
                               call_data->connect_id,
                               XIM_ERROR,
                               0,
                               0,
                               0);
            return False;
        }
        /*endif*/
        memset (reply, 0, total_size);
        FrameMgrSetBuffer (fm, reply);

        str_length = FrameMgrGetSize (fm);
        FrameMgrPutToken (fm, call_data->connect_id);
        FrameMgrPutToken (fm, call_data->icid);
        FrameMgrPutToken (fm, call_data->flag);
        FrameMgrPutToken (fm, str_length);
        FrameMgrPutToken (fm, call_data->commit_string);
    }
    else
    {
        fm = FrameMgrInit (commit_both_fr,
                           NULL,
                           _Xi18nNeedSwap (i18n_core, call_data->connect_id));
        /* set length of STRING8 */
        str_length = strlen (call_data->commit_string);
        if (str_length > 0)
            FrameMgrSetSize (fm, str_length);
        /*endif*/
        total_size = FrameMgrGetTotalSize (fm);
        reply = (unsigned char *) malloc (total_size);
        if (!reply)
        {
            _Xi18nSendMessage (ims,
                               call_data->connect_id,
                               XIM_ERROR,
                               0,
                               0,
                               0);
            return False;
        }
        /*endif*/
        FrameMgrSetBuffer (fm, reply);
        FrameMgrPutToken (fm, call_data->connect_id);
        FrameMgrPutToken (fm, call_data->icid);
        FrameMgrPutToken (fm, call_data->flag);
        FrameMgrPutToken (fm, call_data->keysym);
        if (str_length > 0)
        {
            str_length = FrameMgrGetSize (fm);
            FrameMgrPutToken (fm, str_length);
            FrameMgrPutToken (fm, call_data->commit_string);
        }
        /*endif*/
    }
    /*endif*/
    _Xi18nSendMessage (ims,
                       call_data->connect_id,
                       XIM_COMMIT,
                       0,
                       reply,
                       total_size);
    FrameMgrFree (fm);
    XFree (reply);
    
    return True;
}
Beispiel #2
0
void _Xi18nSendTriggerKey(XIMS ims, CARD16 connect_id)
{
    Xi18n i18n_core = ims->protocol;
    FrameMgr fm;
    extern XimFrameRec register_triggerkeys_fr[];
    XIMTriggerKey *on_keys = i18n_core->address.on_keys.keylist;
    XIMTriggerKey *off_keys = i18n_core->address.off_keys.keylist;
    int on_key_num = i18n_core->address.on_keys.count_keys;
    int off_key_num = i18n_core->address.off_keys.count_keys;
    unsigned char *reply = NULL;
    register int i, total_size;
    CARD16 im_id;

    if (on_key_num == 0  &&  off_key_num == 0)
        return;
    /*endif*/

    fm = FrameMgrInit(register_triggerkeys_fr,
                      NULL,
                      _Xi18nNeedSwap(i18n_core, connect_id));

    /* set iteration count for on-keys list */
    FrameMgrSetIterCount(fm, on_key_num);
    /* set iteration count for off-keys list */
    FrameMgrSetIterCount(fm, off_key_num);

    /* get total_size */
    total_size = FrameMgrGetTotalSize(fm);

    reply = (unsigned char *) malloc(total_size);
    if (!reply)
        return;
    /*endif*/
    memset(reply, 0, total_size);
    FrameMgrSetBuffer(fm, reply);

    /* Right now XIM_OPEN_REPLY hasn't been sent to this new client, so
       the input-method-id is still invalid, and should be set to zero...
       Reter to $(XC)/lib/X11/imDefLkup.c:_XimRegisterTriggerKeysCallback
     */
    im_id = 0;
    FrameMgrPutToken(fm, im_id);   /* input-method-id */
    for (i = 0;  i < on_key_num;  i++) {
        FrameMgrPutToken(fm, on_keys[i].keysym);
        FrameMgrPutToken(fm, on_keys[i].modifier);
        FrameMgrPutToken(fm, on_keys[i].modifier_mask);
    }
    /*endfor*/
    for (i = 0;  i < off_key_num;  i++) {
        FrameMgrPutToken(fm, off_keys[i].keysym);
        FrameMgrPutToken(fm, off_keys[i].modifier);
        FrameMgrPutToken(fm, off_keys[i].modifier_mask);
    }
    /*endfor*/
    _Xi18nSendMessage(ims,
                      connect_id,
                      XIM_REGISTER_TRIGGERKEYS,
                      0,
                      reply,
                      total_size);
    FrameMgrFree(fm);
    XFree(reply);
}
Beispiel #3
0
static Status xi18n_forwardEvent (XIMS ims, XPointer xp)
{
    Xi18n i18n_core = ims->protocol;
    IMForwardEventStruct *call_data = (IMForwardEventStruct *)xp;
    FrameMgr fm;
    extern XimFrameRec forward_event_fr[];
    register int total_size;
    unsigned char *reply = NULL;
    unsigned char *replyp;
    CARD16 serial;
    int event_size;
    Xi18nClient *client;

    client = (Xi18nClient *) _Xi18nFindClient (i18n_core, call_data->connect_id);

    /* create FrameMgr */
    fm = FrameMgrInit (forward_event_fr,
                       NULL,
                       _Xi18nNeedSwap (i18n_core, call_data->connect_id));

    total_size = FrameMgrGetTotalSize (fm);
    event_size = sizeof (xEvent);
    reply = (unsigned char *) malloc (total_size + event_size);
    if (!reply)
    {
        _Xi18nSendMessage (ims,
                           call_data->connect_id,
                           XIM_ERROR,
                           0,
                           0,
                           0);
        return False;
    }
    /*endif*/
    memset (reply, 0, total_size + event_size);
    FrameMgrSetBuffer (fm, reply);
    replyp = reply;

    call_data->sync_bit = 1; 	/* always sync */
    client->sync = True;

    FrameMgrPutToken (fm, call_data->connect_id);
    FrameMgrPutToken (fm, call_data->icid);
    FrameMgrPutToken (fm, call_data->sync_bit);

    replyp += total_size;
    EventToWireEvent (&(call_data->event),
                      (xEvent *) replyp,
                      &serial,
                      _Xi18nNeedSwap (i18n_core, call_data->connect_id));

    FrameMgrPutToken (fm, serial);

    _Xi18nSendMessage (ims,
                       call_data->connect_id,
                       XIM_FORWARD_EVENT,
                       0,
                       reply,
                       total_size + event_size);

    XFree (reply);
    FrameMgrFree (fm);

    return True;
}