1 /* $Id: im.h,v 1.13 2002/01/27 11:33:06 ishisone Exp $ */
2 /*
3  * Copyright (c) 1994  Software Research Associates, Inc.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation for any purpose and without fee is hereby granted, provided
7  * that the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of Software Research Associates not be
10  * used in advertising or publicity pertaining to distribution of the
11  * software without specific, written prior permission.  Software Research
12  * Associates makes no representations about the suitability of this software
13  * for any purpose.  It is provided "as is" without express or implied
14  * warranty.
15  *
16  * Author:  Makoto Ishisone, Software Research Associates, Inc., Japan
17  */
18 
19 #ifndef _im_h
20 #define _im_h
21 
22 #include <stdio.h>
23 #include <X11/IntrinsicP.h>
24 #include <X11/StringDefs.h>
25 #include <X11/Xos.h>
26 #include <X11/Xfuncs.h>
27 
28 /* macros defined in the system header file cause problem... */
29 #undef major
30 #undef minor
31 
32 #define EXT_DEBUG_VAR	debug_IMProtocol
33 #include "DebugPrint.h"
34 #include "AsyncErr.h"
35 #include "FontBank.h"
36 #include "ConvCtrl.h"
37 
38 #include "imprtype.h"
39 #include "imbuf.h"
40 #include "imxport.h"
41 #include "imconst.h"
42 
43 /*
44  * Restrictions of attributes
45  */
46 
47 #define MIN_LINE_SPACING	2
48 #define MIN_AREA_WIDTH		16
49 #define MIN_AREA_HEIGHT		10
50 
51 /*
52  * IMDispatcher -- request dispatcher
53  */
54 
55 typedef int (*IMDispatcher)();
56 
57 
58 /*
59  * IMConnection
60  */
61 
62 typedef struct _im_connection_ {
63     /* protocol information */
64     int major_protocol_version;
65     int minor_protocol_version;
66 #ifdef XIM_BC
67     int has_length_bug;
68 #endif
69     int serial;				/* connection serial # (for debug) */
70     Widget proto_widget;		/* protocol handler widget */
71 
72     /* transport information */
73     IMTransport transport;
74 
75     int byte_order;			/* byte order of the client */
76 #define ORDER_UNKNOWN	0		/* order is yet unknown */
77 #define ORDER_BIG	1		/* big endian */
78 #define ORDER_LITTLE	2		/* little endian */
79 
80     /* communication buffer */
81     IMBuffer in_buf;			/* input buffer */
82     IMBuffer out_buf;			/* output buffer */
83 #define IM_INBUF(conn)	(&(conn)->in_buf)
84 #define IM_OUTBUF(conn)	(&(conn)->out_buf)
85 
86     IMDispatcher dispatcher;		/* request dispatch procedure */
87 
88     struct _im_im_ *im_list;		/* list of IMs on this connection */
89 
90 #ifdef notyet
91     /* authentication information */
92     IMAuth *server_auth;		/* server authentication data */
93     IMAuth *client_auth;		/* client authentication data */
94 #endif /* notyet */
95 
96     /* scheduler */
97     int schedule;			/* type of operation to be performed */
98 #define SCHED_WRITE	1		/* flush output buffer */
99 #define SCHED_CLOSE	2		/* close down connection gently */
100 #define SCHED_SHUTDOWN	4		/* force shut down */
101     struct _im_connection_ *queue_next;	/* output/close/shutdown queue */
102 
103     struct _im_connection_ *next;
104 } IMConnection;
105 
106 
107 /*
108  * IMConverter -- information on the conversion engine
109  */
110 typedef struct {
111     char **supported_locales;		/* list of supported locales */
112     int num_locales;
113     WidgetClass input_object_class;
114     WidgetClass display_object_class;
115 } IMConverter;
116 
117 
118 /*
119  * IMTriggerKey -- conversion trigger key specification
120  */
121 typedef struct {
122     KeySym keysym;
123     long modifiers;
124     long check_modifiers;
125 } IMTriggerKey;
126 
127 
128 /*
129  * IMExtensionMask -- bit mask of enabled extensions
130  */
131 typedef unsigned long IMExtensionMask;	/* holds up to 32 extensions */
132 
133 
134 /*
135  * IMIM -- per-IM structure
136  */
137 
138 typedef struct _im_im_ {
139     unsigned int id;			/* input-method ID */
140     IMConnection *connection;		/* connection this IM is on */
141     struct _im_im_ *next;
142     struct _im_im_ *hash_next;		/* for hash table */
143     IMConverter *converter;		/* conversion engine */
144     IMExtensionMask mask;		/* enabled extensions */
145     struct _im_ic_ *ic_list;		/* list of all ICs belonging to this IM */
146 } IMIM;
147 
148 
149 /*
150  * IMAttributes and IMPSAttributes -- IC attributes structure
151  */
152 
153 typedef struct {
154     unsigned long set_mask;		/* shows attrs that have been set */
155     unsigned long change_mask;		/* shows attrs that have changed */
156 #define ATTR_MASK_INPUT_STYLE	(1<<0)
157 #define ATTR_MASK_CLIENT	(1<<1)
158 #define ATTR_MASK_FOCUS		(1<<2)
159 #define ATTR_MASK_PREEDIT_STATE	(1<<3)
160 #define ATTR_MASK_RESET_STATE	(1<<4)
161     XIMStyle input_style;
162     Window client;			/* client window */
163     Window focus;			/* focus window */
164     unsigned long preedit_state;
165     unsigned long reset_state;
166 } IMCommonAttributes;
167 
168 typedef struct {
169     unsigned long set_mask;		/* shows attrs that have been set */
170     unsigned long change_mask;		/* shows attrs that have changed */
171 #define ATTR_MASK_AREA		(1<<0)
172 #define ATTR_MASK_FOREGROUND	(1<<1)
173 #define ATTR_MASK_BACKGROUND	(1<<2)
174 #define ATTR_MASK_COLORMAP	(1<<3)
175 #define ATTR_MASK_STD_COLORMAP	(1<<4)
176 #define ATTR_MASK_BG_PIXMAP	(1<<5)
177 #define ATTR_MASK_LINESPACE	(1<<6)
178 #define ATTR_MASK_CURSOR	(1<<7)
179 #define ATTR_MASK_AREA_NEEDED	(1<<8)
180 #define ATTR_MASK_FONT_SET	(1<<9)
181 #define ATTR_MASK_SPOT_LOCATION	(1<<10)
182     XRectangle area;
183     Pixel foreground, background;
184     Colormap colormap;
185     Atom std_colormap;
186     Pixmap bg_pixmap;
187     Position line_space;
188     Cursor cursor;
189     XRectangle area_needed;		/* width/height member are unused */
190     String font_set;
191     XPoint spot_location;		/* not used by status attr. */
192 } IMPSAttributes;
193 
194 
195 /*
196  * IMPendingEvent -- record of delayed processing event
197  */
198 
199 typedef struct _im_pending_event_ {
200     struct _im_ic_ *ic;
201     int synchronous;
202     XEvent event;
203     struct _im_pending_event_ *next;
204 } IMPendingEvent;
205 
206 
207 /*
208  * IMWindowProfile -- information about window
209  */
210 
211 typedef struct {
212     Dimension width;
213     Dimension height;
214     Window root;
215 } IMWindowProfile;
216 
217 
218 /*
219  * IMIC -- per-IC structure
220  */
221 
222 typedef struct _im_ic_ {
223     unsigned int id;			/* input-context ID */
224     IMIM *im;				/* IM this IC belongs to */
225     Widget conversion;			/* conversion widget attached
226 					 * to this IC */
227     struct _im_ic_ *next;
228     struct _im_ic_ *hash_next;		/* for hash list */
229     int state;				/* current IC state */
230 #define IC_SYNCING	0x01		/* waiting for SYNC_REPLY message */
231 #define IC_CONVERTING	0x02		/* in conversion mode */
232 #define IC_RESETTING	0x04		/* in resetting */
233 #define IC_FORWARDING	0x08		/* in forward event */
234 #define IC_IN_PREEDIT	0x10		/* in preedit (on-the-spot only) */
235 #define IC_IN_STATUS	0x20		/* in status (on-the-spot only) */
236 #define IC_DESTROYING	0x40		/* in process of IC destruction */
237     IMPendingEvent *pending_events;	/* pending events */
238     int style;				/* input style */
239 #define IMSTYLE_SEPARATE	0	/* root window style */
240 #define IMSTYLE_OVER_THE_SPOT	1	/* over-the-spot style */
241 #define IMSTYLE_OFF_THE_SPOT	2	/* off-the-spot style */
242 #define IMSTYLE_ON_THE_SPOT	3	/* on-the-spot style */
243     IMCommonAttributes common_attr;	/* general attributes */
244     IMPSAttributes preedit_attr;	/* preedit specific attributes */
245     IMPSAttributes status_attr;		/* status specific attributes */
246     IMWindowProfile client_profile;	/* client widow profile */
247     IMWindowProfile focus_profile;	/* focus window profile */
248     XFontStruct **fonts;
249     int num_fonts;
250     XFontStruct **status_fonts;
251     int num_status_fonts;
252 } IMIC;
253 
254 
255 /*
256  * IM and IC hash table size
257  */
258 
259 #define IM_HASH_SIZE	32
260 #define IC_HASH_SIZE	128
261 
262 
263 /*
264  * Public function declarations
265  */
266 
267 #include "imfuncs.h"
268 
269 #endif /* _im_h */
270