1
/******************************************************************
3
Copyright 1994, 1995 by Sun Microsystems, Inc.
4
Copyright 1993, 1994 by Hewlett-Packard Company
6
Permission to use, copy, modify, distribute, and sell this software
7
and its documentation for any purpose is hereby granted without fee,
8
provided that the above copyright notice appear in all copies and
9
that both that copyright notice and this permission notice appear
10
in supporting documentation, and that the name of Sun Microsystems, Inc.
11
and Hewlett-Packard not be used in advertising or publicity pertaining to
12
distribution of the software without specific, written prior permission.
13
Sun Microsystems, Inc. and Hewlett-Packard make no representations about
14
the suitability of this software for any purpose. It is provided "as is"
15
without express or implied warranty.
17
SUN MICROSYSTEMS INC. AND HEWLETT-PACKARD COMPANY DISCLAIMS ALL
18
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
20
SUN MICROSYSTEMS, INC. AND HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY
21
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
22
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
23
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
24
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26
Author: Hidetoshi Tajima(tajima@Eng.Sun.COM) Sun Microsystems, Inc.
28
This version tidied and debugged by Steve Underwood May 1999
30
******************************************************************/
38
Xi18nClient *_Xi18nFindClient (Xi18n, CARD16);
41
_Xi18nNeedSwap (Xi18n i18n_core, CARD16 connect_id)
43
CARD8 im_byteOrder = i18n_core->address.im_byteOrder;
44
Xi18nClient *client = _Xi18nFindClient (i18n_core, connect_id);
46
return (client->byte_order != im_byteOrder);
49
Xi18nClient *_Xi18nNewClient(Xi18n i18n_core)
51
static CARD16 connect_id = 0;
55
if (i18n_core->address.free_clients)
57
client = i18n_core->address.free_clients;
58
i18n_core->address.free_clients = client->next;
59
new_connect_id = client->connect_id;
63
client = (Xi18nClient *) malloc (sizeof (Xi18nClient));
64
new_connect_id = ++connect_id;
67
memset (client, 0, sizeof (Xi18nClient));
68
client->connect_id = new_connect_id;
69
client->pending = (XIMPending *) NULL;
71
client->byte_order = '?'; /* initial value */
72
memset (&client->pending, 0, sizeof (XIMPending *));
73
client->property_offset = 0;
74
client->next = i18n_core->address.clients;
75
i18n_core->address.clients = client;
77
return (Xi18nClient *) client;
80
Xi18nClient *_Xi18nFindClient (Xi18n i18n_core, CARD16 connect_id)
82
Xi18nClient *client = i18n_core->address.clients;
86
if (client->connect_id == connect_id)
89
client = client->next;
95
void _Xi18nDeleteClient (Xi18n i18n_core, CARD16 connect_id)
97
Xi18nClient *target = _Xi18nFindClient (i18n_core, connect_id);
101
for (ccp = i18n_core->address.clients, ccp0 = NULL;
103
ccp0 = ccp, ccp = ccp->next)
108
i18n_core->address.clients = ccp->next;
110
ccp0->next = ccp->next;
112
/* put it back to free list */
113
target->next = i18n_core->address.free_clients;
114
i18n_core->address.free_clients = target;
122
void _Xi18nSendMessage (XIMS ims,
129
Xi18n i18n_core = ims->protocol;
131
extern XimFrameRec packet_header_fr[];
132
unsigned char *reply_hdr = NULL;
134
unsigned char *reply = NULL;
135
unsigned char *replyp;
137
long p_len = length/4;
139
fm = FrameMgrInit (packet_header_fr,
141
_Xi18nNeedSwap (i18n_core, connect_id));
143
header_size = FrameMgrGetTotalSize (fm);
144
reply_hdr = (unsigned char *) malloc (header_size);
145
if (reply_hdr == NULL)
147
_Xi18nSendMessage (ims, connect_id, XIM_ERROR, 0, 0, 0);
151
FrameMgrSetBuffer (fm, reply_hdr);
154
FrameMgrPutToken (fm, major_opcode);
155
FrameMgrPutToken (fm, minor_opcode);
156
FrameMgrPutToken (fm, p_len);
158
reply_length = header_size + length;
159
reply = (unsigned char *) malloc (reply_length);
161
memmove (reply, reply_hdr, header_size);
162
replyp += header_size;
163
memmove (replyp, data, length);
165
i18n_core->methods.send (ims, connect_id, reply, reply_length);
172
void _Xi18nSendTriggerKey (XIMS ims, CARD16 connect_id)
174
Xi18n i18n_core = ims->protocol;
176
extern XimFrameRec register_triggerkeys_fr[];
177
XIMTriggerKey *on_keys = i18n_core->address.on_keys.keylist;
178
XIMTriggerKey *off_keys = i18n_core->address.off_keys.keylist;
179
int on_key_num = i18n_core->address.on_keys.count_keys;
180
int off_key_num = i18n_core->address.off_keys.count_keys;
181
unsigned char *reply = NULL;
182
register int i, total_size;
185
if (on_key_num == 0 && off_key_num == 0)
189
fm = FrameMgrInit (register_triggerkeys_fr,
191
_Xi18nNeedSwap (i18n_core, connect_id));
193
/* set iteration count for on-keys list */
194
FrameMgrSetIterCount (fm, on_key_num);
195
/* set iteration count for off-keys list */
196
FrameMgrSetIterCount (fm, off_key_num);
199
total_size = FrameMgrGetTotalSize (fm);
201
reply = (unsigned char *) malloc (total_size);
205
memset (reply, 0, total_size);
206
FrameMgrSetBuffer (fm, reply);
208
/* Right now XIM_OPEN_REPLY hasn't been sent to this new client, so
209
the input-method-id is still invalid, and should be set to zero...
210
Reter to $(XC)/lib/X11/imDefLkup.c:_XimRegisterTriggerKeysCallback
213
FrameMgrPutToken (fm, im_id); /* input-method-id */
214
for (i = 0; i < on_key_num; i++)
216
FrameMgrPutToken (fm, on_keys[i].keysym);
217
FrameMgrPutToken (fm, on_keys[i].modifier);
218
FrameMgrPutToken (fm, on_keys[i].modifier_mask);
221
for (i = 0; i < off_key_num; i++)
223
FrameMgrPutToken (fm, off_keys[i].keysym);
224
FrameMgrPutToken (fm, off_keys[i].modifier);
225
FrameMgrPutToken (fm, off_keys[i].modifier_mask);
228
_Xi18nSendMessage (ims,
230
XIM_REGISTER_TRIGGERKEYS,
238
void _Xi18nSetEventMask (XIMS ims,
245
Xi18n i18n_core = ims->protocol;
247
extern XimFrameRec set_event_mask_fr[];
248
unsigned char *reply = NULL;
249
register int total_size;
251
fm = FrameMgrInit (set_event_mask_fr,
253
_Xi18nNeedSwap (i18n_core, connect_id));
255
total_size = FrameMgrGetTotalSize (fm);
256
reply = (unsigned char *) malloc (total_size);
260
memset (reply, 0, total_size);
261
FrameMgrSetBuffer (fm, reply);
263
FrameMgrPutToken (fm, im_id); /* input-method-id */
264
FrameMgrPutToken (fm, ic_id); /* input-context-id */
265
FrameMgrPutToken (fm, forward_mask);
266
FrameMgrPutToken (fm, sync_mask);
268
_Xi18nSendMessage (ims,