Back to index

im-sdk  12.3.91
Xi18n.h
Go to the documentation of this file.
00001 /******************************************************************
00002  
00003          Copyright 1994, 1995 by Sun Microsystems, Inc.
00004          Copyright 1993, 1994 by Hewlett-Packard Company
00005  
00006 Permission to use, copy, modify, distribute, and sell this software
00007 and its documentation for any purpose is hereby granted without fee,
00008 provided that the above copyright notice appear in all copies and
00009 that both that copyright notice and this permission notice appear
00010 in supporting documentation, and that the name of Sun Microsystems, Inc.
00011 and Hewlett-Packard not be used in advertising or publicity pertaining to
00012 distribution of the software without specific, written prior permission.
00013 Sun Microsystems, Inc. and Hewlett-Packard make no representations about
00014 the suitability of this software for any purpose.  It is provided "as is"
00015 without express or implied warranty.
00016  
00017 SUN MICROSYSTEMS INC. AND HEWLETT-PACKARD COMPANY DISCLAIMS ALL
00018 WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
00019 WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
00020 SUN MICROSYSTEMS, INC. AND HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY
00021 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
00022 RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
00023 CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
00024 IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00025  
00026   Author: Hidetoshi Tajima(tajima@Eng.Sun.COM) Sun Microsystems, Inc.
00027  
00028 ******************************************************************/
00029 #ifndef _Xi18n_h
00030 #define _Xi18n_h
00031 #include <X11/Xlib.h>
00032 #include <X11/Xfuncs.h>
00033 #include <X11/Xos.h>
00034 #include "XimProto.h"
00035 
00036 /*
00037  * Minor Protocol Number for Extension Protocol 
00038  */
00039 #define XIM_EXTENSION              128
00040 #define XIM_EXT_SET_EVENT_MASK                   (0x30)
00041 #define       XIM_EXT_FORWARD_KEYEVENT           (0x32)
00042 #define       XIM_EXT_MOVE                       (0x33)
00043 #define COMMON_EXTENSIONS_NUM   3
00044 
00045 #include <stdlib.h>
00046 #include "X11R6IMProtoData.h"
00047 
00048 /* XI18N Valid Attribute Name Definition */
00049 #define ExtForwardKeyEvent  "extForwardKeyEvent"
00050 #define ExtMove                    "extMove"
00051 #define ExtSetEventMask            "extSetEventMask"
00052 
00053 /*
00054  * Padding macro
00055  */
00056 #define       IMPAD(length) ((4 - ((length) % 4)) % 4)
00057 
00058 /*
00059  * Target Atom for Transport Connection
00060  */
00061 #define LOCALES             "LOCALES"
00062 #define TRANSPORT    "TRANSPORT"
00063 
00064 #define I18N_OPEN    0
00065 #define I18N_SET     1
00066 #define I18N_GET     2
00067 
00068 typedef struct {
00069     char *transportname;
00070     int   namelen;
00071     Bool (*checkAddr)();
00072 } TransportSW;
00073 
00074 typedef struct _XIMPending {
00075     unsigned char *p;
00076     struct _XIMPending *next;
00077 } XIMPending;
00078 
00079 typedef struct _XimProtoHdr {
00080     CARD8     major_opcode;
00081     CARD8     minor_opcode;
00082     CARD16    length;
00083 } XimProtoHdr;
00084 
00085 typedef struct {
00086   CARD16      attribute_id;
00087   CARD16      type;
00088   CARD16      length;
00089   const char *name;
00090 } XIMAttr;
00091 
00092 typedef struct {
00093     CARD16    attribute_id;
00094     CARD16    type;
00095     CARD16    length;
00096     char      *name;
00097 } XICAttr;
00098 
00099 typedef struct {
00100     CARD16    major_opcode;
00101     CARD16    minor_opcode;
00102     CARD16    length;
00103     char      *name;
00104 } XIMExt;
00105 
00106 typedef struct _Xi18nClient {
00107     int              connect_id;
00108     CARD8     byte_order;
00109                   /*
00110                      '?': initial value
00111                      'B': for Big-Endian
00112                      'l': for little-endian
00113                    */
00114     int              sync;
00115     XIMPending  *pending;
00116   
00117     unsigned char *pending_commit;
00118     int pending_commit_size;
00119 
00120     void *trans_rec;        /* contains transport specific data  */
00121     struct _Xi18nClient *next;
00122 } Xi18nClient;
00123 
00124 typedef struct _Xi18nCore *Xi18n;
00125 
00126 #define DEFAULT_FILTER_MASK (KeyPressMask)
00127 
00128 /* Xi18nAddressRec structure */
00129 typedef struct _Xi18nAddressRec {
00130     Display   *dpy;
00131     CARD8     im_byteOrder; /* byte order 'B' or 'l' */
00132     /* IM Values */
00133     long      imvalue_mask;
00134     Window    im_window;    /* IMServerWindow */
00135     char      *im_name;     /* IMServerName */
00136     char      *im_locale;   /* IMLocale */
00137     char      *im_addr;     /* IMServerTransport */
00138     XIMStyles input_styles; /* IMInputStyles */
00139     XIMTriggerKeys on_keys; /* IMOnKeysList */
00140     XIMTriggerKeys off_keys;       /* IMOffKeysList */
00141     XIMEncodings encoding_list; /* IMEncodingList */
00142 #if IM_PROTO_HANDLER
00143     X11R6IMProtoHandler *improto;  /* IMProtocolHander */
00144 #endif
00145     long      filterevent_mask; /* IMFilterEventMask */
00146     /* XIM_SERVERS target Atoms */
00147     Atom      selection;
00148     Atom        selection_bwc;
00149     Atom      Localename;
00150     Atom      Transportname;
00151     /* XIM/XIC Attr */
00152     int              im_attr_num;
00153     XIMAttr   *xim_attr;
00154     int              ic_attr_num;
00155     XICAttr   *xic_attr;
00156     CARD16    preeditAttr_id;
00157     CARD16    statusAttr_id;
00158     CARD16    separatorAttr_id;
00159     /* XIMExtension List */
00160     int              ext_num;
00161     XIMExt    extension[COMMON_EXTENSIONS_NUM];
00162     /* transport specific connection address */
00163     void      *connect_addr;
00164               /* actual data is defined:
00165                  XSpecRec in Xi18nX.h for X-based connection.
00166                  TransSpecRec in Xi18nTr.h for Socket-based connection.
00167                */
00168     /* clients table */
00169     Xi18nClient *clients;
00170     Xi18nClient *free_clients;
00171 } Xi18nAddressRec;
00172 
00173 typedef struct _Xi18nMethodsRec {
00174     Bool (*begin)(
00175                 XIMS
00176                 );
00177     Bool (*end)(
00178               XIMS
00179               );
00180     Bool (*send)(
00181                XIMS, CARD16, unsigned char*, long
00182                );
00183     Bool (*wait)(
00184                XIMS, CARD16, CARD8, CARD8
00185                );
00186     Bool (*disconnect)(
00187                      XIMS, CARD16
00188                      );
00189 } Xi18nMethodsRec;
00190 
00191 typedef struct _Xi18nCore {
00192     Xi18nAddressRec address;
00193     Xi18nMethodsRec methods;
00194 } Xi18nCore;
00195 
00196 #define CALL_PROTO_HANDLER \
00197     if (i18n_core->address.improto->proc) \
00198        if (!(i18n_core->address.improto->proc(ims, \
00199                             call_data, \
00200                             i18n_core->address.improto->client_data))) \
00201               return;
00202 
00203 #endif /* _Xi18n_h */