home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 August - Disc 2 / chip_20018102_hu.iso / linux / X-4.1.0 / doc / xim.txt < prev    next >
Text File  |  2001-06-27  |  92KB  |  4,093 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.          The Input Method Protocol
  20.  
  21.             Version 1.0
  22.  
  23.            X Consortium Standard
  24.  
  25.          X Version 11, Release 6.4
  26.  
  27.  
  28.  
  29.  
  30.               Masahiko Narita
  31.               FUJITSU Limited.
  32.  
  33.             Hideki Hiura
  34.                SunSoft, Inc.
  35.  
  36.  
  37.  
  38.  
  39.  
  40.               ABSTRACT
  41.  
  42.  
  43.  
  44.      This specifies a protocol between IM library and
  45.      IM (Input Method) Server for internationalized
  46.      text input, which is independent from any specific
  47.      language, any specific input method and the trans-
  48.      port layer used in communication between the IM
  49.      library and the IM Server, and uses a client-
  50.      server model.  This protocol allows user to use
  51.      his/her favorite input method for all applications
  52.      within the stand-alone distributed environment.
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.     X Window System is a trademark of X Consortium, Inc.
  85.  
  86.        Copyright (C) 1993, 1994 by X Consortium, Inc.
  87.  
  88.  
  89.  
  90.  
  91. Permission is hereby granted, free of charge, to any person
  92. obtaining a copy of this software and associated documenta-
  93. tion files (the "Software"), to deal in the Software without
  94. restriction, including without limitation the rights to use,
  95. copy, modify, merge, publish, distribute, sublicense, and/or
  96. sell copies of the Software, and to permit persons to whom
  97. the Software is furnished to do so, subject to the following
  98. conditions:
  99.  
  100. The above copyright notice and this permission notice shall
  101. be included in all copies or substantial portions of the
  102. Software.
  103.  
  104. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  105. KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  106. WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PUR-
  107. POSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE X CONSOR-
  108. TIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  109. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  110. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  111. OR OTHER DEALINGS IN THE SOFTWARE.
  112.  
  113. Except as contained in this notice, the name of the X Con-
  114. sortium shall not be used in advertising or otherwise to
  115. promote the sale, use or other dealings in this Software
  116. without prior written authorization from the X Consortium.
  117.  
  118.  
  119.  
  120.  
  121.     Copyright (C) 1993, 1994 by FUJITSU LIMITED
  122.  
  123.      Copyright (C) 1993, 1994 by Sun Microsystems, Inc.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. Permission to use, copy, modify, and distribute this docu-
  140. mentation for any purpose and without fee is hereby granted,
  141. provided that the above copyright notice and this permission
  142. notice appear in all copies.  Fujitsu and Sun Microsystems
  143. make no representations about the suitability for any pur-
  144. pose of the information in this document.  This documenta-
  145. tion is provided as is without express or implied warranty.
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. 1.  Introduction
  206.  
  207. 1.1.  Scope
  208.  
  209. The internationalization in the X Window System Version 11,
  210. Release 5 (X11R5) provides a common API which application
  211. developers can use to create portable internationalized pro-
  212. grams and to adapt them to the requirements of different
  213. native languages, local customs, and character string encod-
  214. ings (this is called ``localization'').  As one of its
  215. internationalization mechanisms X11R5 has defined a func-
  216. tional interface for internationalized text input, called
  217. XIM (X Input Method).
  218.  
  219. When a client-server model is used with an IM (Input Method)
  220. implementation, a protocol must be established between the
  221. client and the server.    However, the protocol used to inter-
  222. face Input Method Servers (IM Servers) with the Input Method
  223. libraries (IM libraries) to which applications are linked
  224. was not addressed in X11R5.  This led application developers
  225. to depend on vendor-specific input methods, decreased the
  226. user's choice of available input methods, and made it more
  227. difficult for developers to create portable applications.
  228. This paper describes the Input Method Protocol developed for
  229. X11R6 to resolve the above problems and to address the
  230. requirements of existing and future input methods.
  231.  
  232. The Input Method Protocol is independent from the transport
  233. layer used in communication between the IM library and the
  234. IM Server.  Thus, the input method protocol can be built on
  235. any inter-process communication mechanism, such as TCP/IP or
  236. the X protocol.
  237.  
  238. In addition, the protocol provides for future extensions
  239. such as differing input model types.
  240.  
  241.  
  242. 1.2.  Background
  243.  
  244. Text input is much more simple for some languages than oth-
  245. ers.  English, for instance, uses an alphabet of a manage-
  246. able size, and input consists of pressing the corresponding
  247. key on a keyboard, perhaps in combination with a shift key
  248. for capital letters or special characters.
  249.  
  250. Some languages have larger alphabets, or modifiers such as
  251. accents, which require the addition of special key combina-
  252. tions in order to enter text.  These input methods may
  253. require ``dead-keys'' or ``compose-keys'' which, when fol-
  254. lowed by different combinations of key strokes, generate
  255. different characters.
  256.  
  257. Text input for ideographic languages is much less simple.
  258. In these languages, characters represent actual objects
  259.  
  260.  
  261.  
  262.                   1
  263.  
  264.  
  265.  
  266.  
  267.  
  268. X Input Method Protocol             X11, Release 6.1
  269.  
  270.  
  271. rather than phonetic sounds used in pronouncing a word, and
  272. the number of characters in these languages may continue to
  273. grow.  In Japanese, for instance, most text input methods
  274. involve entering characters in a phonetic alphabet, after
  275. which the input method searches a dictionary for possible
  276. ideographic equivalents (of which there may be many).  The
  277. input method then presents the candidate characters for the
  278. user to choose from.
  279.  
  280. In Japanese, either Kana (phonetic symbols) or Roman letters
  281. are typed and then a region is selected for conversion to
  282. Kanji. Several Kanji characters may have the same phonetic
  283. representation. If that is the case with the string entered,
  284. a menu of characters is presented and the user must choose
  285. the appropriate one. If no choice is necessary or a prefer-
  286. ence has been established, the input method does the substi-
  287. tution directly.
  288.  
  289. These complicated input methods must present state informa-
  290. tion (Status Area), text entry and edit space (Preedit
  291. Area), and menu/choice presentations (Auxiliary Area).    Much
  292. of the protocol between the IM library and the IM Server
  293. involves managing these IM areas.  Because of the size and
  294. complexity of these input methods, and because of how widely
  295. they vary from one language or locale to another, they are
  296. usually implemented as separate processes which can serve
  297. many client processes on the same computer or network.
  298.  
  299.  
  300. 1.3.  Input Method Styles
  301.  
  302. X11 internationalization support includes the following four
  303. types of input method:
  304.  
  305.      - on-the-spot:     The client application is directed
  306.              by the IM Server to display all
  307.              pre-edit data at the site of text
  308.              insertion.  The client registers
  309.              callbacks invoked by the input
  310.              method during pre-editing.
  311.  
  312.      - off-the-spot:     The client application provides
  313.              display windows for the pre-edit
  314.              data to the input method which dis-
  315.              plays into them directly.
  316.  
  317.      - over-the-spot:     The input method displays pre-edit
  318.              data in a window which it brings up
  319.              directly over the text insertion
  320.              position.
  321.  
  322.      - root-window:     The input method displays all pre-
  323.              edit data in a separate area of the
  324.              screen in a window specific to the
  325.  
  326.  
  327.  
  328.                   2
  329.  
  330.  
  331.  
  332.  
  333.  
  334. X Input Method Protocol             X11, Release 6.1
  335.  
  336.  
  337.              input method.
  338.  
  339. Client applications must choose from the available input
  340. methods supported by the IM Server and provide the display
  341. areas and callbacks required by the input method.
  342.  
  343.  
  344. 2.  Architecture
  345.  
  346. 2.1.  Implementation Model
  347.  
  348. Within the X Window System environment, the following two
  349. typical architectural models can be used as an input
  350. method's implementation model.
  351.  
  352.      - Client/Server model:
  353.              A separate process, the IM Server,
  354.              processes input and handles preed-
  355.              iting, converting, and committing.
  356.              The IM library within the applica-
  357.              tion, acting as client to the IM
  358.              Server, simply receives the commit-
  359.              ted string from the IM Server.
  360.  
  361.      - Library model:     All input is handled by the IM
  362.              library within the application.
  363.              The event process is closed within
  364.              the IM library and a separate IM
  365.              Server process may not be required.
  366.  
  367. Most languages which need complex preediting, such as Asian
  368. languages, are implemented using the Client/Server IM model.
  369. Other languages which need only dead key or compose key pro-
  370. cessing, such as European languages, are implemented using
  371. the Library model.
  372.  
  373. In this paper, we discuss mainly the Client/Server IM model
  374. and the protocol used in communication between the IM
  375. library (client) and the IM Server.
  376.  
  377.  
  378. 2.2.  Structure of IM
  379.  
  380. When the client connects or disconnects to the IM Server, an
  381. open or close operation occurs between the client and the IM
  382. Server.
  383.  
  384. The IM can be specified at the time of XOpenIM() by setting
  385. the locale of the client and a locale modifier. Since the IM
  386. remembers the locale at the time of creation XOpenIM() can
  387. be called multiple times (with the setting for the locale
  388. and the locale modifier changed) to support multiple lan-
  389. guages.
  390.  
  391.  
  392.  
  393.  
  394.                   3
  395.  
  396.  
  397.  
  398.  
  399.  
  400. X Input Method Protocol             X11, Release 6.1
  401.  
  402.  
  403. In addition, the supported IM type can be obtained using
  404. XGetIMValues().
  405.  
  406. The client usually holds multiple input (text) fields. Xlib
  407. provides a value type called the ``Input Context'' (IC) to
  408. manage each individual input field.  An IC can be created by
  409. specifying XIM using XCreateIC(), and it can be destroyed
  410. using XDestroyIC().
  411.  
  412. The IC can specify the type of IM which is supported by XIM
  413. for each input field, so each input field can handle a dif-
  414. ferent type of IM.
  415.  
  416. Most importantly information such as the committed string
  417. sent from the IM Server to the client, is exchanged based on
  418. each IC.
  419.  
  420. Since each IC corresponds to an input field, the focused
  421. input field should be announced to the IM Server using XSet-
  422. ICFocus(). (XUnsetICFocus() can also be used to change the
  423. focus.)
  424.  
  425.  
  426. 2.3.  Event Handling Model
  427.  
  428. Existing input methods support either the FrontEnd method,
  429. the BackEnd method, or both.  This protocol specifically
  430. supports the BackEnd method as the default method, but also
  431. supports the FrontEnd method as an optional IM Server exten-
  432. sion.
  433.  
  434. The difference between the FrontEnd and BackEnd methods is
  435. in how events are delivered to the IM Server.  (Fig. 1)
  436.  
  437.  
  438. 2.3.1.    BackEnd Method
  439.  
  440. In the BackEnd method, client window input events are always
  441. delivered to the IM library, which then passes them to the
  442. IM Server.  Events are handled serially in the order deliv-
  443. ered, and therefore there is no synchronization problem
  444. between the IM library and the IM Server.
  445.  
  446. Using this method, the IM library forwards all KeyPress and
  447. KeyRelease events to the IM Server (as required by the Event
  448. Flow Control model described in section 2.4. ``Event Flow
  449. Control''), and synchronizes with the IM Server (as
  450. described in section 4.16.  ``Filtering Events'').
  451.  
  452.  
  453. 2.3.2.    FrontEnd Method
  454.  
  455. In the FrontEnd method, client window input events are
  456. delivered by the X server directly to both the IM Server and
  457.  
  458.  
  459.  
  460.                   4
  461.  
  462.  
  463.  
  464.  
  465.  
  466. X Input Method Protocol             X11, Release 6.1
  467.  
  468.  
  469. the IM library.  Therefore this method provides much better
  470. interactive performance while preediting (particularly in
  471. cases such as when the IM Server is running locally on the
  472. user's workstation and the client application is running on
  473. another workstation over a relatively slow network).
  474.  
  475. However, the FrontEnd model may have synchronization prob-
  476. lems between the key events handled in the IM Server and
  477. other events handled in the client, and these problems could
  478. possibly cause the loss or duplication of key events.  For
  479. this reason, the BackEnd method is the core method sup-
  480. ported, and the FrontEnd method is made available as an
  481. extension for performance purposes. (Refer to Appendix A for
  482. more information.)
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.                   5
  527.  
  528.  
  529.  
  530.  
  531.  
  532. X Input Method Protocol             X11, Release 6.1
  533.  
  534.  
  535. ... 0.05 6.513 4.737 10.45 ... 0.000i 3.937i 4.687i 0.000i
  536.  
  537.        +
  538.  
  539.  
  540.               ____________________
  541.               |              |
  542.               |  Application      |
  543.               |              |
  544.               |  _______          |
  545.               |        |          |
  546.               |  |     |____________|
  547.               |  |     |  | Library |
  548.               |  |     |____________|
  549.               |___________________|
  550.                  |        |
  551.                  |        |
  552.                  |     _____________________
  553.                  |     |              |
  554.                  |     |    IM Server       |
  555.                  |     |____________________|
  556.            BackEnd Method|(Core)        |FrontEnd Method (Extension)
  557.                  |            |
  558.               ____________________
  559.               |              |
  560.               |     X Server     |
  561.               |___________________|
  562.  
  563.  
  564.           Fig.1 The Flow of Events
  565.  
  566.  
  567. 2.4.  Event Flow Control
  568.  
  569. This protocol supports two event flow models for communica-
  570. tion between the IM library and the IM Server (Static and
  571. Dynamic).
  572.  
  573. Static Event Flow requires that input events always be sent
  574. to the IM Server from the client.
  575.  
  576. Dynamic Event Flow, however, requires only that those input
  577. events which need to be processed (converted) be sent to the
  578. IM Server from the client.
  579.  
  580. For instance, in the case of inputing a combination of ASCII
  581. characters and Chinese characters, ASCII characters do not
  582. need to be processed in the IM Server, so their key events
  583. do not have to be sent to the IM Server.  On the other hand,
  584. key events necessary for composing Chinese characters must
  585. be sent to the IM Server.
  586.  
  587. Thus, by adopting the Dynamic Event Flow, the number of
  588. requests among the X Server, the client, and the IM Server
  589.  
  590.  
  591.  
  592.                   6
  593.  
  594.  
  595.  
  596.  
  597.  
  598. X Input Method Protocol             X11, Release 6.1
  599.  
  600.  
  601. is significantly reduced, and the number of context switches
  602. is also reduced, resulting in improved performance.  The IM
  603. Server can send XIM_REGISTER_TRIGGERKEYS message in order to
  604. switch the event flow in the Dynamic Event Flow.
  605.  
  606. The protocol for this process is described in section 4.5.
  607. ``Event Flow Control''.
  608.  
  609.  
  610. 3.  Default Preconnection Convention
  611.  
  612. IM Servers are strongly encouraged to register their sym-
  613. bolic names as the ATOM names into the IM Server directory
  614. property, XIM_SERVERS, on the root window of the screen_num-
  615. ber 0.    This property can contain a list of ATOMs, and the
  616. each ATOM represents each possible IM Server.  IM Server
  617. names are restricted to POSIX Portable Filename Character
  618. Set.  To discover if the IM Server is active, see if there
  619. is an owner for the selection with that atom name.  To learn
  620. the address of that IM Server, convert the selection target
  621. TRANSPORT, which will return a string form of the transport
  622. address(es).  To learn the supported locales of that IM
  623. Server, convert the selection target LOCALES, which will
  624. return a set of names of the supported locales in the syntax
  625. X/Open defines.
  626.  
  627. The basic semantics to determine the IM Server if there are
  628. multiple ATOMs are found in XIM_SERVERS property, is first
  629. fit if the IM Server name is not given as a X modifier's
  630. category im.
  631.  
  632. The address information retrievable from the TRANSPORT tar-
  633. get is a transport-specific name.  The preregistered formats
  634. for transport-specific names are listed in Appendix B.
  635. Additional transport-specific names may be registered with X
  636. Consortium.
  637.  
  638. For environments that lack X connections, or for IM Servers
  639. which do not use the X Window System, the preconnection con-
  640. vention with IM Server may be given outside the X Window
  641. system (e.g. using a Name Service).
  642.  
  643.  
  644. 4.  Protocol
  645.  
  646. The protocol described below uses the bi-directional syn-
  647. chronous/asynchronous request/reply/error model and is spec-
  648. ified using the same conventions outlined in Section 2 of
  649. the core X Window System protocol [1]:
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.                   7
  659.  
  660.  
  661.  
  662.  
  663.  
  664. X Input Method Protocol             X11, Release 6.1
  665.  
  666.  
  667. 4.1.  Basic Requests Packet Format
  668.  
  669. This section describes the requests that may be exchanged
  670. between the client and the IM Server.
  671.  
  672. The basic request packet header format is as follows.
  673.  
  674.            major-opcode:        CARD8
  675.            minor-opcode:        CARD8
  676.            length:            CARD16
  677.  
  678. The MAJOR-OPCODE specifies which core request or extension
  679. package this packet represents.  If the MAJOR-OPCODE corre-
  680. sponds to a core request, the MINOR-OPCODE contains 8 bits
  681. of request-specific data.  (If the MINOR-OPCODE is not used,
  682. it is 0.)  Otherwise, the MAJOR-OPCODE and the MINOR-OPCODE
  683. are specified by XIM_QUERY_EXTENSION message.  (Refer to
  684. 4.7. Query the supported extension protocol list.)  The
  685. LENGTH field specifies the number of 4 bytes elements fol-
  686. lowing the header.  If no additional data is followed by the
  687. header, the LENGTH field will be 0.
  688.  
  689.  
  690. 4.2.  Data Types
  691.  
  692. The following data types are used in the core X IM Server
  693. protocol:
  694.  
  695. BITMASK16
  696.   CARD16
  697.  
  698. BITMASK32
  699.   CARD32
  700.  
  701. PADDING FORMAT
  702.   Where N is some expression, and Pad(N) is the number of bytes needed to round N up to a
  703.   multiple of four.
  704.      Pad(N) = (4 - (N mod 4)) mod 4
  705.  
  706. LPCE
  707.   1            A character from the4 X Portable Character Set in Latin Portable
  708.             Character Encoding
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.                   8
  725.  
  726.  
  727.  
  728.  
  729.  
  730. X Input Method Protocol             X11, Release 6.1
  731.  
  732.  
  733. STRING
  734.   2  n            length of string in bytes
  735.   n  LISTofLPCE     string
  736.   p            unused, p=Pad(2+n)
  737.  
  738. STR
  739.   1  n            length of name in bytes
  740.   n  STRING8        name
  741.  
  742. XIMATTR
  743.   2  CARD16        attribute ID (*1)
  744.   2  CARD16        type of the value (*2)
  745.   2  n            length of im-attribute
  746.   n  STRING8        im-attribute
  747.   p            unused, p = Pad(2+n)
  748.  
  749. The im-attribute argument specifies XIM values such as XNQueryInputStyle.
  750.  
  751. XICATTR
  752.   2  CARD16        attribute ID (*1)
  753.   2  CARD16        type of the value (*2)
  754.   2  n            length of ic-attribute
  755.   n  STRING8        ic-attribute
  756.   p            unused, p = Pad(2+n)
  757.  
  758.  
  759. (*1) XIMATTR and XICATTR are used during the setup stage and
  760.      XIMATTRIBUTE and XICATTRIBUTE are used after each
  761.      attribute ID has been recognized by the IM Server and
  762.      the IM library.
  763.  
  764.  
  765. (*2) The value types are defined as follows:
  766.  
  767.      ------------------------------------------------------------------------------------------
  768.      values   data            format
  769.      ------------------------------------------------------------------------------------------
  770.      #0       Separator of NestedList    ----- (*3)
  771.      #1       byte data         CARD8
  772.      #2       word data         CARD16
  773.      #3       long data         CARD32
  774.      #4       char data         STRING8
  775.      #5       Window            CARD32
  776.      #10      XIMStyles         2         n              number of XIMStyle list
  777.                     2                  unused
  778.                     n         CARD32          XIMStyle list
  779.      #11      XRectangle        2         INT16          X
  780.                     2         INT16          Y
  781.                     2         CARD16          width
  782.                     2         CARD16          height
  783.      #12      XPoint            2         INT16          X
  784.                     2         INT16          Y
  785.      #13      XFontSet            2         n              length of Base font name
  786.  
  787.  
  788.  
  789.  
  790.                   9
  791.  
  792.  
  793.  
  794.  
  795.  
  796. X Input Method Protocol             X11, Release 6.1
  797.  
  798.  
  799.      ------------------------------------------------------------------------------------------
  800.      values   data            format
  801.      ------------------------------------------------------------------------------------------
  802.                     n         STRING8          Base font name list
  803.                     p                  unused, p = Pad(2+n)
  804.      #15      XIMHotKeyTriggers     4         n              number of XIMTRIGGERKEY
  805.                                       list (*4)
  806.                     n         XIMTRIGGERKEY    XIMHotkeyTrigger list
  807.      #16      XIMHotKeyState                 XIMHOTKEYSTATE   HotKey processing state
  808.      #17      XIMStringConversion    XIMSTRCONVTEXT
  809.      #18      XIMPreeditState        XIMPREEDITSTATE
  810.      #19      XIMResetState        XIMRESETSTATE
  811.      #x7fff   NestedList        -----
  812.      ------------------------------------------------------------------------------------------
  813.  
  814.  
  815.  
  816. (*3) The IC value for the separator of NestedList is defined
  817.      as follows,
  818.       #define   XNSeparatorofNestedList   ``separato-
  819.      rofNestedList''
  820.      , which is registered in X Consortium and cannot be
  821.      used for any other purpose.
  822.  
  823.  
  824. (*4) LISTofFOO
  825.       A Type name of the form LISTof FOO means a counted
  826.       list of elements of type FOO.  The size of the
  827.       length field may vary (it is not necessarily the
  828.       same size as a FOO), and in some cases, it may be
  829.       implicit.
  830.  
  831.  
  832. XIMTRIGGERKEY
  833.   4  CARD32        keysym
  834.   4  CARD32        modifier
  835.   4  CARD32        modifier mask
  836.  
  837. ENCODINGINFO
  838.   2  n            length of encoding info
  839.   n  STRING8        encoding info
  840.   p            unused, p=Pad(2+n)
  841.  
  842. EXT
  843.   1  CARD8        extension major-opcode
  844.   1  CARD8        extension minor-opcode
  845.   2  n            length of extension name
  846.   n  STRING8        extension name
  847.   p            unused, p = Pad(n)
  848.  
  849. XIMATTRIBUTE
  850.   2  CARD16        attribute ID
  851.   2  n            value length
  852.   n            value
  853.  
  854.  
  855.  
  856.                  10
  857.  
  858.  
  859.  
  860.  
  861.  
  862. X Input Method Protocol             X11, Release 6.1
  863.  
  864.  
  865.   p            unused, p = Pad(n)
  866.  
  867. XICATTRIBUTE
  868.   2  CARD16        attribute ID
  869.   2  n            value length
  870.   n            value
  871.   p            unused, p = Pad(n)
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.                  11
  923.  
  924.  
  925.  
  926.  
  927.  
  928. X Input Method Protocol             X11, Release 6.1
  929.  
  930.  
  931. XIMSTRCONVTEXT
  932.   2  CARD16              XIMStringConversionFeedback
  933.      #x0000001              XIMStringConversionLeftEdge
  934.      #x0000002              XIMStringConversionRightEdge
  935.      #x0000004              XIMStringConversionTopEdge
  936.      #x0000008              XIMStringConversionBottomEdge
  937.      #x0000010              XIMStringConversionConvealed
  938.      #x0000020              XIMStringConversionWrapped
  939.   2  n                  byte length of the retrieved string
  940.   n  STRING8              retrieved string
  941.   p                  unused, p = Pad(n)
  942.   2  m                  byte length of feedback array
  943.   2                  unused
  944.   m  LISTofXIMSTRCONVFEEDBACK feedback array(*1)
  945.  
  946. (*1) This field is reserved for future use.
  947.  
  948.  
  949. XIMFEEDBACK
  950.   4  CARD32        XIMFeedback
  951.      #x000001        XIMReverse
  952.      #x000002        XIMUnderline
  953.      #x000004        XIMHighlight
  954.      #x000008        XIMPrimary
  955.      #x000010        XIMSecondary
  956.      #x000020        XIMTertiary
  957.      #x000040        XIMVisibleToForward
  958.      #x000080        XIMVisibleToBackward
  959.      #x000100        XIMVisibleCenter
  960.  
  961. XIMHOTKEYSTATE
  962.   4  CARD32        XIMHotKeyState
  963.      #x0000001        XIMHotKeyStateON
  964.      #x0000002        XIMHotKeyStateOFF
  965.  
  966. XIMPREEDITSTATE
  967.   4  CARD32        XIMPreeditState
  968.      #x0000001        XIMPreeditEnable
  969.      #x0000002        XIMPreeditDisable
  970.  
  971. XIMRESETSTATE
  972.   4  CARD32        XIMResetState
  973.      #x0000001        XIMInitialState
  974.      #x0000002        XIMPreserveState
  975.  
  976.  
  977. 4.3.  Error Notification
  978.  
  979. Both the IM Server and the IM library return XIM_ERROR mes-
  980. sages instead of the corresponding reply messages if any
  981. errors occur during data processing.
  982.  
  983. At most one error is generated per request. If more than one
  984. error condition is encountered in processing a request, the
  985.  
  986.  
  987.  
  988.                  12
  989.  
  990.  
  991.  
  992.  
  993.  
  994. X Input Method Protocol             X11, Release 6.1
  995.  
  996.  
  997. choice of which error is returned is implementation-depen-
  998. dent.
  999.  
  1000.  
  1001.      XIM_ERROR (IM Server <--> IM library)
  1002.       2    CARD16            input-method-ID
  1003.       2    CARD16            input-context-ID
  1004.       2    BITMASK16        flag (*1)
  1005.         #0000            Both Input-Method-ID and Input-Context-ID are invalid
  1006.         #0001            Input-Method-ID is valid
  1007.         #0002            Input-Context-ID is valid
  1008.       2    CARD16            Error Code
  1009.         #1            BadAlloc
  1010.         #2            BadStyle
  1011.         #3            BadClientWindow
  1012.         #4            BadFocusWindow
  1013.         #5            BadArea
  1014.         #6            BadSpotLocation
  1015.         #7            BadColormap
  1016.         #8            BadAtom
  1017.         #9            BadPixel
  1018.         #10            BadPixmap
  1019.         #11            BadName
  1020.         #12            BadCursor
  1021.         #13            BadProtocol
  1022.         #14            BadForeground
  1023.         #15            BadBackground
  1024.         #16            LocaleNotSupported
  1025.         #999            BadSomething (*2)
  1026.       2    n            byte length of error detail.
  1027.       2    CARD16            type of error detail (*3)
  1028.       n    STRING8         error detail (*4)
  1029.       p                unused, p = Pad(n)
  1030.  
  1031.  
  1032.  
  1033.      (*1) Before an IM is created, both Input-Method-ID and
  1034.       Input-Context-ID are invalid.  Before an IC is
  1035.       created, only Input-Method-ID is valid.  After
  1036.       that, both of Input-Method-ID and Input-Context-ID
  1037.       are valid.
  1038.  
  1039.      (*2) Unspecific error, for example ``language engine
  1040.       died''
  1041.  
  1042.      (*3) This field is reserved for future use.
  1043.  
  1044.      (*4) Vendor defined detail error message
  1045.  
  1046.  
  1047. 4.4.  Connection Establishment
  1048.  
  1049. XIM_CONNECT message requests to establish a connection over
  1050. a mutually-understood virtual stream.
  1051.  
  1052.  
  1053.  
  1054.                  13
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. X Input Method Protocol             X11, Release 6.1
  1061.  
  1062.  
  1063.      XIM_CONNECT (IM library -> IM Server)
  1064.       1                byte order
  1065.         #x42 MSB first
  1066.         #x6c LSB first
  1067.       1                unused
  1068.       2    CARD16            client-major-protocol-version (*1)
  1069.       2    CARD16            client-minor-protocol-version (*1)
  1070.       2    CARD16            number of client-auth-protocol-names
  1071.       n    LISTofSTRING        client-auth-protocol-names
  1072.  
  1073.  
  1074.  
  1075.      (*1) Specify the version of IM Protocol that the client
  1076.       supports.
  1077.  
  1078.  
  1079. A client must send XIM_CONNECT message as the first message
  1080. on the connection.  The list specifies the names of authen-
  1081. tication protocols the sending IM Server is willing to per-
  1082. form.  (If the client need not authenticate, the list may be
  1083. omited.)
  1084.  
  1085. XIM_AUTH_REQUIRED message is used to send the authentication
  1086. protocol name and protocol-specific data.
  1087.  
  1088.      XIM_AUTH_REQUIRED (IM library <--> IM Server)
  1089.       1    CARD8            auth-protocol-index
  1090.       3                unused
  1091.       2    n            length of authentication data
  1092.       2                unused
  1093.       n    <varies>        data
  1094.       p                unused, p = Pad(n)
  1095.  
  1096.  
  1097. The auth-protocol is specified by an index into the list of
  1098. names given in the XIM_CONNECT or XIM_AUTH_SETUP message.
  1099. Any protocol-specific data that might be required is also
  1100. sent.
  1101.  
  1102. The IM library sends XIM_AUTH_REPLY message as the reply to
  1103. XIM_AUTH_REQUIRED message, if the IM Server is authenti-
  1104. cated.
  1105.  
  1106.      XIM_AUTH_REPLY (IM library -> IM Server)
  1107.       2    n            length of authentication data
  1108.       2                unused
  1109.       2    n            length of authentication data
  1110.       2                unused
  1111.       n    <varies>        data
  1112.       p                unused, p = Pad(n)
  1113.  
  1114.  
  1115. The auth data is specific to the authentication protocol in
  1116. use.
  1117.  
  1118.  
  1119.  
  1120.                  14
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. X Input Method Protocol             X11, Release 6.1
  1127.  
  1128.  
  1129. XIM_AUTH_NEXT message requests to send more auth data.
  1130.  
  1131.      XIM_AUTH_NEXT (IM library <--> IM Server)
  1132.       2    n            length of authentication data
  1133.       2                unused
  1134.       n    <varies>        data
  1135.       p                unused, p = Pad(n)
  1136.  
  1137.  
  1138. The auth data is specific to the authentication protocol in
  1139. use.
  1140.  
  1141. The IM Server sends XIM_AUTH_SETUP message to authenticate
  1142. the client.
  1143.  
  1144.      XIM_AUTH_SETUP (IM Server -> IM library)
  1145.       2    CARD16            number of client-auth-protocol-names
  1146.       2                unused
  1147.       n    LISTofSTRING        server-auth-protocol-names
  1148.  
  1149.  
  1150. The list specifies the names of authentication protocols the
  1151. client is willing to perform.
  1152.  
  1153. XIM_AUTH_NG message requests to give up the connection.
  1154.  
  1155.      XIM_AUTH_NG (IM library <--> IM Server)
  1156.  
  1157.  
  1158. The IM Server sends XIM_CONNECT_REPLY message as the reply
  1159. to XIM_CONNECT or XIM_AUTH_REQUIRED message.
  1160.  
  1161.      XIM_CONNECT_REPLY (IM Server -> IM library)
  1162.       2    CARD16            server-major-protocol-version (*1)
  1163.       2    CARD16            server-minor-protocol-version (*1)
  1164.  
  1165.  
  1166.  
  1167.      (*1) Specify the version of IM Protocol that the IM
  1168.       Server supports.  This document specifies major
  1169.       version one, minor version zero.
  1170.  
  1171.  
  1172. Here are the state diagrams for the client and the IM
  1173. Server.
  1174.  
  1175. State transitions for the client
  1176.  
  1177.      init_status:
  1178.       Use authorization function -> client_ask
  1179.       Not use authorization function -> client_no_check
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.                  15
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. X Input Method Protocol             X11, Release 6.1
  1193.  
  1194.  
  1195.      start:
  1196.       Send XIM_CONNECT
  1197.            If client_ask -> client_wait1
  1198.            If client_no_check, client-auth-protocol-
  1199.            names may be omited -> client_wait2
  1200.  
  1201.  
  1202.      client_wait1:
  1203.       Receive XIM_AUTH_REQUIRED -> client_check
  1204.       Receive <other> -> client_NG
  1205.  
  1206.  
  1207.      client_check:
  1208.       If no more auth needed, send XIM_AUTH_REPLY ->
  1209.       client_wait2
  1210.       If good auth data, send XIM_AUTH_NEXT ->
  1211.       client_wait1
  1212.       If bad auth data, send XIM_AUTH_NG -> give up on
  1213.       this protocol
  1214.  
  1215.  
  1216.      client_wait2:
  1217.       Receive XIM_CONNECT_REPLY -> connect
  1218.       Receive XIM_AUTH_SETUP -> client_more
  1219.       Receive XIM_AUTH_NEXT -> client_more
  1220.       Receive XIM_AUTH_NG -> give up on this protocol
  1221.       Receive <other> -> client_NG
  1222.  
  1223.  
  1224.      client_more:
  1225.       Send XIM_AUTH_REQUIRED -> client_wait2
  1226.  
  1227.  
  1228.      client_NG:
  1229.       Send XIM_AUTH_NG -> give up on this protocol
  1230.  
  1231.  
  1232. State transitions for the IM Server
  1233.  
  1234.      init-status:
  1235.       Use authorization function -> server_ask
  1236.       Not use authorization function -> server_no_check
  1237.  
  1238.  
  1239.      start:
  1240.       Receive XIM_CONNECT -> start2
  1241.       Receive <other> -> server_NG
  1242.  
  1243.  
  1244.      start2:
  1245.       If client_ask, send XIM_AUTH_REQUIRED ->
  1246.       server_wait1
  1247.       If client_no_check and server_ask, send
  1248.       XIM_AUTH_SETUP -> server_wait2
  1249.  
  1250.  
  1251.  
  1252.                  16
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. X Input Method Protocol             X11, Release 6.1
  1259.  
  1260.  
  1261.       If client_no_check and server_no_check, send
  1262.       XIM_CONNECT_REPLY -> connect
  1263.  
  1264.  
  1265.      server_wait1:
  1266.       Receive XIM_AUTH_REPLY -> server2
  1267.       Receive XIM_AUTH_NEXT -> server_more
  1268.       Receive <other> -> server_NG
  1269.  
  1270.  
  1271.      server_more
  1272.       Send XIM_AUTH_REQUIRED -> server_wait1
  1273.  
  1274.  
  1275.      server2
  1276.       If server_ask, send XIM_AUTH_SETUP -> server_wait2
  1277.       If server_no_check, send XIM_CONNECT_REPLY -> con-
  1278.       nect
  1279.  
  1280.  
  1281.      server_wait2
  1282.       Receive XIM_AUTH_REQUIRED -> server_check
  1283.       Receive <other> -> server_NG
  1284.  
  1285.  
  1286.      server_check
  1287.       If no more auth data, send XIM_CONNECT_REPLY ->
  1288.       connect
  1289.       If bad auth data, send XIM_AUTH_NG -> give up on
  1290.       this protocol
  1291.       If good auth data, send XIM_AUTH_NEXT ->
  1292.       server_wait2
  1293.  
  1294.  
  1295.      server_NG
  1296.       Send XIM_AUTH_NG -> give up on this protocol
  1297.  
  1298.  
  1299. XIM_DISCONNECT message requests to shutdown the connection
  1300. over a mutually-understood virtual stream.
  1301.  
  1302.      XIM_DISCONNECT (IM library -> IM Server)
  1303.  
  1304.  
  1305. XIM_DISCONNECT is a synchronous request.  The IM library
  1306. should wait until it receives either an XIM_DISCONNECT_REPLY
  1307. packet or an XIM_ERROR packet.
  1308.  
  1309.  
  1310.      XIM_DISCONNECT_REPLY (IM Server -> IM library)
  1311.  
  1312.  
  1313. XIM_OPEN requests to establish a logical connection between
  1314. the IM library and the IM Server.
  1315.  
  1316.  
  1317.  
  1318.                  17
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. X Input Method Protocol             X11, Release 6.1
  1325.  
  1326.  
  1327.      XIM_OPEN (IM library -> IM Server)
  1328.       n    STR            locale name
  1329.       p                unused, p = Pad(n)
  1330.  
  1331.  
  1332. XIM_OPEN is a synchronous request.  The IM library should
  1333. wait until receiving either an XIM_OPEN_REPLY packet or an
  1334. XIM_ERROR packet.
  1335.  
  1336.  
  1337.      XIM_OPEN_REPLY (IM Server -> IM library)
  1338.       2    CARD16            input-method-ID
  1339.       2    n            byte length of IM attributes supported
  1340.       n    LISTofXIMATTR        IM attributes supported
  1341.       2    m            byte length of IC attributes supported
  1342.       2    CARD16            unused
  1343.       m    LISTofXICATTR         IC attributes supported
  1344.  
  1345.  
  1346. XIM_OPEN_REPLY message returns all supported IM and IC
  1347. attributes in LISTofXIMATTR and LISTofXICATTR.    These IM and
  1348. IC attribute IDs are used to reduce the amount of data which
  1349. must be transferred via the network. In addition, this indi-
  1350. cates to the IM library what kinds of IM/IC attributes can
  1351. be used in this session, and what types of data will be
  1352. exchanged. This allows the IM Server provider and applica-
  1353. tion writer to support IM system enhancements with new IM/IC
  1354. attributes, without modifying Xlib.  The IC value for the
  1355. separator of NestedList must be included in the LISTofXI-
  1356. CATTR.
  1357.  
  1358. XIM_CLOSE message requests to shutdown the logical connec-
  1359. tion between the IM library and the IM Server.
  1360.  
  1361.      XIM_CLOSE (IM library -> IM Server)
  1362.       2    CARD16            input-method-ID
  1363.       2                unused
  1364.  
  1365.  
  1366. XIM_CLOSE is a synchronous request.  The IM library should
  1367. wait until receiving either an XIM_CLOSE_REPLY packet or an
  1368. XIM_ERROR packet.
  1369.  
  1370.  
  1371.      XIM_CLOSE_REPLY (IM Server -> IM library)
  1372.       2    CARD16            input-method-ID
  1373.       2                unused
  1374.  
  1375.  
  1376.  
  1377. 4.5.  Event Flow Control
  1378.  
  1379. An IM Server must send XIM_SET_EVENT_MASK message to the IM
  1380. library in order for events to be forwarded to the IM
  1381.  
  1382.  
  1383.  
  1384.                  18
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. X Input Method Protocol             X11, Release 6.1
  1391.  
  1392.  
  1393. Server, since the IM library initially doesn't forward any
  1394. events to the IM Server. In the protocol, the IM Server will
  1395. specify masks of X events to be forwarded and which need to
  1396. be synchronized by the IM library.
  1397.  
  1398.  
  1399.      XIM_SET_EVENT_MASK (IM Server -> IM library)
  1400.       2    CARD16            input-method-ID
  1401.       2    CARD16            input-context-ID
  1402.       4    EVENTMASK        forward-event-mask (*1)
  1403.       4    EVENTMASK        synchronous-event-mask (*2)
  1404.  
  1405.  
  1406.  
  1407.      (*1) Specify all the events to be forwarded to the IM
  1408.       Server by the IM library.
  1409.  
  1410.      (*2) Specify the events to be forwarded with syn-
  1411.       chronous flag on by the IM library.
  1412.  
  1413.  
  1414. XIM_SET_EVENT_MASK is an asynchronous request.    The event
  1415. masks are valid immediately after they are set until changed
  1416. by another XIM_SET_EVENT_MASK message.    If input-context-ID
  1417. is set to zero, the default value of the input-method-ID
  1418. will be changed to the event masks specified in the request.
  1419. That value will be used for the IC's which have no individ-
  1420. ual values.
  1421.  
  1422. Using the Dynamic Event Flow model, an IM Server sends
  1423. XIM_REGISTER_TRIGGERKEYS message to the IM library before
  1424. sending XIM_OPEN_REPLY message.  Or the IM library may sup-
  1425. pose that the IM Server uses the Static Event Flow model.
  1426.  
  1427.      XIM_REGISTER_TRIGGERKEYS (IM Server -> IM library)
  1428.       2    CARD16              input-method-ID
  1429.       2                  unused
  1430.       4    n              byte length of on-keys
  1431.       n    LISTofXIMTRIGGERKEY   on-keys list
  1432.       4    m              byte length of off-keys
  1433.       m    LISTofXIMTRIGGERKEY   off-keys list
  1434.  
  1435.  
  1436. XIM_REGISTER_TRIGGERKEYS is an asynchronous request.  The IM
  1437. Server notifys the IM library of on-keys and off-keys lists
  1438. with this message.
  1439.  
  1440. The IM library notifys the IM Server with XIM_TRIGGER_NOTIFY
  1441. message that a key event matching either on-keys or off-keys
  1442. has been occurred.
  1443.  
  1444.  
  1445.      XIM_TRIGGER_NOTIFY (IM library -> IM Server)
  1446.  
  1447.  
  1448.  
  1449.  
  1450.                  19
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. X Input Method Protocol             X11, Release 6.1
  1457.  
  1458.  
  1459.       2    CARD16            input-method-ID
  1460.       2    CARD16            input-context-ID
  1461.       4    CARD32            flag
  1462.         #0            on-keys list
  1463.         #1            off-keys list
  1464.       4    CARD32            index of keys list
  1465.       4    EVENTMASK        client-select-event-mask (*1)
  1466.  
  1467.  
  1468.  
  1469.      (*1) Specify the events currently selected by the IM
  1470.       library with XSelectInput.
  1471.  
  1472.  
  1473. XIM_TRIGGER_NOTIFY is a synchronous request.  The IM library
  1474. should wait until receiving either an XIM_TRIG-
  1475. GER_NOTIFY_REPLY packet or an XIM_ERROR packet.
  1476.  
  1477.  
  1478.      XIM_TRIGGER_NOTIFY_REPLY (IM Server -> IM library)
  1479.       2    CARD16            input-method-ID
  1480.       2    CARD16            input-context-ID
  1481.  
  1482.  
  1483.  
  1484. 4.6.  Encoding Negotiation
  1485.  
  1486. XIM_ENCODING_NEGOTIATION message requests to decide which
  1487. encoding to be sent across the wire.  When the negotiation
  1488. fails, the fallback default encoding is Portable Character
  1489. Encoding.
  1490.  
  1491.      XIM_ENCODING_NEGOTIATION (IM library -> IM Server).sp 6p
  1492.       2    CARD16             input-method-ID
  1493.       2    n             byte length of encodings listed by name
  1494.       n    LISTofSTR         list of encodings supported in the IM library.
  1495.       p                 unused, p = Pad(n)
  1496.       2    m             byte length of encodings listed by detailed data
  1497.       2                 unused
  1498.       m    LISTofENCODINGINFO   list of encordings supported in the IM library
  1499.  
  1500.  
  1501. The IM Server must choose one encoding from the list sent by
  1502. the IM library.  If index of the encording determined is -1
  1503. to indicate that the negotiation is failed, the fallback
  1504. default encoding is used.  The message must be issued after
  1505. sending XIM_OPEN message via XOpenIM().  The name of encod-
  1506. ing may be registered with X Consortium.
  1507.  
  1508. XIM_ENCODING_NEGOTIATION is a synchronous request.  The IM
  1509. library should wait until receiving either an XIM_ENCOD-
  1510. ING_NEGOTIATION_REPLY packet or an XIM_ERROR packet.
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.                  20
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. X Input Method Protocol             X11, Release 6.1
  1523.  
  1524.  
  1525.      XIM_ENCODING_NEGOTIATION_REPLY (IM Server -> IM library)
  1526.       2    CARD16            input-method-ID
  1527.       2    CARD16            category of the encoding determined.
  1528.         #0            name
  1529.         #1            detailed data
  1530.       2    INT16            index of the encoding determinated.
  1531.       2                unused
  1532.  
  1533.  
  1534.  
  1535. 4.7.  Query the supported extension protocol list
  1536.  
  1537. XIM_QUERY_EXTENSION message requests to query the IM exten-
  1538. sions supported by the IM Server to which the client is
  1539. being connected.
  1540.  
  1541.      XIM_QUERY_EXTENSION (IM library -> IM Server)
  1542.       2    CARD16            input-method-ID
  1543.       2    n            byte length of extensions supported by
  1544.                     the IM library
  1545.       n    LISTofSTR        extensions supported by the IM library
  1546.       p                unused, p = Pad(n)
  1547.  
  1548.  
  1549. An example of a supported extension is FrontEnd.  The mes-
  1550. sage must be issued after sending XIM_OPEN message via
  1551. XOpenIM().
  1552.  
  1553. If n is 0, the IM library queries the IM Server for all
  1554. extensions.
  1555.  
  1556. If n is not 0, the IM library queries whether the IM Server
  1557. supports the contents specified in the list.
  1558.  
  1559. If a client uses an extension request without previously
  1560. having issued a XIM_QUERY_EXTENSION message for that exten-
  1561. sion, the IM Server responds with a BadProtocol error.    If
  1562. the IM Server encounters a request with an unknown MAJOR-
  1563. OPCODE or MINOR-OPCODE, it responds with a BadProtocol
  1564. error.
  1565.  
  1566. XIM_QUERY_EXTENSION is a synchronous request.  The IM
  1567. library should wait until receiving either an
  1568. XIM_QUERY_EXTENSION_REPLY packet or an XIM_ERROR packet.
  1569.  
  1570.  
  1571.      XIM_QUERY_EXTENSION_REPLY (IM Server -> IM library)
  1572.       2    CARD16            input-method-ID
  1573.       2    n            byte length of extensions supported
  1574.                     by both the IM library and the IM
  1575.                     Server
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.                  21
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. X Input Method Protocol             X11, Release 6.1
  1589.  
  1590.  
  1591.       n    LISTofEXT        list of extensions supported by
  1592.                     both the IM library and the IM
  1593.                     Server
  1594.  
  1595.  
  1596. XIM_QUERY_EXTENSION_REPLY message returns the list of exten-
  1597. sions supported by both the IM library and the IM Server. If
  1598. the list passed in XIM_QUERY_EXTENSION message is NULL, the
  1599. IM Server returns the full list of extensions supported by
  1600. the IM Server.    If the list is not NULL, the IM Server
  1601. returns the extensions in the list that are supported by the
  1602. IM Server.
  1603.  
  1604. A zero-length string is not a valid extension name.  The IM
  1605. library should disregard any zero-length strings that are
  1606. returned in the extension list.  The IM library does not use
  1607. the requests which are not supported by the IM Server.
  1608.  
  1609.  
  1610. 4.8.  Setting IM Values
  1611.  
  1612. XIM_SET_IM_VALUES requests to set attributes to the IM.
  1613.  
  1614.      XIM_SET_IM_VALUES (IM library -> IM Server)
  1615.       2    CARD16             input-method-ID
  1616.       2    n             byte length of im-attribute
  1617.       n    LISTofXIMATTRIBUTE   im-attributes
  1618.  
  1619.  
  1620. The im-attributes in XIM_SET_IM_VALUES message are specified
  1621. as a LISTofXIMATTRIBUTE, specifying the attributes to be
  1622. set. Attributes other than the ones returned by
  1623. XIM_OPEN_REPLY message should not be specified.
  1624.  
  1625. XIM_SET_IM_VALUES is a synchronous request. The IM library
  1626. should wait until receiving either an XIM_SET_IM_VAL-
  1627. UES_REPLY packet or an XIM_ERROR packet, because it must
  1628. receive the error attribute if XIM_ERROR message is
  1629. returned.
  1630.  
  1631.      XIM_SET_IM_VALUES_REPLY (IM Server -> IM library)
  1632.       2    CARD16            input-method-ID
  1633.       2                unused
  1634.  
  1635.  
  1636. XIM_SET_IM_VALUES_REPLY message returns the input-method-ID
  1637. to distinguish replies from multiple IMs.
  1638.  
  1639.  
  1640. 4.9.  Getting IM Values
  1641.  
  1642. XIM_GET_IM_VALUES requests to query IM values supported by
  1643. the IM Server currently being connected.
  1644.  
  1645.  
  1646.  
  1647.  
  1648.                  22
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. X Input Method Protocol             X11, Release 6.1
  1655.  
  1656.  
  1657.      XIM_GET_IM_VALUES (IM library -> IM Server)
  1658.       2    CARD16            input-method-ID
  1659.       2    n            byte length of im-attribute-id
  1660.       n    LISTofCARD16        im-attribute-id
  1661.       p                unused, p=Pad(n)
  1662.  
  1663.  
  1664. XIM_GET_IM_VALUES is a synchronous request.  The IM library
  1665. should wait until it receives either an XIM_GET_IM_VAL-
  1666. UES_REPLY packet or an XIM_ERROR packet.
  1667.  
  1668.      XIM_GET_IM_VALUES_REPLY (IM Server -> IM library)
  1669.       2    CARD16             input-method-ID
  1670.       2    n             byte length of im-attributes returned
  1671.       n    LISTofXIMATTRIBUTE   im-attributes returned
  1672.  
  1673.  
  1674. The IM Server returns IM values with XIM_GET_IM_VALUES_REPLY
  1675. message.  The order of the returned im-attribute values cor-
  1676. responds directly to that of the list passed with the
  1677. XIM_GET_IM_VALUES message.
  1678.  
  1679.  
  1680. 4.10.  Creating an IC
  1681.  
  1682. XIM_CREATE_IC message requests to create an IC.
  1683.  
  1684.  
  1685.      XIM_CREATE_IC (IM library -> IM Server)
  1686.       2    CARD16             input-method-ID
  1687.       2    n             byte length of ic-attributes
  1688.       n    LISTofXICATTRIBUTE   ic-attributes
  1689.  
  1690.  
  1691. The input-context-id is specified by the IM Server to iden-
  1692. tify the client (IC).  (It is not specified by the client in
  1693. XIM_CREATE_IC message.), and it should not be set to zero.
  1694.  
  1695. XIM_CREATE_IC is a synchronous request which returns the
  1696. input-context-ID.  The IM library should wait until it
  1697. receives either an XIM_CREATE_IC_REPLY packet or an
  1698. XIM_ERROR packet.
  1699.  
  1700.      XIM_CREATE_IC_REPLY (IM Server -> IM library)
  1701.       2    CARD16            input-method-ID
  1702.       2    CARD16            input-context-ID
  1703.  
  1704.  
  1705.  
  1706. 4.11.  Destroying the IC
  1707.  
  1708. XIM_DESTROY_IC message requests to destroy the IC.
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.                  23
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. X Input Method Protocol             X11, Release 6.1
  1721.  
  1722.  
  1723.      XIM_DESTROY_IC (IM library -> IM Server)
  1724.       2    CARD16            input-method-ID
  1725.       2    CARD16            input-context-ID
  1726.  
  1727.  
  1728. XIM_DESTROY_IC is a synchronous request. The IM library
  1729. should not free its resources until it receives an
  1730. XIM_DESTROY_IC_REPLY message because XIM_DESTROY_IC message
  1731. may result in Callback packets such as XIM_PREEDIT_DRAW and
  1732. XIM_PREEDIT_DONE.
  1733.  
  1734.  
  1735.      XIM_DESTROY_IC_REPLY (IM Server -> IM library)
  1736.       2    CARD16            input-method-ID
  1737.       2    CARD16            input-context-ID
  1738.  
  1739.  
  1740.  
  1741. 4.12.  Setting IC Values
  1742.  
  1743. XIM_SET_IC_VALUES messages requests to set attributes to the
  1744. IC.
  1745.  
  1746.      XIM_SET_IC_VALUES (IM library -> IM Server)
  1747.       2    CARD16             input-method-ID
  1748.       2    CARD16             input-context-ID
  1749.       2    n             byte length of ic-attributes
  1750.       2                 unused
  1751.       n    LISTofXICATTRIBUTE   ic-attributes
  1752.  
  1753.  
  1754. The ic-attributes in XIM_SET_IC_VALUES message are specified
  1755. as a LISTofXICATTRIBUTE, specifying the attributes to be
  1756. set. Attributes other than the ones returned by
  1757. XIM_OPEN_REPLY message should not be specified.
  1758.  
  1759. XIM_SET_IC_VALUES is a synchronous request. The IM library
  1760. should wait until receiving either an XIM_SET_IC_VAL-
  1761. UES_REPLY packet or an XIM_ERROR packet, because it must
  1762. receive the error attribute if XIM_ERROR message is
  1763. returned.
  1764.  
  1765.      XIM_SET_IC_VALUES_REPLY (IM Server -> IM library)
  1766.       2    CARD16            input-method-ID
  1767.       2    CARD16            input-context-ID
  1768.  
  1769.  
  1770.  
  1771. 4.13.  Getting IC Values
  1772.  
  1773. XIM_GET_IC_VALUES message requests to query IC values sup-
  1774. ported by the IM Server currently being connected.
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.                  24
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. X Input Method Protocol             X11, Release 6.1
  1787.  
  1788.  
  1789.      XIM_GET_IC_VALUES (IM library -> IM Server)
  1790.       2    CARD16            input-method-ID
  1791.       2    CARD16            input-context-ID
  1792.       2    n            byte length of ic-attribute-id
  1793.       n    LISTofCARD16        ic-attribute-id
  1794.       p                unused, p=Pad(2+n)
  1795.  
  1796.  
  1797. In LISTofCARD16, the appearance of the ic-attribute-id for
  1798. the separator of NestedList shows the end of the heading
  1799. nested list.
  1800.  
  1801. XIM_GET_IC_VALUES is a synchronous request and returns each
  1802. attribute with its values to show the correspondence.  The
  1803. IM library should wait until receiving either an
  1804. XIM_GET_IC_VALUES_REPLY packet or an XIM_ERROR packet.
  1805.  
  1806.      XIM_GET_IC_VALUES_REPLY (IM Server -> IM library)
  1807.       2    CARD16             input-method-ID
  1808.       2    CARD16             input-context-ID
  1809.       2    n             byte length of ic-attribute
  1810.       2                 unused
  1811.       n    LISTofXICATTRIBUTE   ic-attribute
  1812.  
  1813.  
  1814.  
  1815. 4.14.  Setting IC Focus
  1816.  
  1817. XIM_SET_IC_FOCUS message requests to set the focus to the
  1818. IC.
  1819.  
  1820.      XIM_SET_IC_FOCUS (IM library -> IM Server)
  1821.       2    CARD16            input-method-ID
  1822.       2    CARD16            input-context-ID
  1823.  
  1824.  
  1825. XIM_SET_IC_FOCUS is an asynchronous request.
  1826.  
  1827.  
  1828. 4.15.  Unsetting IC Focus
  1829.  
  1830. XIM_UNSET_IC_FOCUS message requests to unset the focus to
  1831. the focused IC.
  1832.  
  1833.      XIM_UNSET_IC_FOCUS (IM library -> IM Server)
  1834.       2    CARD16            input-method-ID
  1835.       2    CARD16            input-context-ID
  1836.  
  1837.  
  1838. XIM_UNSET_IC_FOCUS is an asynchronous request.
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.                  25
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. X Input Method Protocol             X11, Release 6.1
  1853.  
  1854.  
  1855. 4.16.  Filtering Events
  1856.  
  1857. Event filtering is mainly provided for BackEnd method to
  1858. allow input method to capture X events transparently to
  1859. clients.
  1860.  
  1861. X Events are forwarded by XIM_FORWARD_EVENT message.  This
  1862. message can be operated both synchronously and asyn-
  1863. chronously.  If the requester sets the synchronous flag, the
  1864. receiver must send XIM_SYNC_REPLY message back to the
  1865. requester when all the data processing is done.
  1866.  
  1867. Protocol flow of BackEnd model
  1868.  
  1869.  
  1870. With BackEnd method, the protocol flow can be classified
  1871. into two methods in terms of synchronization, depending on
  1872. the synchronous-eventmask of XIM_SET_EVENT_MASK message.
  1873. One can be called on-demand-synchronous method and another
  1874. can be called as full-synchronous method.
  1875.  
  1876. In on-demand-synchronous method, the IM library always
  1877. receives XIM_FORWARD_EVENT or XIM_COMMIT message as a syn-
  1878. chronous request. Also, the IM Server needs to synchronously
  1879. process the correspondent reply from the IM library and the
  1880. following XIM_FORWARD_EVENT message sent from the IM library
  1881. when any of the event causes the IM Server to send XIM_FOR-
  1882. WARD_EVENT or XIM_COMMIT message to the IM library, so that
  1883. the input service is consistent.  If the IM library gets the
  1884. control back from the application after receiving the syn-
  1885. chronous request, the IM library replies for the synchronous
  1886. request before processing any of the events. In this time,
  1887. the IM Server blocks XIM_FORWARD_EVENT message which is sent
  1888. by the IM library, and handles it after receiving the reply.
  1889. However, the IM Server handles the other protocols at any
  1890. time.
  1891.  
  1892. In full-synchronous method, the IM library always sends
  1893. XIM_FORWARD_EVENT message to the IM Server as a synchronous
  1894. request. Therefore, the reply to it from the IM Server will
  1895. be put between the XIM_FORWARD_EVENT message and its
  1896. XIM_SYNC_REPLY message.  In case of sending XIM_FOR-
  1897. WARD_EVENT or XIM_COMMIT message, the IM Server should set
  1898. the synchronous flag off. Because the synchronization can be
  1899. done by the following XIM_SYNC_REPLY message.
  1900.  
  1901.  
  1902. Sample Protocol flow chart 1
  1903.  
  1904. Following chart shows one of the simplest protocol flow
  1905. which only deals with keyevents for preediting operation.
  1906.  
  1907. ... 0.425 6.888 6.3 10.296 ... 0.000i 3.408i 5.875i 0.000i
  1908.  
  1909.  
  1910.  
  1911.  
  1912.                  26
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. X Input Method Protocol             X11, Release 6.1
  1919.  
  1920.  
  1921.          Xlib API     IM library          IM Server
  1922.   Key event_-XNextEvent        |          |
  1923.          XFilterEvent------|          |
  1924.                   -| XIM_FORWARD_EVENT|
  1925.                    |        --|
  1926.   Key event_-XNextEvent        | XIM_FORWARD_EVENT|synchronous
  1927.          XFilterEvent      | or XIM_COMMIT      |request
  1928.                   -| (synchronous)      |
  1929.              ----------|--        --|     ___
  1930.          XNextEvent        |        --|Pending  |
  1931.          XFilterEvent (returnXIM_FORWARD_EVENT|        |
  1932.        _____ XmbLookupString   |          |        |
  1933.  Application moves         --|  XIM_SYNC    --|        |
  1934.  the focus   XSetICFocus_______|__XIM_SYNC_REPLY_-|        |
  1935.                    |_________________ |processed|
  1936.                    |  XIM_SET_IC_FOCUS|(The focused
  1937.                    |        --|IC is changed)
  1938.          XNextEvent        |XIM_SYNC_REPLY as-apreplysed|
  1939.                   -|of the XIM_FORWARD_EVENT    |
  1940.                  --|          |        |
  1941.                    |           -- |processed|
  1942.  
  1943.  
  1944.  
  1945.          Fig.2 Sample Protocol Flow
  1946.  
  1947.  
  1948. Sample Protocol flow chart 2
  1949.  
  1950. Following chart shows one of the complex protocol flow,
  1951. which deals with multiple focus windows and button press
  1952. event as well as keyevent, and the focus is moved by the
  1953. application triggered by both of keyevent and button press
  1954. event.
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.                  27
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. X Input Method Protocol             X11, Release 6.1
  1985.  
  1986.  
  1987. ... 0.425 5.575 6.3 10.296 ... 0.000i 4.721i 5.875i 0.000i
  1988.  
  1989.          Xlib API     IM library          IM Server
  1990.   Key event_-XNextEvent        |          |
  1991.          XFilterEvent------|          |
  1992.                   -| XIM_FORWARD_EVENT|
  1993.                    |           -- |
  1994.   Key event_-XNextEvent        | XIM_FORWARD_EVENT|synchronous
  1995.          XFilterEvent      | or XIM_COMMIT      |request
  1996.                   -| (synchronous)      |
  1997.   focusnchangXSetICFocus       |        --|Pending__
  1998.               Pending untilM_FORWARD_EVENT|        |
  1999.               sync cycle-is doneM_SYNC    --|        |
  2000.                    |--          |        |
  2001.                    |-- XIM_SYNC_REPLY |        |
  2002.          XNextEvent       -|XIM_SET_IC_FOCUS is        |
  2003.          XFilterEvent (returpendabecause another sync cycle
  2004.        _____ XmbLookupString | |is started by XIM_COMMIT    |
  2005.  Application moves         | |          |        |
  2006.  the focus   XSetICFocus_______| XIM_SET_IC_FOCUS |        |
  2007.                  | |        --|processed|
  2008.                  | |        --|(The focused
  2009.                  | |          |IC is changed)
  2010.  Key event_--XNextEvent      | |XIM_SYNC_REPLY as apreplysed|
  2011.                  | |of the XIM_FORWARD_EVENT    |
  2012.          XFilterEvent    |-|          |        |
  2013.                  |+|           -- |processed|
  2014.                  -+|   XIM_SET_IC_FOCUS
  2015.                    |           -- |processed
  2016.                    |           -- |
  2017.                    |XIM_FORWARD_EVENT |
  2018.  
  2019.  
  2020.  
  2021.           Fig.3 Sample Protocol Flow chart
  2022.  
  2023.  
  2024.  
  2025.      XIM_FORWARD_EVENT (IM library <--> IM Server)
  2026.       2    CARD16            input-method-ID
  2027.       2    CARD16            input-context-ID
  2028.       2    BITMASK16        flag
  2029.         #0001            synchronous
  2030.         #0002            request filtering (*1)
  2031.         #0004            request lookupstring (*2)
  2032.       2    CARD16            serial number
  2033.         XEVENT            X event
  2034.  
  2035.  
  2036.  
  2037.      (*1) Indicate the receiver should filter events and
  2038.       possible preedit may be invoked.
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.                  28
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. X Input Method Protocol             X11, Release 6.1
  2051.  
  2052.  
  2053.      (*2) Indicate the receiver should only do lookup
  2054.       string. The IM Server is expected to just do a
  2055.       conversion of the key event to the best candidate.
  2056.       This bit may affect the state of the preedit state
  2057.       (e.g. compose of dead key sequences).
  2058.  
  2059. XEVENT format is same as the X Protocol event for-
  2060. mat(xEvent).  As the value of xEvent's sequenceNumber is the
  2061. bottom of 16 bit of XEvent's xany.serial, the top of 16 bit
  2062. is sent by serial number(INT16).
  2063.  
  2064. XIM_FORWARD_EVENT message is used for forwarding the events
  2065. from the IM library to the IM Server in order for IM to be
  2066. able to filter the event. On the other hand, this message is
  2067. also used for forwarding the events from the IM Server to
  2068. the IM library if the event forwarded from the IM library is
  2069. not filtered.  The IM Server, which receives XIM_FOR-
  2070. WARD_EVENT message without synchronous bit, should set syn-
  2071. chronous bit.  If both ``request event filtering'' and
  2072. ``request lookupstring'' flag are set, then both filtering
  2073. and lookup should be done for the same event.
  2074.  
  2075.  
  2076. 4.17.  Synchronizing with the IM Server
  2077.  
  2078. XIM_SYNC message requests to synchronize the IM library and
  2079. the IM Server.
  2080.  
  2081.      XIM_SYNC (IM library <--> IM Server)
  2082.       2    CARD16            input-method-ID
  2083.       2    CARD16            input-context-ID
  2084.  
  2085.  
  2086. This synchronization can be started either on the IM library
  2087. side or on the IM Server side.    The side which receives
  2088. XIM_SYNC message should process all XIM requests before
  2089. replying. The input-context-ID is necessary to distinguish
  2090. the IC with which the IM library and the IM Server are syn-
  2091. chronized.
  2092.  
  2093.      XIM_SYNC_REPLY (IM Server <--> IM library)
  2094.       2    CARD16            input-method-ID
  2095.       2    CARD16            input-context-ID
  2096.  
  2097.  
  2098. The side which receives XIM_FORWARD_EVENT, XIM_COMMIT or any
  2099. other message with synchronous bit, should process all XIM
  2100. request before replying, and send XIM_SYNC_REPLY message as
  2101. the reply to the previous message.
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.                  29
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. X Input Method Protocol             X11, Release 6.1
  2117.  
  2118.  
  2119. 4.18.  Sending a committed string
  2120.  
  2121. When the IM Server commits a string, the IM Server sends
  2122. either the committed string or list of KeySym, or both, by
  2123. XIM_COMMIT message.
  2124.  
  2125.      XIM_COMMIT (IM Server -> IM library)
  2126.       2    CARD16            input-method-ID
  2127.       2    CARD16            input-context-ID
  2128.       2    BITMASK16        flag
  2129.         #0001            synchronous
  2130.         #0002            XLookupChars
  2131.         #0004            XLookupKeySym
  2132.         #0006             XLookupBoth = XLookupChars | XLookupKeySym
  2133.  
  2134.  
  2135.      If flag is XLookupKeySym, the arguments continue as
  2136.      follows:
  2137.  
  2138.       2                unused
  2139.       4    KEYSYM            KeySym
  2140.  
  2141.  
  2142.      If flag is XLookupChars, the arguments continue as fol-
  2143.      lows:
  2144.  
  2145.       2    m            byte length of committed string
  2146.       m    LISTofBYTE        committed string
  2147.       p                unused, p = Pad(m)
  2148.  
  2149.  
  2150.      If flag is XLookupBoth, the arguments continue as fol-
  2151.      lows:
  2152.  
  2153.       2                unused
  2154.       4    KEYSYM            KeySym
  2155.       2    n            byte length of committed string
  2156.       n    LISTofBYTE        committed string
  2157.       p                unused, p = Pad(2+n)
  2158.  
  2159.  
  2160. The IM Server which receives XIM_COMMIT message without syn-
  2161. chronous bit should set synchronous bit.
  2162.  
  2163.  
  2164. 4.19.  Reset IC
  2165.  
  2166. XIM_RESET_IC message requests to reset the status of IC in
  2167. the IM Server.
  2168.  
  2169.      XIM_RESET_IC (IM library -> IM Server)
  2170.       2    CARD16            input-method-ID
  2171.       2    CARD16            input-context-ID
  2172.  
  2173.  
  2174.  
  2175.  
  2176.                  30
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. X Input Method Protocol             X11, Release 6.1
  2183.  
  2184.  
  2185. XIM_RESET_IC is a synchronous request. The IM library should
  2186. wait until receiving either an XIM_RESET_IC_REPLY packet or
  2187. an XIM_ERROR packet.
  2188.  
  2189.  
  2190.      XIM_RESET_IC_REPLY (IM Server -> IM library)
  2191.       2    CARD16            input-method-ID
  2192.       2    CARD16            input-context-ID
  2193.       2    n            byte length of preedit string
  2194.       n    LISTofBYTE        preedit string
  2195.       p                unused, p = Pad(2+n)
  2196.  
  2197.  
  2198. XIM_RESET_IC_REPLY message returns the input-context-ID to
  2199. distinguish replies from multiple ICs.
  2200.  
  2201.  
  2202. 4.20.  Callbacks
  2203.  
  2204. If XIMStyle has XIMPreeditArea or XIMStatusArea set, XIMGe-
  2205. ometryCallback may be used, and if XIMPreeditCallback and/or
  2206. XIMStatusCallback are set, corresponding callbacks may be
  2207. used.
  2208.  
  2209. Any callback request may be sent from an IM Server to an IM
  2210. client asynchronously in response to any request previously
  2211. sent by the IM client to the IM Server.
  2212.  
  2213. When an IM Server needs to send a callback request syn-
  2214. chronously with the request previously sent by an IM client,
  2215. the IM Server sends it before replying to the previous
  2216. request.
  2217.  
  2218.  
  2219. 4.20.1.  Negotiating geometry
  2220.  
  2221. The IM Server sends XIM_GEOMETRY message to start geometry
  2222. negotiation, if XIMStyle has XIMPreeditArea or XIMStatusArea
  2223. set.
  2224.  
  2225.      XIM_GEOMETRY (IM Server -> IM library)
  2226.       2    CARD16            input-method-ID
  2227.       2    CARD16            input-context-ID
  2228.  
  2229.  
  2230. There is always a single Focus Window, even if some input
  2231. fields have only one IC.
  2232.  
  2233.  
  2234. 4.20.2.  Converting a string
  2235.  
  2236.  
  2237.      XIM_STR_CONVERSION (IM Server -> IM library)
  2238.  
  2239.  
  2240.  
  2241.  
  2242.                  31
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. X Input Method Protocol             X11, Release 6.1
  2249.  
  2250.  
  2251.       2    CARD16            input-method-ID
  2252.       2    CARD16            input-context-ID
  2253.       2    CARD16            XIMStringConversionPosition
  2254.       2                unused
  2255.       4    CARD32            XIMCaretDirection
  2256.         #0            XIMForwardChar
  2257.         #1            XIMBackwardChar
  2258.         #2            XIMForwardWord
  2259.         #3            XIMBackwardWord
  2260.         #4            XIMCaretUp
  2261.         #5            XIMCaretDown
  2262.         #6            XIMNextLine
  2263.         #7            XIMCPreviousLine
  2264.         #8            XIMLineStart
  2265.         #9            XIMLineEnd
  2266.         #10            XIMAbsolutePosition
  2267.         #11            XIMDontChange
  2268.       2    CARD16            factor
  2269.       2    CARD16            XIMStringConversionOperation
  2270.         #0001            XIMStringConversionSubstitution
  2271.         #0002            XIMStringConversionRetrieval
  2272.       2    INT16            byte length to multiply the XIM-
  2273.                     StringConversionType
  2274.  
  2275.  
  2276.  
  2277. XIM_STR_CONVERSION message may be used to start the string
  2278. conversion from the IM Server.
  2279.  
  2280.  
  2281.      XIM_STR_CONVERSION_REPLY (IM library -> IM Server)
  2282.       2    CARD16            input-method-ID
  2283.       2    CARD16            input-context-ID
  2284.       4    CARD32            XIMStringConversionFeedback
  2285.         XIMSTRCONVTEXT        XIMStringConversionText
  2286.  
  2287.  
  2288.  
  2289. XIM_STR_CONVERSION_REPLY message returns the string to be
  2290. converted and the feedback information array.
  2291.  
  2292.  
  2293. 4.20.3.  Preedit Callbacks
  2294.  
  2295. The IM Server sends XIM_PREEDIT_START message to call the
  2296. XIMPreeditStartCallback function.
  2297.  
  2298.      XIM_PREEDIT_START (IM Server -> IM library)
  2299.       2    CARD16            input-method-ID
  2300.       2    CARD16            input-context-ID
  2301.  
  2302.  
  2303. The reply to this message must be sent synchronously. The
  2304. reply forwards the return value from the callback function
  2305.  
  2306.  
  2307.  
  2308.                  32
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314. X Input Method Protocol             X11, Release 6.1
  2315.  
  2316.  
  2317. to the IM Server.
  2318.  
  2319.      XIM_PREEDIT_START_REPLY (IM library -> IM Server)
  2320.       2    CARD16            input-method-ID
  2321.       2    CARD16            input-context-ID
  2322.       4    INT32            return value
  2323.  
  2324.  
  2325. XIM_PREEDIT_START_REPLY message returns the input-context-ID
  2326. to distinguish replies from multiple IC's.  The return value
  2327. contains the return value of the function XIMPreeditStart-
  2328. Callback.
  2329.  
  2330. The IM Server sends XIM_PREEDIT_DRAW message to call the
  2331. XIMPreeditDrawCallback function.
  2332.  
  2333.      XIM_PREEDIT_DRAW (IM Server -> IM library)
  2334.       2    CARD16            input-method-ID
  2335.       2    CARD16            input-context-ID
  2336.       4    INT32            caret
  2337.       4    INT32            chg_first
  2338.       4    INT32            chg_length
  2339.       4    BITMASK32        status
  2340.         #x0000001        no string
  2341.         #x0000002        no feedback
  2342.       2    n            length of preedit string
  2343.       n    STRING8         preedit string
  2344.       p                unused, p = Pad(2+n)
  2345.       2    m            byte length of feedback array
  2346.       2                unused
  2347.       m    LISTofXIMFEEDBACK   feedback array
  2348.  
  2349.  
  2350. The fields ``caret'', ``chg_first'' and ``chg_length'' cor-
  2351. respond to the fields of XIMPreeditDrawCallbackStruct.    When
  2352. the ``no string'' bit of the status field is set, the text
  2353. field of XIMPreeditDrawCallbackStruct is NULL.    When the
  2354. ``no feedback'' bit of the status field is set, the text
  2355. feedback field of XIMPreeditDrawCallbackStruct is NULL.
  2356. When the above bits are not set, ``preedit string'' contains
  2357. the preedit string to be displayed, and the feedback array
  2358. contains feedback information.
  2359.  
  2360. The IM Server sends XIM_PREEDIT_CARET message to call the
  2361. PreeditCaretCallback function.
  2362.  
  2363.      XIM_PREEDIT_CARET (IM Server -> IM library)
  2364.       2    CARD16            input-method-ID
  2365.       2    CARD16            input-context-ID
  2366.       4    INT32            position
  2367.       4    CARD32            direction
  2368.         #0            XIMForwardChar
  2369.         #1            XIMBackwardChar
  2370.  
  2371.  
  2372.  
  2373.  
  2374.                  33
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. X Input Method Protocol             X11, Release 6.1
  2381.  
  2382.  
  2383.         #2            XIMForwardWord
  2384.         #3            XIMBackwardWord
  2385.         #4            XIMCaretUp
  2386.         #5            XIMCaretDown
  2387.         #6            XIMNextLine
  2388.         #7            XIMCPreviousLine
  2389.         #8            XIMLineStart
  2390.         #9            XIMLineEnd
  2391.         #10            XIMAbsolutePosition
  2392.         #11            XIMDontChange
  2393.       4    CARD32            style
  2394.         #0            XIMInvisible
  2395.         #1            XIMCPrimary
  2396.         #2            XIMSecondary
  2397.  
  2398.  
  2399. Each entry corresponds to a field of XIMPreeditCaretCall-
  2400. backStruct.  Since this callback sets the caret position,
  2401. its reply must be sent synchronously.
  2402.  
  2403.      XIM_PREEDIT_CARET_REPLY (IM library -> IM Server)
  2404.       2    CARD16            input-method-ID
  2405.       2    CARD16            input-context-ID
  2406.       4    CARD32            position
  2407.  
  2408.  
  2409. The position is the value returned by the callback function
  2410. after it has been called.
  2411.  
  2412. The IM Server sends XIM_PREEDIT_DONE message to call the
  2413. XIMPreeditDoneCallback function.
  2414.  
  2415.      XIM_PREEDIT_DONE (IM Server -> IM library)
  2416.       2    CARD16            input-method-ID
  2417.       2    CARD16            input-context-ID
  2418.  
  2419.  
  2420.  
  2421. 4.20.4.  Preedit state notify
  2422.  
  2423.      XIM_PREEDITSTATE (IM Server -> IM Library)
  2424.       2    CARD16            input-method-ID
  2425.       2    CARD16            input-context-ID
  2426.       4    BITMASK32        XIMPreeditState
  2427.         #x0000000        XIMPreeditUnknown
  2428.         #x0000001        XIMPreeditEnable
  2429.         #x0000002        XIMPreeditDisable
  2430.  
  2431.  
  2432.  
  2433.  
  2434. XIM_PREEDITSTATE message is used to call the XIMPreedit-
  2435. StateNotifyCallback function.
  2436.  
  2437.  
  2438.  
  2439.  
  2440.                  34
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. X Input Method Protocol             X11, Release 6.1
  2447.  
  2448.  
  2449. 4.20.5.  Status Callbacks
  2450.  
  2451. The IM Server sends XIM_STATUS_START message to call the
  2452. XIMStatusStartCallback function.
  2453.  
  2454.      XIM_STATUS_START (IM Server -> IM library)
  2455.       2    CARD16            input-method-ID
  2456.       2    CARD16            input-context-ID
  2457.  
  2458.  
  2459. The IM Server sends XIM_STATUS_DRAW message to call the XIM-
  2460. StatusDrawCallback function.
  2461.  
  2462.      XIM_STATUS_DRAW (IM Server -> IM library)
  2463.       2    CARD16            input-method-ID
  2464.       2    CARD16            input-context-ID
  2465.       4    CARD32            type
  2466.         #0            XIMTextType
  2467.         #1            XIMBitmapType
  2468.  
  2469.  
  2470.      If type is XIMTextType, the arguments continue as fol-
  2471.      lows.
  2472.  
  2473.       4    BITMASK32        status
  2474.         #x0000001        no string
  2475.         #x0000002        no feedback
  2476.       2    n            length of status string
  2477.       n    STRING8         status string
  2478.       p                unused, p = Pad(2+n)
  2479.       2    m            byte length of feedback array
  2480.       2                unused
  2481.       m    LISTofXIMFEEDBACK   feedback array
  2482.  
  2483.  
  2484.      If type is XIMBitmapType, the arguments continue as
  2485.      follows.
  2486.  
  2487.       4    PIXMAP            pixmap data
  2488.  
  2489.  
  2490. The field ``type'' corresponds to the field in XIMStatus-
  2491. DrawCallbackStruct.
  2492.  
  2493. The IM Server sends XIM_STATUS_DONE message to call the XIM-
  2494. StatusDoneCallback function.
  2495.  
  2496.      XIM_STATUS_DONE (IM Server -> IM library)
  2497.       2    CARD16            input-method-ID
  2498.       2    CARD16            input-context-ID
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.                  35
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. X Input Method Protocol             X11, Release 6.1
  2513.  
  2514.  
  2515. 5.  Acknowledgements
  2516.  
  2517. This document represents the culmination of several years of
  2518. debate and experiments done under the auspices of the MIT X
  2519. Consortium i18n working group.    Although this was a group
  2520. effort, the author remains responsible for any errors or
  2521. omissions.
  2522.  
  2523. We would like to thank to all members of this group.  And we
  2524. would like to make special thanks to the following people
  2525. (in alphabetical order) for their participation in the IM
  2526. Protocol design, Hector Chan, Takashi Fujiwara, Yoshio Hori-
  2527. uchi, Makoto Inada, Hiromu Inukai, Mickael Kung, Seiji
  2528. Kuwari, Franky Ling, Hiroyuki Machida, Hiroyuki Miyamoto,
  2529. Frank Rojas, Bob Scheifler, Makiko Shimamura, Shoji
  2530. Sugiyama, Hidetoshi Tajima, Masaki Takeuchi, Makoto Waka-
  2531. matsu, Masaki Wakao, Nobuyuki Tanaka, Shigeru Yamada, Kat-
  2532. suhisa Yano, Jinsoo Yoon.
  2533.  
  2534.  
  2535. 6.  References
  2536.  
  2537. All of the following documents are X Consortium standards
  2538. available from MIT:
  2539.  
  2540. [1] Scheifler, Robert W., ``X Window System Protocol Version
  2541. 11''
  2542.  
  2543. [2] Scheifler, Robert W. etc., ``Xlib - C Language X Inter-
  2544. face''
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.                  36
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. X Input Method Protocol             X11, Release 6.1
  2579.  
  2580.  
  2581.              Appendix A
  2582.  
  2583.              Common Extensions
  2584.  
  2585.  
  2586. Extension opcodes and packet names (e.g.
  2587. XIM_EXT_SET_EVENT_MASK ) for additional extensions may be
  2588. registered with X Consortium.  The following is a commonly
  2589. well-known extended packet.
  2590.  
  2591.  
  2592.  
  2593. (1)  Extension to manipulate the event handling
  2594.  
  2595. XIM_EXT_SET_EVENT_MASK message specifies the set of event
  2596. masks that the IM library should manipulate.
  2597.  
  2598.      XIM_EXT_SET_EVENT_MASK (IM Server -> IM library)
  2599.       2    CARD16            input-method-ID
  2600.       2    CARD16            input-context-ID
  2601.       4    EVENTMASK        filter-event-mask (*1)
  2602.       4    EVENTMASK        intercept-event-mask (*2)
  2603.       4    EVENTMASK        select-event-mask (*3)
  2604.       4    EVENTMASK        forward-event-mask (*4)
  2605.       4    EVENTMASK        synchronous-event-mask (*5)
  2606.  
  2607.  
  2608.      (*1) Specify the events to be neglected by the IM
  2609.       library via XFilterEvent.
  2610.  
  2611.      (*2) Specify the events to be deselected by the IM
  2612.       library with XSelectInput.
  2613.  
  2614.      (*3) Specify the events to be selected by the IM
  2615.       library with XSelectInput.
  2616.  
  2617.      (*4) Specify all the events to be forwarded to the IM
  2618.       Server by the IM library.
  2619.  
  2620.      (*5) Specify the events to be forwarded with syn-
  2621.       chronous flag on by the IM library.
  2622.  
  2623. The IM library must reply XIM_SYNC_REPLY message to the IM
  2624. Server. This request is valid after the ic is created.
  2625.  
  2626.  
  2627.  
  2628. (2)  Extension for improvement of performance
  2629.  
  2630. The following requests may be used for improvement of per-
  2631. formance.
  2632.  
  2633. XIM_EXT_FORWARD_KEYEVENT message may be used instead of
  2634. XIM_FORWARD_EVENT message.
  2635.  
  2636.  
  2637.  
  2638.                  37
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. X Input Method Protocol             X11, Release 6.1
  2645.  
  2646.  
  2647.      XIM_EXT_FORWARD_KEYEVENT (IM Server <--> IM library)
  2648.       2    CARD16            input-method-ID
  2649.       2    CARD16            input-context-ID
  2650.       2    BITMASK16        flag
  2651.         #0001            synchronous
  2652.       2    CARD16            sequence number
  2653.       1    BYTE            xEvent.u.u.type
  2654.       1    BYTE            keycode
  2655.       2    CARD16            state
  2656.       4    CARD32            time
  2657.       4    CARD32            window
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.                  38
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. X Input Method Protocol             X11, Release 6.1
  2711.  
  2712.  
  2713. XIM_EXT_MOVE message may be used to change the spot location
  2714. instead of  XIM_SET_IC_VALUES message.    It is effective only
  2715. if the client specified XIMPreeditPosition.
  2716.  
  2717.      XIM_EXT_MOVE (IM library -> IM Server)
  2718.       2    CARD16            input-method-ID
  2719.       2    CARD16            input-context-ID
  2720.       2    INT16            X
  2721.       2    INT16            Y
  2722.  
  2723.  
  2724. XIM_EXT_MOVE message is a asynchronous request.
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.                  39
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. X Input Method Protocol             X11, Release 6.1
  2777.  
  2778.  
  2779.              Appendix B
  2780.  
  2781. The list of transport specific IM Server address format registered
  2782.  
  2783.  
  2784. The following format represents the ATOM contained in
  2785. XIM_SERVERS property and the string returned from the
  2786. request converting selection target LOCALES and TRANSPORT.
  2787.  
  2788.       ``{@category=[value,...]}...''
  2789.  
  2790.  
  2791. The following categories are currently registered.
  2792.  
  2793.      server     : IM Server name (used for XIM_SERVERS)
  2794.      locale     : XPG4 locale name (LOCALES)
  2795.      transport     : transport-specific name (TRANSPORT)
  2796.  
  2797.  
  2798. The preregistered formats for transport-specific names are
  2799. as follows:
  2800.  
  2801.      TCP/IP Names
  2802.  
  2803.       The following syntax should be used for system
  2804.       internal domain names:
  2805.  
  2806.            <local name>  ::= ``local/''<hostname>``:''<pathname>
  2807.  
  2808.  
  2809.       Where <pathname> is a path name of socket address.
  2810.  
  2811.       IM Server's name should be set to <pathname> to
  2812.       run multiple IM Server at the same time
  2813.  
  2814.       The following syntax should be used for Internet
  2815.       domain names:
  2816.  
  2817.            <TCP name>  ::=    ``tcp/''<hostname>``:''<ipportnumber>
  2818.  
  2819.       where <hostname> is either symbolic (such as
  2820.       expo.lcs.mit.edu) or numeric decimal (such as
  2821.       18.30.0.212).  The <ipportnumber> is the port on
  2822.       which the IM Server is listening for connections.
  2823.       For example:
  2824.  
  2825.            tcp/expo.lcs.mit.edu:8012
  2826.            tcp/18.30.0.212:7890
  2827.  
  2828.  
  2829.      DECnet Names
  2830.  
  2831.       The following syntax should be used for DECnet
  2832.       names:
  2833.  
  2834.  
  2835.  
  2836.                  40
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. X Input Method Protocol             X11, Release 6.1
  2843.  
  2844.  
  2845.            <DECnet name>  ::=  ``decnet/''<nodename>``::IMSERVER$''<objname>
  2846.  
  2847.       where <nodename> is either symbolic (such as
  2848.       SRVNOD) or the numeric decimal form of the DECnet
  2849.       address (such as 44.70).  The <objname> is normal,
  2850.       case-insensitive DECnet object name. For example:
  2851.  
  2852.            DECNET/SRVNOD::IMSERVER$DEFAULT
  2853.            decnet/44.70::IMSERVER$other
  2854.  
  2855.  
  2856.      X Names
  2857.  
  2858.       The following syntax should be used for X names:
  2859.  
  2860.            <X name>  ::=  ``X/''
  2861.  
  2862.  
  2863. If a given category has multiple values, the value is evalu-
  2864. ated in order of setting.
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  
  2880.  
  2881.  
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.                  41
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. X Input Method Protocol             X11, Release 6.1
  2909.  
  2910.  
  2911.              Appendix C
  2912.  
  2913.               Protocol number
  2914.  
  2915.  
  2916. Major Protocol number
  2917.  
  2918.      XIM_CONNECT                   #001
  2919.      XIM_CONNECT_REPLY               #002
  2920.      XIM_DISCONNECT                #003
  2921.      XIM_DISCONNECT_REPLY               #004
  2922.  
  2923.      XIM_AUTH_REQUIRED               #010
  2924.      XIM_AUTH_REPLY                #011
  2925.      XIM_AUTH_NEXT                   #012
  2926.      XIM_AUTH_SETUP                #013
  2927.      XIM_AUTH_NG                   #014
  2928.  
  2929.      XIM_ERROR                   #020
  2930.  
  2931.      XIM_OPEN                   #030
  2932.      XIM_OPEN_REPLY                #031
  2933.      XIM_CLOSE                   #032
  2934.      XIM_CLOSE_REPLY               #033
  2935.      XIM_REGISTER_TRIGGERKEYS           #034
  2936.      XIM_TRIGGER_NOTIFY               #035
  2937.      XIM_TRIGGER_NOTIFY_REPLY           #036
  2938.      XIM_SET_EVENT_MASK               #037
  2939.      XIM_ENCODING_NEGOTIATION           #038
  2940.      XIM_ENCODING_NEGOTIATION_REPLY        #039
  2941.      XIM_QUERY_EXTENSION               #040
  2942.      XIM_QUERY_EXTENSION_REPLY           #041
  2943.      XIM_SET_IM_VALUES               #042
  2944.      XIM_SET_IM_VALUES_REPLY           #043
  2945.      XIM_GET_IM_VALUES               #044
  2946.      XIM_GET_IM_VALUES_REPLY           #045
  2947.  
  2948.      XIM_CREATE_IC                   #050
  2949.      XIM_CREATE_IC_REPLY               #051
  2950.      XIM_DESTROY_IC                #052
  2951.      XIM_DESTROY_IC_REPLY               #053
  2952.      XIM_SET_IC_VALUES               #054
  2953.      XIM_SET_IC_VALUES_REPLY           #055
  2954.      XIM_GET_IC_VALUES               #056
  2955.      XIM_GET_IC_VALUES_REPLY           #057
  2956.      XIM_SET_IC_FOCUS               #058
  2957.      XIM_UNSET_IC_FOCUS               #059
  2958.      XIM_FORWARD_EVENT               #060
  2959.      XIM_SYNC                   #061
  2960.      XIM_SYNC_REPLY                #062
  2961.      XIM_COMMIT                   #063
  2962.      XIM_RESET_IC                   #064
  2963.      XIM_RESET_IC_REPLY               #065
  2964.  
  2965.  
  2966.  
  2967.  
  2968.                  42
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974. X Input Method Protocol             X11, Release 6.1
  2975.  
  2976.  
  2977.  
  2978.      XIM_GEOMETRY                   #070
  2979.      XIM_STR_CONVERSION               #071
  2980.      XIM_STR_CONVERSION_REPLY           #072
  2981.      XIM_PREEDIT_START               #073
  2982.      XIM_PREEDIT_START_REPLY           #074
  2983.      XIM_PREEDIT_DRAW               #075
  2984.      XIM_PREEDIT_CARET               #076
  2985.      XIM_PREEDIT_CARET_REPLY           #077
  2986.      XIM_PREEDIT_DONE               #078
  2987.      XIM_STATUS_START               #079
  2988.      XIM_STATUS_DRAW               #080
  2989.      XIM_STATUS_DONE               #081
  2990.      XIM_PREEDITSTATE               #082
  2991.  
  2992.  
  2993. (*) The IM Server's extension protocol number should be more
  2994. than #128.
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.                  43
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040. X Input Method Protocol             X11, Release 6.1
  3041.  
  3042.  
  3043.              Appendix D
  3044.  
  3045.             Implementation Tips
  3046.  
  3047.  
  3048.  
  3049. (1)  FrontEnd Method
  3050.  
  3051. FrontEnd method is recognized as a performance acceleration
  3052. by the trade off of the variety of the reliability.
  3053.  
  3054. In order to use the FrontEnd method, the IM library must
  3055. query the IM Server to see if the FrontEnd extension is
  3056. available.  The query is made by using the XIM_QUERY_EXTEN-
  3057. SION message. The IM Server may send XIM_EXT_SET_EVENT_MASK
  3058. message with intercept-event-mask, forward-event-mask, and
  3059. synchronous-event-mask values set after replying
  3060. XIM_QUERY_EXTENSION_REPLY message.
  3061.  
  3062. FrontEnd method can be implemented in a couple of ways
  3063. depending on how the IM Server utilize
  3064. XIM_EXT_SET_EVENT_MASK message.
  3065.  
  3066. One approach is to update both of the input mask and the
  3067. filter-event-mask depending on the preeidting state. The
  3068. sample protocol sequence using the static event flow is as
  3069. follows:
  3070.  
  3071.  
  3072. ... 1.675 6.888 6.237 10.296 ... 0.000i 3.408i 4.562i 0.000i
  3073.  
  3074.         IM library            IM Server
  3075.        Keys in the on-key-list            |
  3076.          _________-|_XIM_FORWARD_EVENT  |
  3077.                |_________________   |
  3078.                |XIM_EXT_SET_EVENT_MASK
  3079.      event mask is changedrcept-event-maskvistsetsk is changed
  3080.      to deselect the event            |to select the event
  3081.                |            |
  3082.                |            |_______
  3083.                |            |--
  3084.                |            | X events directly come
  3085.                |            | to the IM Server.
  3086.                |            | when preediting is turning off
  3087.                |_________________   |
  3088.      event mask is changedT_SET_EVENT_MASKevent mask is changed
  3089.      to select the eventlect-event-mask istseteselect the event
  3090.                |            |
  3091.                |            |
  3092.                |            |
  3093.                |            |
  3094.                |            |
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.                  44
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106. X Input Method Protocol             X11, Release 6.1
  3107.  
  3108.  
  3109. To pursuit a maximum performance regardless of the preedit-
  3110. ing mode, the IM Server may use the dynamic event flow with
  3111. the following sample protocol sequence.
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.  
  3136.  
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.                  45
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172. X Input Method Protocol             X11, Release 6.1
  3173.  
  3174.  
  3175. ... 1.675 6.888 6.237 10.296 ... 0.000i 3.408i 4.562i 0.000i
  3176.  
  3177.         IM library            IM Server
  3178.        Keys in the on-key-list            |
  3179.          _________-|_XIM_TRIGGER_NOTIFY |
  3180.                |_________________   |
  3181.                |XIM_EXT_SET_EVENT_MASK
  3182.      event mask is changedrcept-event-maskvistsetsk is changed
  3183.      to deselect theXeventIGGER_NOTIFY_REPLYselect the event
  3184.                |_________________   |
  3185.                |            |_______
  3186.                |            |--
  3187.                |            | X events directly come
  3188.                |            | to the IM Server.
  3189.                |            | when preediting is turning off
  3190.                |_________________   |
  3191.      event mask is changedT_SET_EVENT_MASKevent mask is changed
  3192.      to select the eventlect-event-mask istseteselect the event
  3193.                |            |
  3194.                |            |
  3195.                |            |
  3196.                |            |
  3197.                |            |
  3198.  
  3199.  
  3200. This method can reduce the XIM protocol traffic dramatically
  3201. by updating intercept-event-mask and select-event-mask
  3202. accordingly.  The tradeoff of this performance improvement
  3203. is that the key events may be lost or disordered in some
  3204. particular situation, such as when the user types the key-
  3205. board in following sequence really fast:
  3206.      <preediting on key>``some strings''<preediting off
  3207.      key>``another string''
  3208. Since this method requires the input mask updates to the
  3209. both the IM Server and Xlib when turning on and off the
  3210. preediting, and there is a time lag till the requests take
  3211. effect when two client issues the input mask updates simul-
  3212. taneously.
  3213.  
  3214. Another approach of the FrontEnd method is to update the
  3215. filter-event-mask depending on the preediting state and not
  3216. to update the input mask.  The IM Server must register both
  3217. of the preediting on key list and off key list by XIM_REGIS-
  3218. TER_TRIGGERKEYS message.  In this method, Both the IM Server
  3219. and the IM client select the same events on the same
  3220. client's window, so that the events are delivered to both of
  3221. the IM Server and the client. The preediting on and off
  3222. states are expressed by whether the key events are filtered
  3223. or not.  The sample protocol sequence are as follows:
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.                  46
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238. X Input Method Protocol             X11, Release 6.1
  3239.  
  3240.  
  3241. <<Using static event flow>>
  3242.  
  3243.  
  3244. ... 1.488 7.325 6.487 10.358 ... 0.000i 3.033i 4.999i 0.000i
  3245.  
  3246.         IM library            IM Server
  3247.  
  3248.      Keys in the_on-key-lXIM_FORWARD_EVENT  |__Keys_in_the on-key-list
  3249.               | _________________-  |--
  3250.               | XIM_EXT_SET_EVENT_MASK
  3251.        the specified eventsr-event-mask istsetspecified events
  3252.        are being filtered            | are being processed
  3253.               |             |
  3254.               |             |
  3255.       Keys in the off-key-list            |  Keys in the off-key-list
  3256.          _________|             |__________
  3257.               |  _________________  |
  3258.               | XIfilter-event-maskAis set
  3259.               |             |
  3260.        the specified events         | the specified events
  3261.        are being processed            | are being discarded
  3262.               |             |
  3263.               |             |
  3264.               |             |
  3265.               |             |
  3266.  
  3267. <<Using the dynamic event flow>>
  3268.  
  3269. ... 1.488 7.325 6.487 10.358 ... 0.000i 3.033i 4.999i 0.000i
  3270.  
  3271.         IM library            IM Server
  3272.  
  3273.      Keys in the_on-key-list_TRIGGER_NOTIFY |__Keys_in_the on-key-list
  3274.               | _________________-  |--
  3275.               | XIM_EXT_SET_EVENT_MASK
  3276.        the specified eventsr-event-mask istsetspecified events
  3277.        are being filtered            | are being processed
  3278.               | XIM_TRIGGER_NOTIFY_REPLY
  3279.               | _________________   |
  3280.       Keys in the off-key-list            |  Keys in the off-key-list
  3281.          _________|             |__________
  3282.               |  _________________  |
  3283.               | XIfilter-event-maskAis set
  3284.               |             |
  3285.        the specified events         | the specified events
  3286.        are being processed            | are being discarded
  3287.               |             |
  3288.               |             |
  3289.               |             |
  3290.               |             |
  3291.  
  3292.  
  3293. This method does not have the problem of the time lag when
  3294. going across the preediting on and off mode, however, the
  3295.  
  3296.  
  3297.  
  3298.                  47
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304. X Input Method Protocol             X11, Release 6.1
  3305.  
  3306.  
  3307. amount of the performance acceleration is not as good as the
  3308. method described above.
  3309.  
  3310. In general, the FrontEnd method requires some synchroniza-
  3311. tion to some of the X protocols, such as the ChangeWindowAt-
  3312. tribute protocol for the event mask change or the GrabKey
  3313. protocol, since it relies on the X's principal event dis-
  3314. patching mechanism. Any X protocol bindings do not consider
  3315. the synchronization might cause some mis-synchronization
  3316. between the IM clients and the IM Server.
  3317.  
  3318.  
  3319.  
  3320.  
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.  
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.  
  3364.                  48
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370. X Input Method Protocol             X11, Release 6.1
  3371.  
  3372.  
  3373. (2)  Transport Layer
  3374.  
  3375. The Xlib XIM implementation is layered into three functions,
  3376. a protocol layer, an interface layer and a transport layer.
  3377. The purpose of this layering is to make the protocol inde-
  3378. pendent of transport implementation.  Each function of these
  3379. layers are:
  3380.  
  3381.      The protocol layer
  3382.       implements overall function of XIM and calls the
  3383.       interface layer functions when it needs to commu-
  3384.       nicate to IM Server.
  3385.  
  3386.      The interface layer
  3387.       separates the implementation of the transport
  3388.       layer from the protocol layer, in other words, it
  3389.       provides implementation independent hook for the
  3390.       transport layer functions.
  3391.  
  3392.      The transport layer
  3393.       handles actual data communication with IM Server.
  3394.       It is done by a set of several functions named
  3395.       transporters.
  3396.  
  3397. The interface layer and the transport layer make various
  3398. communication channels usable such as X Protocol, TCP/IP,
  3399. DECnet or STREAM.  The following is a sample implementation
  3400. for the transporter using the X connection.  Refer to
  3401. "xtrans" for the transporter using Socket Transport.
  3402.  
  3403. At the beginning of the X Transport connection for the XIM
  3404. transport mechanism, two different windows must be created
  3405. either in an Xlib XIM or in an IM Server, with which the
  3406. Xlib and the IM Server exchange the XIM transports by using
  3407. the ClientMessage events and Window Properties.  In the fol-
  3408. lowing, the window created by the Xlib is referred as the
  3409. "client communication window", and on the other hand, the
  3410. window created by the IM Server is referred as the "IMS com-
  3411. munication window".
  3412.  
  3413. Connection
  3414.  
  3415.      In order to establish a connection, a communication
  3416.      window is created.  A ClientMessage in the following
  3417.      event's format is sent to the owner window of
  3418.      XIM_SERVER selection, which the IM Server has created.
  3419.  
  3420.      Refer to "The Input Method Protocol" for the XIM_SERVER
  3421.      atom.
  3422.  
  3423.       Table D-1; The ClientMessage sent to the IMS window.
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.                  49
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436. X Input Method Protocol             X11, Release 6.1
  3437.  
  3438.  
  3439.      -----------------------+------------------------------------------------
  3440.      Structure Member        | Contents
  3441.      -----------------------+------------------------------------------------
  3442.      int       type        | ClientMessage
  3443.      u_long    serial        | Set by the X Window System
  3444.      Bool      send_event   | Set by the X Window System
  3445.      Display   *display     | The display to which connects
  3446.      Window    window        | IMS Window ID
  3447.      Atom      message_type | XInternAtom(display, ``_XIM_XCONNECT'', False)
  3448.      int       format        | 32
  3449.      long      data.l[0]    | client communication window ID
  3450.      long      data.l[1]    | client-major-transport-version (*1)
  3451.      long      data.l[2]    | client-major-transport-version (*1)
  3452.      -----------------------+------------------------------------------------
  3453.  
  3454.  
  3455.      In order to establish the connection (to notify the IM
  3456.      Server communication window), the IM Server sends a
  3457.      ClientMessage in the following event's format to the
  3458.      client communication window.
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496.                  50
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502. X Input Method Protocol             X11, Release 6.1
  3503.  
  3504.  
  3505.      Table D-2; The ClientMessage sent by IM Server.
  3506.  
  3507.      -----------------------+-------------------------------------------------------
  3508.      Structure Member        | Contents
  3509.      -----------------------+-------------------------------------------------------
  3510.      int       type        | ClientMessage
  3511.      u_long    serial        | Set by the X Window System
  3512.      Bool      send_event   | Set by the X Window System
  3513.      Display   *display     | The display to which connects
  3514.      Window    window        | client communication window ID
  3515.      Atom      message_type | XInternAtom(display, ``_XIM_XCONNECT'', False)
  3516.      int       format        | 32
  3517.      long      data.l[0]    | IMS communication window ID
  3518.      long      data.l[1]    | server-major-transport-version (*1)
  3519.      long      data.l[2]    | server-minor-transport-version (*1)
  3520.      long      data.l[3]    | dividing size between ClientMessage and Property (*2)
  3521.      -----------------------+-------------------------------------------------------
  3522.  
  3523.  
  3524.  
  3525.      (*1) major/minor-transport-version
  3526.            The read/write method is decided by the com-
  3527.            bination of major/minor-transport-version, as
  3528.            follows:
  3529.  
  3530.       Table D-3; The read/write method and the major/minor-transport-version
  3531.  
  3532.       +------------------+---------------------------------------+
  3533.       |Transport-version | read/write                 |
  3534.       +--------+---------+---------------------------------------+
  3535.       | major  |  minor  |                     |
  3536.       +--------+---------+---------------------------------------+
  3537.       |   0    |    0     | only-CM & Property-with-CM         |
  3538.       |        |    1     | only-CM & multi-CM             |
  3539.       |        |    2     | only-CM & multi-CM & Property-with-CM |
  3540.       +--------+---------+---------------------------------------+
  3541.       |   1    |    0     | PropertyNotify             |
  3542.       +--------+---------+---------------------------------------+
  3543.       |   2    |    0     | only-CM & PropertyNotify         |
  3544.       |        |    1     | only-CM & multi-CM & PropertyNotify     |
  3545.       +--------+---------+---------------------------------------+
  3546.  
  3547.  
  3548.  
  3549.       only-CM         :   data is sent via a ClientMessage
  3550.       multi-CM         :   data is sent via multiple ClientMessages
  3551.       Property-with-CM     :   data is written in Property, and its Atom
  3552.                  is send via ClientMessage
  3553.       PropertyNotify     :   data is written in Property, and its Atom
  3554.                  is send via PropertyNotify
  3555.  
  3556.  
  3557.       The method to decide major/minor-transport-version
  3558.       is as follows:
  3559.  
  3560.  
  3561.  
  3562.                  51
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568. X Input Method Protocol             X11, Release 6.1
  3569.  
  3570.  
  3571.       (1)  The client sends 0 as major/minor-transport-
  3572.            version to the IM Server.  The client must
  3573.            support all methods in Table D-3.  The client
  3574.            may send another number as major/minor-trans-
  3575.            port-version to use other method than the
  3576.            above in the future.
  3577.  
  3578.       (2)  The IM Server sends its major/minor-trans-
  3579.            port-version number to the client. The client
  3580.            sends data using the method specified by the
  3581.            IM Server.
  3582.  
  3583.       (3)  If major/minor-transport-version number is
  3584.            not available, it is regarded as 0.
  3585.  
  3586.  
  3587.      (*2) dividing size between ClientMessage and Property
  3588.            If data is sent via both of multi-CM and
  3589.            Property, specify the dividing size between
  3590.            ClientMessage and Property. The data, which
  3591.            is smaller than this size, is sent via multi-
  3592.            CM (or only-CM), and the data, which is lager
  3593.            than this size, is sent via Property.
  3594.  
  3595.  
  3596.  
  3597. read/write
  3598.  
  3599.      The data is transferred via either ClientMessage or
  3600.      Window Property in the X Window System.
  3601.  
  3602.      Format for the data from the Client to the IM Server
  3603.  
  3604.       ClientMessage
  3605.  
  3606.       If data is sent via ClientMessage event, the for-
  3607.       mat is as follows:
  3608.  
  3609.       Table D-4; The ClientMessage event's format (first
  3610.                   or middle)
  3611.  
  3612.       -----------------------+------------------------------------------------
  3613.       Structure Member     | Contents
  3614.       -----------------------+------------------------------------------------
  3615.       int        type     | ClientMessage
  3616.       u_long    serial     | Set by the X Window System
  3617.       Bool        send_event     | Set by the X Window System
  3618.       Display   *display     | The display to which connects
  3619.       Window    window     | IMS communication window ID
  3620.       Atom        message_type | XInternAtom(display, ``_XIM_MOREDATA'', False)
  3621.       int        format     | 8
  3622.       char        data.b[20]     | (read/write DATA : 20 byte)
  3623.       -----------------------+------------------------------------------------
  3624.  
  3625.  
  3626.  
  3627.  
  3628.                  52
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634. X Input Method Protocol             X11, Release 6.1
  3635.  
  3636.  
  3637.       Table D-5; The ClientMessage event's format (only
  3638.                    or last)
  3639.  
  3640.       -----------------------+------------------------------------------------
  3641.       Structure Member     | Contents
  3642.       -----------------------+------------------------------------------------
  3643.       int        type     | ClientMessage
  3644.       u_long    serial     | Set by the X Window System
  3645.       Bool        send_event     | Set by the X Window System
  3646.       Display   *display     | The display to which connects
  3647.       Window    window     | IMS communication window ID
  3648.       Atom        message_type | XInternAtom(display, ``_XIM_PROTOCOL'', False)
  3649.       int        format     | 8
  3650.       char        data.b[20]     | (read/write DATA : MAX 20 byte)  (*1)
  3651.       -----------------------+------------------------------------------------
  3652.  
  3653.  
  3654.       (*1) If the data is smaller than 20 byte, all data
  3655.            other than available data must be 0.
  3656.  
  3657.       Property
  3658.  
  3659.       In the case of large data, data will be sent via
  3660.       the Window Property for the efficiency.  There are
  3661.       the following two methods to notify Property, and
  3662.       transport-version is decided which method is used.
  3663.  
  3664.  
  3665.       (1)  The XChangeProperty function is used to store
  3666.            data in the client communication window, and
  3667.            Atom of the stored data is notified to the IM
  3668.            Server via ClientMessage event.
  3669.  
  3670.       (2)  The XChangeProperty function is used to store
  3671.            data in the client communication window, and
  3672.            Atom of the stored data is notified to the IM
  3673.            Server via PropertyNotify event.
  3674.  
  3675.       The arguments of the XChangeProperty are as fol-
  3676.       lows:
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.                  53
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700. X Input Method Protocol             X11, Release 6.1
  3701.  
  3702.  
  3703.         Table D-6; The XChangeProperty event's format
  3704.  
  3705.       --------------------+--------------------------------
  3706.       Argument          | Contents
  3707.       --------------------+--------------------------------
  3708.       Display   *display  | The display to which connects
  3709.       Window    window    | IMS communication window ID
  3710.       Atom        property  | read/write property Atom (*1)
  3711.       Atom        type      | XA_STRING
  3712.       int        format    | 8
  3713.       int        mode      | PropModeAppend
  3714.       u_char    *data     | read/write DATA
  3715.       int        nelements | length of DATA
  3716.       --------------------+--------------------------------
  3717.  
  3718.  
  3719.  
  3720.       (*1) The read/write property ATOM allocates the
  3721.            following strings by XInternAtom.
  3722.             ``_clientXXX''
  3723.  
  3724.       The client changes the property with the mode of
  3725.       PropModeAppend and the IM Server will read it with
  3726.       the delete mode i.e. (delete = True).
  3727.  
  3728.       If Atom is notified via ClientMessage event, the
  3729.       format of the ClientMessage is as follows:
  3730.  
  3731.       Table D-7; The ClientMessage event's format to
  3732.             send Atom of property
  3733.  
  3734.       -----------------------+------------------------------------------------
  3735.       Structure Member     | Contents
  3736.       -----------------------+------------------------------------------------
  3737.       int        type     | ClientMessage
  3738.       u_long    serial     | Set by the X Window System
  3739.       Bool        send_event     | Set by the X Window System
  3740.       Display   *display     | The display to which connects
  3741.       Window    window     | IMS communication window ID
  3742.       Atom        message_type | XInternAtom(display, ``_XIM_PROTOCOL'', False)
  3743.       int        format     | 32
  3744.       long        data.l[0]     | length of read/write property Atom
  3745.       long        data.l[1]     | read/write property Atom
  3746.       -----------------------+------------------------------------------------
  3747.  
  3748.  
  3749.      Format for the data from the IM Server to the Client
  3750.  
  3751.       ClientMessage
  3752.  
  3753.       The format of the ClientMessage is as follows:
  3754.  
  3755.       Table D-8; The ClientMessage event's format (first
  3756.                   or middle)
  3757.  
  3758.  
  3759.  
  3760.                  54
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766. X Input Method Protocol             X11, Release 6.1
  3767.  
  3768.  
  3769.       -----------------------+------------------------------------------------
  3770.       Structure Member     | Contents
  3771.       -----------------------+------------------------------------------------
  3772.       int        type     | ClientMessage
  3773.       u_long    serial     | Set by the X Window System
  3774.       Bool        send_event     | Set by the X Window System
  3775.       Display   *display     | The display to which connects
  3776.       Window    window     | client communication window ID
  3777.       Atom        message_type | XInternAtom(display, ``_XIM_MOREDATA'', False)
  3778.       int        format     | 8
  3779.       char        data.b[20]     | (read/write DATA : 20 byte)
  3780.       -----------------------+------------------------------------------------
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.                  55
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832. X Input Method Protocol             X11, Release 6.1
  3833.  
  3834.  
  3835.       Table D-9; The ClientMessage event's format (only
  3836.                    or last)
  3837.  
  3838.       -----------------------+------------------------------------------------
  3839.       Structure Member     | Contents
  3840.       -----------------------+------------------------------------------------
  3841.       int        type     | ClientMessage
  3842.       u_long    serial     | Set by the X Window System
  3843.       Bool        send_event     | Set by the X Window System
  3844.       Display   *display     | The display to which connects
  3845.       Window    window     | client communication window ID
  3846.       Atom        message_type | XInternAtom(display, ``_XIM_PROTOCOL'', False)
  3847.       int        format     | 8
  3848.       char        data.b[20]     | (read/write DATA : MAX 20 byte) (*1)
  3849.       -----------------------+------------------------------------------------
  3850.  
  3851.  
  3852.  
  3853.       (*1) If the data size is smaller than 20 bytes,
  3854.            all data other than available data must be 0.
  3855.  
  3856.       Property
  3857.  
  3858.       In the case of large data, data will be sent via
  3859.       the Window Property for the efficiency. There are
  3860.       the following two methods to notify Property, and
  3861.       transport-version is decided which method is used.
  3862.  
  3863.  
  3864.       (1)  The XChangeProperty function is used to store
  3865.            data in the IMS communication window, and
  3866.            Atom of the property is sent via the
  3867.            ClientMessage event.
  3868.  
  3869.       (2)  The XChangeProperty function is used to store
  3870.            data in the IMS communication window, and
  3871.            Atom of the property is sent via PropertyNo-
  3872.            tify event.
  3873.  
  3874.       The arguments of the XChangeProperty are as fol-
  3875.       lows:
  3876.  
  3877.         Table D-10; The XChangeProperty event's format
  3878.  
  3879.       --------------------+----------------------------------
  3880.       Argument          | Contents
  3881.       --------------------+----------------------------------
  3882.       Display   *display  | The display which to connects
  3883.       Window    window    | client communication window ID
  3884.       Atom        property  | read/write property Atom (*1)
  3885.       Atom        type      | XA_STRING
  3886.       int        format    | 8
  3887.       int        mode      | PropModeAppend
  3888.  
  3889.  
  3890.  
  3891.  
  3892.                  56
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898. X Input Method Protocol             X11, Release 6.1
  3899.  
  3900.  
  3901.       --------------------+----------------------------------
  3902.       Argument          | Contents
  3903.       --------------------+----------------------------------
  3904.       u_char    *data     | read/write DATA
  3905.       int        nelements | length of DATA
  3906.       --------------------+----------------------------------
  3907.  
  3908.  
  3909.  
  3910.       (*1) The read/write property ATOM allocates some
  3911.            strings, which are not allocated by the
  3912.            client, by XInternAtom.
  3913.  
  3914.       The IM Server changes the property with the mode
  3915.       of PropModeAppend and the client reads it with the
  3916.       delete mode, i.e. (delete = True).
  3917.  
  3918.       If Atom is notified via ClientMessage event, the
  3919.       format of the ClientMessage is as follows:
  3920.  
  3921.  
  3922.  
  3923.  
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.                  57
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964. X Input Method Protocol             X11, Release 6.1
  3965.  
  3966.  
  3967.       Table D-11; The ClientMessage event's format to
  3968.             send Atom of property
  3969.  
  3970.       -----------------------+------------------------------------------------
  3971.       Structure Member     | Contents
  3972.       -----------------------+------------------------------------------------
  3973.       int        type     | ClientMessage
  3974.       u_long    serial     | Set by the X Window System
  3975.       Bool        send_event     | Set by the X Window System
  3976.       Display   *display     | The display to which connects
  3977.       Window    window     | client communication window ID
  3978.       Atom        message_type | XInternAtom(display, ``_XIM_PROTOCOL'', False)
  3979.       int        format     | 32
  3980.       long        data.l[0]     | length of read/write property ATOM
  3981.       long        data.l[1]     | read/write property ATOM
  3982.       -----------------------+------------------------------------------------
  3983.  
  3984.  
  3985. Closing Connection
  3986.  
  3987.      If the client disconnect with the IM Server, shutdown
  3988.      function should free the communication window proper-
  3989.      ties and etc..
  3990.  
  3991.  
  3992.  
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998.  
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.  
  4005.  
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024.                  58
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030. X Input Method Protocol             X11, Release 6.1
  4031.  
  4032.  
  4033.              Table of Contents
  4034.  
  4035.  
  4036. 1. Introduction  . . . . . . . . . . . . . . . . . . . .   1
  4037. 1.1. Scope . . . . . . . . . . . . . . . . . . . . . . .   1
  4038. 1.2. Background  . . . . . . . . . . . . . . . . . . . .   1
  4039. 1.3. Input Method Styles . . . . . . . . . . . . . . . .   2
  4040. 2. Architecture  . . . . . . . . . . . . . . . . . . . .   3
  4041. 2.1. Implementation Model  . . . . . . . . . . . . . . .   3
  4042. 2.2. Structure of IM . . . . . . . . . . . . . . . . . .   3
  4043. 2.3. Event Handling Model  . . . . . . . . . . . . . . .   4
  4044. 2.3.1. BackEnd Method  . . . . . . . . . . . . . . . . .   4
  4045. 2.3.2. FrontEnd Method . . . . . . . . . . . . . . . . .   4
  4046. 2.4. Event Flow Control  . . . . . . . . . . . . . . . .   6
  4047. 3. Default Preconnection Convention  . . . . . . . . . .   7
  4048. 4. Protocol  . . . . . . . . . . . . . . . . . . . . . .   7
  4049. 4.1. Basic Requests Packet Format  . . . . . . . . . . .   8
  4050. 4.2. Data Types  . . . . . . . . . . . . . . . . . . . .   8
  4051. 4.3. Error Notification  . . . . . . . . . . . . . . . .  12
  4052. 4.4. Connection Establishment  . . . . . . . . . . . . .  13
  4053. 4.5. Event Flow Control  . . . . . . . . . . . . . . . .  18
  4054. 4.6. Encoding Negotiation  . . . . . . . . . . . . . . .  20
  4055. 4.7. Query the supported extension protocol list . . . .  21
  4056. 4.8. Setting IM Values . . . . . . . . . . . . . . . . .  22
  4057. 4.9. getting IM Values . . . . . . . . . . . . . . . . .  22
  4058. 4.10. Creating an IC . . . . . . . . . . . . . . . . . .  23
  4059. 4.11. Destroying the IC  . . . . . . . . . . . . . . . .  23
  4060. 4.12. Setting IC Values  . . . . . . . . . . . . . . . .  24
  4061. 4.13. Getting IC Values  . . . . . . . . . . . . . . . .  24
  4062. 4.14. Setting IC Focus . . . . . . . . . . . . . . . . .  25
  4063. 4.15. Unsetting IC Focus . . . . . . . . . . . . . . . .  25
  4064. 4.16. Filtering Events . . . . . . . . . . . . . . . . .  26
  4065. 4.17. Synchronizing with the IM Server . . . . . . . . .  29
  4066. 4.18. Sending a committed string . . . . . . . . . . . .  30
  4067. 4.19. Reset IC . . . . . . . . . . . . . . . . . . . . .  30
  4068. 4.20. Callbacks  . . . . . . . . . . . . . . . . . . . .  31
  4069. 4.20.1. Negotiating geometry . . . . . . . . . . . . . .  31
  4070. 4.20.2. Converting a string  . . . . . . . . . . . . . .  31
  4071. 4.20.3. Preedit Callbacks  . . . . . . . . . . . . . . .  32
  4072. 4.20.4. Preedit state notify . . . . . . . . . . . . . .  34
  4073. 4.20.5. Status Callbacks . . . . . . . . . . . . . . . .  35
  4074. 5. Acknowledgements  . . . . . . . . . . . . . . . . . .  36
  4075. 6. References  . . . . . . . . . . . . . . . . . . . . .  36
  4076. Appendix A - Common Extensions . . . . . . . . . . . . .  37
  4077. Appendix B - The list of transport specific IM
  4078. Server names registered  . . . . . . . . . . . . . . . .  40
  4079. Appendix C - Protocol number . . . . . . . . . . . . . .  42
  4080. Appendix D - Implementation Tips . . . . . . . . . . . .  44
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.