aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/XimintP.h
blob: 89b7c214f08c0375b0b677c947ad0435de51e241 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/*
 * Copyright 1991, 1992 Sun Microsystems, Inc.  All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */
/******************************************************************

           Copyright 1992, 1993, 1994 by FUJITSU LIMITED
           Copyright 1993, 1994       by Sony Corporation

Permission to use, copy, modify, distribute, and sell this software and
its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of FUJITSU LIMITED and Sony Corporation
not be used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.  FUJITSU LIMITED and
Sony Corporation makes no representations about the suitability of this
software for any purpose.  It is provided "as is" without express or
implied warranty.

FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL FUJITSU LIMITED OR SONY CORPORATION BE LIABLE
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
USE OR PERFORMANCE OF THIS SOFTWARE.

  Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
          Takashi Fujiwara     FUJITSU LIMITED
                                 fujiwara@a80.tech.yk.fujitsu.co.jp
	  Makoto Wakamatsu     Sony Corporation
                                 makoto@sm.sony.co.jp
	  Hiroyuki Miyamoto    Digital Equipment Corporation
                                 miyamoto@jrd.dec.com

******************************************************************/

#ifndef _XIMINTP_H
#define _XIMINTP_H

#include "XimProto.h"
#include "XlcPublic.h"

/*
 * for protocol layer callback function
 */
typedef Bool (*XimProtoIntrProc)(
	Xim, INT16, XPointer, XPointer
);
typedef struct _XimProtoIntrRec {
    XimProtoIntrProc		 func;
    CARD16			 major_code;
    CARD16			 minor_code;
    XPointer			 call_data;
    struct _XimProtoIntrRec	*next;
} XimProtoIntrRec;

/*
 * for transport layer methods
 */
typedef Bool (*XimTransConnectProc)(
	 Xim
);
typedef Bool (*XimTransShutdownProc)(
	 Xim
);
typedef Bool (*XimTransWriteProc)(
	 Xim, INT16, XPointer
);
typedef Bool (*XimTransReadProc)(
	 Xim, XPointer, int, int *
);
typedef void (*XimTransFlushProc)(
	 Xim
);
typedef Bool (*XimTransRegDispatcher)(
	 Xim, Bool (*)(Xim, INT16, XPointer, XPointer), XPointer
);
typedef Bool (*XimTransCallDispatcher)(
	 Xim, INT16, XPointer
);

/*
 * private part of IM
 */
typedef struct _XimProtoPrivateRec {
    /* The first fields are identical with XimCommonPrivateRec. */
    XlcConv			 ctom_conv;
    XlcConv			 ctow_conv;
    XlcConv			 ctoutf8_conv;
    XlcConv			 cstomb_conv;
    XlcConv			 cstowc_conv;
    XlcConv			 cstoutf8_conv;
    XlcConv			 ucstoc_conv;
    XlcConv			 ucstoutf8_conv;

    Window			 im_window;
    XIMID			 imid;
    CARD16			 unused;
    XIMStyles			*default_styles;
    CARD32			*im_onkeylist;
    CARD32			*im_offkeylist;
    BITMASK32			 flag;

    BITMASK32			 registed_filter_event;
    EVENTMASK			 forward_event_mask;
    EVENTMASK			 synchronous_event_mask;

    XimProtoIntrRec		*intrproto;
    XIMResourceList		 im_inner_resources;
    unsigned int		 im_num_inner_resources;
    XIMResourceList		 ic_inner_resources;
    unsigned int		 ic_num_inner_resources;
    char			*hold_data;
    int				 hold_data_len;
    char			*locale_name;
    CARD16			 protocol_major_version;
    CARD16			 protocol_minor_version;
    XrmQuark			*saved_imvalues;
    int				 num_saved_imvalues;

    /*
     * transport specific
     */
    XimTransConnectProc		 connect;
    XimTransShutdownProc	 shutdown;
    XimTransWriteProc		 write;
    XimTransReadProc		 read;
    XimTransFlushProc		 flush;
    XimTransRegDispatcher	 register_dispatcher;
    XimTransCallDispatcher	 call_dispatcher;
    XPointer			 spec;
} XimProtoPrivateRec;

/*
 * bit mask for the flag of XIMPrivateRec
 */
#define SERVER_CONNECTED	(1L)
#define	DYNAMIC_EVENT_FLOW	(1L << 1)
#define	USE_AUTHORIZATION_FUNC	(1L << 2)
#ifdef XIM_CONNECTABLE
#define DELAYBINDABLE		(1L << 3)
#define RECONNECTABLE		(1L << 4)
#endif /* XIM_CONNECTABLE */

/*
 * macro for the flag of XIMPrivateRec
 */
#define IS_SERVER_CONNECTED(im) \
		((((Xim)im))->private.proto.flag & SERVER_CONNECTED)
#define MARK_SERVER_CONNECTED(im) \
		((((Xim)im))->private.proto.flag |= SERVER_CONNECTED)
#define UNMARK_SERVER_CONNECTED(im) \
		((((Xim)im))->private.proto.flag &= ~SERVER_CONNECTED)

#define	IS_DYNAMIC_EVENT_FLOW(im) \
		(((Xim)im)->private.proto.flag & DYNAMIC_EVENT_FLOW)
#define	MARK_DYNAMIC_EVENT_FLOW(im) \
		(((Xim)im)->private.proto.flag |= DYNAMIC_EVENT_FLOW)

#define	IS_USE_AUTHORIZATION_FUNC(im) \
		(((Xim)im)->private.proto.flag & USE_AUTHORIZATION_FUNC)
#define	MARK_USE_AUTHORIZATION_FUNC(im) \
		(((Xim)im)->private.proto.flag |= USE_AUTHORIZATION_FUNC)

#ifdef XIM_CONNECTABLE
#define IS_DELAYBINDABLE(im) \
		(((Xim)im)->private.proto.flag & DELAYBINDABLE)
#define MARK_DELAYBINDABLE(im) \
		(((Xim)im)->private.proto.flag |= DELAYBINDABLE)

#define IS_RECONNECTABLE(im) \
		(((Xim)im)->private.proto.flag & RECONNECTABLE)
#define MARK_RECONNECTABLE(im) \
		(((Xim)im)->private.proto.flag |= RECONNECTABLE)

#define IS_CONNECTABLE(im) \
    (((Xim)im)->private.proto.flag & (DELAYBINDABLE|RECONNECTABLE))
#define UNMAKE_CONNECTABLE(im) \
    (((Xim)im)->private.proto.flag &= ~(DELAYBINDABLE|RECONNECTABLE))
#endif /* XIM_CONNECTABLE */

/*
 * bit mask for the register_filter_event of XIMPrivateRec/XICPrivateRec
 */
#define KEYPRESS_MASK		(1L)
#define KEYRELEASE_MASK		(1L << 1)
#define DESTROYNOTIFY_MASK	(1L << 2)

typedef struct _XimCommitInfoRec {
    struct _XimCommitInfoRec	*next;
    char			*string;
    int				 string_len;
    KeySym			*keysym;
    int				 keysym_len;
} XimCommitInfoRec, *XimCommitInfo;

typedef struct _XimPendingCallback {
    int				 major_opcode;
    Xim				 im;
    Xic				 ic;
    char			*proto;
    int				 proto_len;
    struct _XimPendingCallback	*next;
} XimPendingCallbackRec, *XimPendingCallback;


/*
 * private part of IC
 */
typedef struct _XicProtoPrivateRec {
    XICID	         icid;			/* ICID		*/
    CARD16		 dmy;
    BITMASK32		 flag;			/* Input Mode	*/

    BITMASK32		 registed_filter_event; /* registed filter mask */
    EVENTMASK		 forward_event_mask;	/* forward event mask */
    EVENTMASK		 synchronous_event_mask;/* sync event mask */
    EVENTMASK		 filter_event_mask;	/* negrect event mask */
    EVENTMASK		 intercept_event_mask;	/* deselect event mask */
    EVENTMASK		 select_event_mask;	/* select event mask */

    char		*preedit_font;		/* Base font name list */
    int			 preedit_font_length;	/* length of base font name */
    char		*status_font;		/* Base font name list */
    int			 status_font_length;	/* length of base font name */

    XimCommitInfo	 commit_info;
    XIMResourceList	 ic_resources;
    unsigned int	 ic_num_resources;
    XIMResourceList	 ic_inner_resources;
    unsigned int	 ic_num_inner_resources;
    XrmQuark		*saved_icvalues;
    int			 num_saved_icvalues;
    XimPendingCallback	 pend_cb_que;
    Bool		 waitCallback;
} XicProtoPrivateRec ;

/*
 * bit mask for the flag of XICPrivateRec
 */
#define IC_CONNECTED		(1L)
#define FABLICATED		(1L << 1)
#define	NEED_SYNC_REPLY		(1L << 2)
#define FOCUSED			(1L << 3)

/*
 * macro for the flag of XICPrivateRec
 */
#define	IS_IC_CONNECTED(ic) \
		(((Xic)ic)->private.proto.flag & IC_CONNECTED)
#define	MARK_IC_CONNECTED(ic) \
		(((Xic)ic)->private.proto.flag |= IC_CONNECTED)
#define	UNMARK_IC_CONNECTED(ic) \
		(((Xic)ic)->private.proto.flag &= ~IC_CONNECTED)

#define IS_FABLICATED(ic) \
		(((Xic)ic)->private.proto.flag & FABLICATED)
#define MARK_FABLICATED(ic) \
		(((Xic)ic)->private.proto.flag |= FABLICATED)
#define UNMARK_FABLICATED(ic) \
		(((Xic)ic)->private.proto.flag &= ~FABLICATED)

#define	IS_NEED_SYNC_REPLY(ic) \
		(((Xic)ic)->private.proto.flag & NEED_SYNC_REPLY)
#define	MARK_NEED_SYNC_REPLY(ic) \
		(((Xic)ic)->private.proto.flag |= NEED_SYNC_REPLY)
#define	UNMARK_NEED_SYNC_REPLY(ic) \
		(((Xic)ic)->private.proto.flag &= ~NEED_SYNC_REPLY)

#define IS_FOCUSED(ic) \
		(((Xic)ic)->private.proto.flag & FOCUSED)
#define MARK_FOCUSED(ic) \
		(((Xic)ic)->private.proto.flag |= FOCUSED)
#define UNMARK_FOCUSED(ic) \
		(((Xic)ic)->private.proto.flag &= ~FOCUSED)

/*
 * macro for the filter_event_mask of XICPrivateRec
 */
#define	IS_NEGLECT_EVENT(ic, mask) \
		(((Xic)ic)->private.proto.filter_event_mask & (mask))

/*
 * macro for the forward_event_mask of XICPrivateRec
 */
#define	IS_FORWARD_EVENT(ic, mask) \
		(((Xic)ic)->private.proto.forward_event_mask & (mask))

/*
 * macro for the synchronous_event_mask of XICPrivateRec
 */
#define	IS_SYNCHRONOUS_EVENT(ic, mask) \
   ((((Xic)ic)->private.proto.synchronous_event_mask & (mask)) ? True: False)

#define XIM_MAXIMNAMELEN 64
#define XIM_MAXLCNAMELEN 64

#endif /* _XIMINTP_H */