⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i18nx.c

📁 手写识别Chinput3.0.2源代码,可以在linux下开发手写板程序
💻 C
📖 第 1 页 / 共 2 页
字号:
static char *MakeNewAtom (CARD16 connect_id, char *atomName){    static int sequence = 0;        sprintf (atomName,             "_server%d_%d",             connect_id,             ((sequence > 20)  ?  (sequence = 0)  :  sequence++));    return atomName;}static Bool Xi18nXSend (XIMS ims,                        CARD16 connect_id,                        unsigned char *reply,                        long length){    Xi18n i18n_core = ims->protocol;    Xi18nClient *client = _Xi18nFindClient (i18n_core, connect_id);    XSpecRec *spec = (XSpecRec *) i18n_core->address.connect_addr;    XClient *x_client = (XClient *) client->trans_rec;    XEvent event;    event.type = ClientMessage;    event.xclient.window = x_client->client_win;    event.xclient.message_type = spec->xim_request;    if (length > XCM_DATA_LIMIT)    {        Atom atom;        char atomName[16];        Atom actual_type_ret;        int actual_format_ret;        int return_code;        unsigned long nitems_ret;        unsigned long bytes_after_ret;        unsigned char *win_data;        event.xclient.format = 32;        atom = XInternAtom (i18n_core->address.dpy,                            MakeNewAtom (connect_id, atomName),                            False);        return_code = XGetWindowProperty (i18n_core->address.dpy,                                          x_client->client_win,                                          atom,                                          0L,                                          10000L,                                          False,                                          XA_STRING,                                          &actual_type_ret,                                          &actual_format_ret,                                          &nitems_ret,                                          &bytes_after_ret,                                          &win_data);        if (return_code != Success)            return False;        /*endif*/        if (win_data)            XFree ((char *) win_data);        /*endif*/        XChangeProperty (i18n_core->address.dpy,                         x_client->client_win,                         atom,                         XA_STRING,                         8,                         PropModeAppend,                         (unsigned char *) reply,                         length);        event.xclient.data.l[0] = length;        event.xclient.data.l[1] = atom;    }    else    {        unsigned char buffer[XCM_DATA_LIMIT];        int i;        event.xclient.format = 8;        /* Clear unused field with NULL */        memmove(buffer, reply, length);        for (i = length; i < XCM_DATA_LIMIT; i++)            buffer[i] = (char) 0;        /*endfor*/        length = XCM_DATA_LIMIT;        memmove (event.xclient.data.b, buffer, length);    }    XSendEvent (i18n_core->address.dpy,                x_client->client_win,                False,                NoEventMask,                &event);    XFlush (i18n_core->address.dpy);    return True;}static Bool CheckCMEvent (Display *display, XEvent *event, XPointer xi18n_core){    Xi18n i18n_core = (Xi18n) ((void *) xi18n_core);    XSpecRec *spec = (XSpecRec *) i18n_core->address.connect_addr;    if ((event->type == ClientMessage)        &&        (event->xclient.message_type == spec->xim_request))    {        return  True;    }    /*endif*/    return  False;}static Bool Xi18nXWait (XIMS ims,                        CARD16 connect_id,                        CARD8 major_opcode,                        CARD8 minor_opcode){    Xi18n i18n_core = ims->protocol;    XEvent event;    Xi18nClient *client = _Xi18nFindClient (i18n_core, connect_id);    XClient *x_client = (XClient *) client->trans_rec;    for (;;)    {        unsigned char *packet;        XimProtoHdr *hdr;        int connect_id_ret;        XIfEvent (i18n_core->address.dpy,                  &event,                  CheckCMEvent,                  (XPointer) i18n_core);        if (event.xclient.window == x_client->accept_win)        {            if ((packet = ReadXIMMessage (ims,                                          (XClientMessageEvent *) & event,                                          &connect_id_ret))                == (unsigned char*) NULL)            {                return False;            }            /*endif*/            hdr = (XimProtoHdr *)packet;            if ((hdr->major_opcode == major_opcode)                &&                (hdr->minor_opcode == minor_opcode))            {                return True;            }            else if (hdr->major_opcode == XIM_ERROR)            {                return False;            }            /*endif*/        }        /*endif*/    }    /*endfor*/}static Bool Xi18nXDisconnect (XIMS ims, CARD16 connect_id){    Xi18n i18n_core = ims->protocol;    Display *dpy = i18n_core->address.dpy;    Xi18nClient *client = _Xi18nFindClient (i18n_core, connect_id);    XClient *x_client = (XClient *) client->trans_rec;    XDestroyWindow (dpy, x_client->accept_win);    _XUnregisterFilter (dpy,		        x_client->accept_win,                        WaitXIMProtocol,		        ims);    XFree (x_client);    _Xi18nDeleteClient (i18n_core, connect_id);    return True;}Bool _Xi18nCheckXAddress (Xi18n i18n_core,                          TransportSW *transSW,                          char *address){    XSpecRec *spec;    if (!(spec = (XSpecRec *) malloc (sizeof (XSpecRec))))        return False;    /*endif*/        i18n_core->address.connect_addr = (XSpecRec *) spec;    i18n_core->methods.begin = Xi18nXBegin;    i18n_core->methods.end = Xi18nXEnd;    i18n_core->methods.send = Xi18nXSend;    i18n_core->methods.wait = Xi18nXWait;    i18n_core->methods.disconnect = Xi18nXDisconnect;    return True;}static Bool WaitXConnectMessage (Display *dpy,                                 Window win,                                 XEvent *ev,                                 XPointer client_data){    XIMS ims = (XIMS)client_data;    Xi18n i18n_core = ims->protocol;    XSpecRec *spec = (XSpecRec *) i18n_core->address.connect_addr;    if (((XClientMessageEvent *) ev)->message_type        == spec->connect_request)    {        ReadXConnectMessage (ims, (XClientMessageEvent *) ev);        return True;    }    /*endif*/    return False;}static Bool WaitXIMProtocol (Display *dpy,                             Window win,                             XEvent *ev,                             XPointer client_data){    extern void _Xi18nMessageHandler (XIMS, CARD16, unsigned char *, Bool *);    XIMS ims = (XIMS) client_data;    Xi18n i18n_core = ims->protocol;    XSpecRec *spec = (XSpecRec *) i18n_core->address.connect_addr;    Bool delete = True;    unsigned char *packet;    int connect_id;    if (((XClientMessageEvent *) ev)->message_type        == spec->xim_request)    {        if ((packet = ReadXIMMessage (ims,                                      (XClientMessageEvent *) ev,                                      &connect_id))            == (unsigned char *)  NULL)        {            return False;        }        /*endif*/        _Xi18nMessageHandler (ims, connect_id, packet, &delete);        if (delete == True)            XFree (packet);        /*endif*/        return True;    }    /*endif*/    return False;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -