annotate lib/imlib/imrequest.c @ 21:7a454839a6de default tip

add some missing header files
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 09 Mar 2010 19:02:39 +0900
parents 92745d501b9a
children 1f9e9cb00c6c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1 #ifndef lint
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
2 static char *rcsid = "$Id: imrequest.c,v 1.19 2002/01/27 11:33:37 ishisone Exp $";
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
3 #endif
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
4 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
5 * Copyright (c) 1994 Software Research Associates, Inc.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
6 *
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
7 * Permission to use, copy, modify, and distribute this software and its
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
8 * documentation for any purpose and without fee is hereby granted, provided
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
9 * that the above copyright notice appear in all copies and that both that
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
10 * copyright notice and this permission notice appear in supporting
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
11 * documentation, and that the name of Software Research Associates not be
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
12 * used in advertising or publicity pertaining to distribution of the
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
13 * software without specific, written prior permission. Software Research
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
14 * Associates makes no representations about the suitability of this software
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
15 * for any purpose. It is provided "as is" without express or implied
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
16 * warranty.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
17 *
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
18 * Author: Makoto Ishisone, Software Research Associates, Inc., Japan
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
19 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
20
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
21 /* in order to include xEvent definition */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
22 #define NEED_EVENTS
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
23 #include <X11/Xproto.h>
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
24
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
25 #include "im.h"
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
26 #include "imreq.h"
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
27
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
28 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
29 * Request handle functions
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
30 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
31 static void ximDisconnectProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
32 static void ximErrorProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
33 static void ximOpenProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
34 static void ximCloseProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
35 static void ximTriggerNotifyProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
36 static void ximEncodingNegotiationProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
37 static void ximQueryExtensionProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
38 static void ximSetIMValuesProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
39 static void ximGetIMValuesProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
40 static void ximCreateICProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
41 static void ximDestroyICProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
42 static void ximSetICValuesProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
43 static void ximGetICValuesProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
44 static void ximSetICFocusProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
45 static void ximUnsetICFocusProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
46 static void ximForwardEventProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
47 static void ximExtForwardKeyeventProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
48 static void ximSyncProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
49 static void ximSyncReplyProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
50 static void ximResetICProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
51 static void ximExtMoveProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
52
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
53 static void ximAlreadyConnectedProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
54 static void ximShouldNotBeSentProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
55 static void ximAuthPhaseProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
56 static void ximNopProc _Pt_((IMConnection *, int, int, int));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
57
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
58 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
59 * Core request table
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
60 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
61 static IMRequest coreRequestTbl[] = {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
62 { "CONNECT", XIM_CONNECT, 0, ximAlreadyConnectedProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
63 { "CONNECT-REPLY", XIM_CONNECT_REPLY, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
64 { "DISCONNECT", XIM_DISCONNECT, 0, ximDisconnectProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
65 { "DISCONNECT-REPLY", XIM_DISCONNECT_REPLY, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
66 { "AUTH-REQUIRED", XIM_AUTH_REQUIRED, 0, ximAuthPhaseProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
67 { "AUTH-REPLY", XIM_AUTH_REPLY, 0, ximAuthPhaseProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
68 { "AUTH-NEXT", XIM_AUTH_NEXT, 0, ximAuthPhaseProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
69 { "AUTH-SETUP", XIM_AUTH_SETUP, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
70 { "AUTH-NG", XIM_AUTH_NG, 0, ximAuthPhaseProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
71 { "ERROR", XIM_ERROR, 0, ximErrorProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
72 { "OPEN", XIM_OPEN, 0, ximOpenProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
73 { "OPEN-REPLY", XIM_OPEN_REPLY, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
74 { "CLOSE", XIM_CLOSE, 0, ximCloseProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
75 { "CLOSE-REPLY", XIM_CLOSE_REPLY, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
76 { "SET-EVENT-MASK", XIM_SET_EVENT_MASK, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
77 { "REGISTER-TRIGGERKEYS", XIM_REGISTER_TRIGGERKEYS, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
78 ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
79 { "TRIGGER-NOTIFY", XIM_TRIGGER_NOTIFY, 0, ximTriggerNotifyProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
80 { "TRIGGER-NOTIFY-REPLY", XIM_TRIGGER_NOTIFY_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
81 ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
82 { "ENCODING-NEGOTIATION", XIM_ENCODING_NEGOTIATION, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
83 ximEncodingNegotiationProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
84 { "ENCODING-NEGOTIATION-REPLY", XIM_ENCODING_NEGOTIATION_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
85 ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
86 { "QUERY-EXTENSION", XIM_QUERY_EXTENSION, 0, ximQueryExtensionProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
87 { "QUERY-EXTENSION-REPLY", XIM_QUERY_EXTENSION_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
88 ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
89 { "SET-IM-VALUES", XIM_SET_IM_VALUES, 0, ximSetIMValuesProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
90 { "SET-IM-VALUES-REPLY", XIM_SET_IM_VALUES_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
91 ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
92 { "GET-IM-VALUES", XIM_GET_IM_VALUES, 0, ximGetIMValuesProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
93 { "GET-IM-VALUES-REPLY", XIM_GET_IM_VALUES_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
94 ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
95 { "CREATE-IC", XIM_CREATE_IC, 0, ximCreateICProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
96 { "CREATE-IC-REPLY", XIM_CREATE_IC_REPLY, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
97 { "DESTROY-IC", XIM_DESTROY_IC, 0, ximDestroyICProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
98 { "DESTROY-IC-REPLY", XIM_DESTROY_IC_REPLY, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
99 { "SET-IC-VALUES", XIM_SET_IC_VALUES, 0, ximSetICValuesProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
100 { "SET-IC-VALUES-REPLY", XIM_SET_IC_VALUES_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
101 ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
102 { "GET-IC-VALUES", XIM_GET_IC_VALUES, 0, ximGetICValuesProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
103 { "GET-IC-VALUES-REPLY", XIM_GET_IC_VALUES_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
104 ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
105 { "SET-IC-FOCUS", XIM_SET_IC_FOCUS, 0, ximSetICFocusProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
106 { "UNSET-IC-FOCUS", XIM_UNSET_IC_FOCUS, 0, ximUnsetICFocusProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
107 { "FORWARD-EVENT", XIM_FORWARD_EVENT, 0, ximForwardEventProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
108 { "SYNC", XIM_SYNC, 0, ximSyncProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
109 { "SYNC-REPLY", XIM_SYNC_REPLY, 0, ximSyncReplyProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
110 { "COMMIT", XIM_COMMIT, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
111 { "RESET-IC", XIM_RESET_IC, 0, ximResetICProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
112 { "RESET-IC-REPLY", XIM_RESET_IC_REPLY, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
113 { "GEOMETRY", XIM_GEOMETRY, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
114 { "STR-CONVERSION", XIM_STR_CONVERSION, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
115 { "STR-CONVERSION-REPLY", XIM_STR_CONVERSION_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
116 ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
117 { "PREEDIT-START", XIM_PREEDIT_START, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
118 { "PREEDIT-START-REPLY", XIM_PREEDIT_START_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
119 ximNopProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
120 { "PREEDIT-DRAW", XIM_PREEDIT_DRAW, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
121 { "PREEDIT-CARET", XIM_PREEDIT_CARET, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
122 { "PREEDIT-CARET-REPLY", XIM_PREEDIT_CARET_REPLY, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
123 ximNopProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
124 { "PREEDIT-DONE", XIM_PREEDIT_DONE, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
125 { "PREEDITSTATE", XIM_PREEDITSTATE, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
126 { "STATUS-START", XIM_STATUS_START, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
127 { "STATUS-DRAW", XIM_STATUS_DRAW, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
128 { "STATUS-DONE", XIM_STATUS_DONE, 0, ximShouldNotBeSentProc },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
129 { NULL, 0, 0, NULL },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
130 };
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
131
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
132 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
133 * Extension request table
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
134 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
135 static IMRequest extRequestTbl[] = {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
136 { "XIM_EXT_SET_EVENT_MASK", XIM_EXT_SET_EVENT_MASK, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
137 ximShouldNotBeSentProc, XIM_EXT_SET_EVENT_MASK_MASK },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
138 { "XIM_EXT_FORWARD_KEYEVENT", XIM_EXT_FORWARD_KEYEVENT, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
139 ximExtForwardKeyeventProc, XIM_EXT_FORWARD_KEYEVENT_MASK },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
140 { "XIM_EXT_MOVE", XIM_EXT_MOVE, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
141 ximExtMoveProc, XIM_EXT_MOVE_MASK },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
142 { NULL, 0, 0, NULL },
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
143 };
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
144
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
146 * Request dispatch table (global)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
147 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148 IMRequest *IMMainDispatchTable[256];
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
149
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
150
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
151 static void compileTbl _Pt_((IMRequest *req));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
152 static char *ecode2str _Pt_((int code));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
153 static void putTriggerkeyList _Pt_((IMIM *imp));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
154 static int findCtext _Pt_((IMConnection *conn, int arglen));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
155 static IMRequest *getExtension _Pt_((char *name));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
156 static void putExtension _Pt_((IMConnection *conn, IMRequest *req));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
157 static void swapData _Pt_((char *data, char *format));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
158 static int getEvent _Pt_((IMConnection *conn, unsigned int serial,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
159 int offset, XEvent *ev));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
160 static void postponeEvent _Pt_((IMIC *icp, int synchronous, XEvent *ev));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
161 static void handleForwardedEvent _Pt_((IMIC *icp, int synchronous, XEvent *ev));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
162 static void processPendingEvents _Pt_((IMIC *icp,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
163 IMPendingEvent *pending_event));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
164
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
165
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
166 /*- compileTbl: assemble IMMainDispatchTbl -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
167 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
168 compileTbl(req)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
169 IMRequest *req;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
170 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
171 while (req->name != NULL) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
172 req->next = IMMainDispatchTable[req->major];
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
173 IMMainDispatchTable[req->major] = req;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
174 req++;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
175 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
176 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
177
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
178 /*- ximDisconnectProc: handle XIM_DISCONNECT request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
179 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
180 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
181 ximDisconnectProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
182 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
183 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
184 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
185 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
186 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
187 IMIM *imp = conn->im_list;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
188 IMIM *imp_next;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
189
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
190 TRACE(("ximDisconnectProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
191
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
192 if (arglen != 0) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
193 DPRINT(("ximDisconnectProc: arglen != 0\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
194 IMSendBadLength(conn, 0, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
195 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
196 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
197
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
198 while (imp != NULL) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
199 imp_next = imp->next;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
200 IMDestroyIM(imp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
201 imp = imp_next;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
202 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
203 IMSendSimpleRequest(conn, XIM_DISCONNECT_REPLY, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
204 IMSchedule(conn, SCHED_CLOSE);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
205 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
206
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
207 /*- ecode2str: error code to error name string converter -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
208 static char *
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
209 ecode2str(code)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
210 int code;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
211 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
212 char *s;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
213
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
214 switch (code) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
215 case IMBadAlloc: s = "BadAlloc"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
216 case IMBadStyle: s = "BadStyle"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
217 case IMBadClientWindow: s = "BadClientWindow"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
218 case IMBadFocusWindow: s = "BadFocusWindow"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
219 case IMBadArea: s = "BadArea"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
220 case IMBadSpotLocation: s = "BadSpotLocation"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
221 case IMBadColormap: s = "BadColormap"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
222 case IMBadAtom: s = "BadAtom"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
223 case IMBadPixel: s = "BadPixel"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
224 case IMBadPixmap: s = "BadPixmap"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
225 case IMBadName: s = "BadName"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
226 case IMBadCursor: s = "BadCursor"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
227 case IMBadProtocol: s = "BadProtocol"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
228 case IMBadForeground: s = "BadForeground"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
229 case IMBadBackground: s = "BadBackground"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
230 case IMLocaleNotSupported: s = "LocaleNotSupported"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
231 case IMBadSomething: s = "BadSomething"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
232 default: s = "? (undefined error code)"; break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
233 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
234 return s;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
235 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
236
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
237 /*- ximErrorProc: handle XIM_Error messsage -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
238 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
239 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
240 ximErrorProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
241 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
242 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
243 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
244 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
245 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
246 unsigned int imid, icid;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
247 int flag;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
248 int code;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
249 int msg_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
250 char msg[256 + 1];
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
251
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
252 TRACE(("ximErrorProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
253
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
254 if (arglen < 10) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
255 DPRINT(("corrupted XIM_ERROR message (arglen < 10) received\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
256 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
257 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
258 imid = IMGetC16(conn, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
259 icid = IMGetC16(conn, 2);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
260 flag = IMGetC16(conn, 4);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
261 code = IMGetC16(conn, 6);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
262 msg_len = IMGetC16(conn, 8);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
263 if (msg_len > 0) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
264 if (msg_len + 12 > arglen) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
265 DPRINT(("corrupted XIM_ERROR message (message too long) received\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
266 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
267 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
268 if (msg_len > 256) msg_len = 256;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
269 IMGetString(conn, 12, msg, msg_len);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
270 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
271 if (DEBUG_CONDITION) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
272 printf("** XIM_ERROR message received:\n");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
273 if (flag & 1) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
274 printf("\t input-method ID: %d\n", imid);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
275 } else {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
276 printf("\t input-method ID: N/A\n");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
277 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
278 if (flag & 2) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
279 printf("\tinput-context ID: %d\n", icid);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
280 } else {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
281 printf("\tinput-context ID: N/A\n");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
282 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
283 printf("\t error code: %s\n", ecode2str(code));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
284 printf("\t error message: %s\n", msg);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
285 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
286 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
287
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
288 /*- putTriggerkeyList: put trigger key list on the output stream -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
289 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
290 putTriggerkeyList(imp)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
291 IMIM *imp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
292 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
293 IMConnection *conn = imp->connection;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
294 IMTriggerKey *triggers;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
295 int num_triggers;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
296 int i;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
297
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
298 triggers = IMTriggerKeys(imp, &num_triggers);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
299
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
300 IMPutC32(conn, (unsigned long)(12 * num_triggers));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
301 for (i = 0; i < num_triggers; i++) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
302 IMPutC32(conn, triggers[i].keysym);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
303 IMPutC32(conn, (unsigned long)triggers[i].modifiers);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
304 IMPutC32(conn, (unsigned long)triggers[i].check_modifiers);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
305 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
306 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
307
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
308 /*- ximOpenProc: handle XIM_OPEN request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
309 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
310 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
311 ximOpenProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
312 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
313 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
314 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
315 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
316 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
317 int locale_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
318 char localename[256 + 1];
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
319 int offset;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
320 IMConverter *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
321 IMIM *imp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
322
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
323 TRACE(("ximOpenProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
324
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
325 if (arglen < 1) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
326 DPRINT(("ximOpenProc: arglen < 1\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
327 IMSendBadLength(conn, 0, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
328 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
329 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
330
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
331 locale_len = IMGetC8(conn, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
332 if (arglen < locale_len + 1) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
333 DPRINT(("ximOpenProc: locale too long\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
334 IMSendBadLength(conn, 0, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
335 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
336 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
337
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
338 bcopy(IMBUFDATA(IM_INBUF(conn)) + 1, localename, locale_len);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
339 localename[locale_len] = '\0';
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
340 TRACE(("\tlocalename: %s\n", localename));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
341
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
342 if ((icp = IMGetConverter(conn->proto_widget, localename)) == NULL) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
343 DPRINT(("ximOpenProc: unsupported locale %s\n", localename));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
344 IMSendError(conn, IMLocaleNotSupported, 0, 0, "unknown locale");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
345 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
346 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
347
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
348 imp = IMCreateIM(conn, icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
349
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
350 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
351 * Send open reply message.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
352 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
353 offset = IMPutHeader(conn, XIM_OPEN_REPLY, 0, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
354 IMPutC16(conn, imp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
355 IMPutIMAttrList(imp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
356 IMPutICAttrList(imp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
357 IMFinishRequest(conn, offset);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
358
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
359 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
360 * Notify conversion trigger keys.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
361 *
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
362 * Note:
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
363 * The spec says that XIM_REGISTER_TRIGGERKEYS message should
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
364 * be sent to the client bofore XIM_OPEN_REPLY message, in
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
365 * order to use dynamic event flow model. However, this
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
366 * does not work with current Xlib implementation. So we
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
367 * send XIM_REGISTER_TRIGGERKEYS just after XIM_OPEN_REPLY,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
368 * which works fine.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
369 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
370 offset = IMPutHeader(conn, XIM_REGISTER_TRIGGERKEYS, 0, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
371 IMPutC16(conn, imp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
372 IMPutC16(conn, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
373 putTriggerkeyList(imp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
374 IMFinishRequest(conn, offset);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
375 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
376
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
377 /*- ximCloseProc: handle XIM_CLOSE request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
378 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
379 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
380 ximCloseProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
381 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
382 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
383 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
384 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
385 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
386 IMIM *imp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
387
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
388 TRACE(("ximCloseProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
389
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
390 if ((imp = IMGetIM(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
391 if (arglen != 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
392 DPRINT(("ximCloseProc: arglen != 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
393 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
394 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
395 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
396
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
397 IMPutHeader(conn, XIM_CLOSE_REPLY, 0, 4);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
398 IMPutC16(conn, imp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
399 IMPutPad(conn);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
400 IMSchedule(conn, SCHED_WRITE);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
401
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
402 IMDestroyIM(imp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
403 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
404
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
405 /*- ximTriggerNotifyProc: handle XIM_TRIGGER_NOTIFY request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
406 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
407 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
408 ximTriggerNotifyProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
409 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
410 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
411 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
412 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
413 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
414 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
415 int flag;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
416 int key_index;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
417 int num_triggers;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
418
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
419 TRACE(("ximTriggerNotifyProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
420
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
421 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
422
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
423 if (arglen != 16) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
424 DPRINT(("ximTriggerNotifyProc: arglen != 16\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
425 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
426 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
427 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
428
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
429 flag = (int)IMGetC32(conn, 4);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
430 key_index = (int)IMGetC32(conn, 8);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
431 TRACE(("\tflag=%d, index=%d\n", flag, key_index));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
432
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
433 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
434 * Check flag and index. Since kinput2 does not
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
435 * specifiy off-keys, any off-key notifications
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
436 * are invalid.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
437 * The current Xlib implementation (as of pl4)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
438 * specifies incorrect key_index, so index check
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
439 * is turned off until the bug is fixed.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
440 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
441
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
442 (void)IMTriggerKeys(icp->im, &num_triggers);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
443 if (flag != 0
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
444 #ifndef XIM_BC
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
445 || key_index >= num_triggers
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
446 #endif /* XIM_BC */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
447 ) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
448 /* invalid parameter */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
449 DPRINT(("ximTriggerNotifyProc: invalid trigger spec.\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
450 IMSendError(conn, IMBadSomething, icp->im->id, icp->id,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
451 "invalid trigger key specification");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
452 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
453 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
454
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
455 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
456 * If we are already in conversion mode, do nothing special.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
457 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
458 if (!(icp->state & IC_CONVERTING)) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
459 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
460 * Start conversion.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
461 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
462 if (IMStartConversion(icp) < 0) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
463 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
464
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
465 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
466 * Send XIM_TRIGGER_NOTIFY_REPLY request.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
467 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
468 (void)IMPutHeader(conn, XIM_TRIGGER_NOTIFY_REPLY, 0, 4);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
469 IMPutC16(conn, icp->im->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
470 IMPutC16(conn, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
471 IMSchedule(conn, SCHED_WRITE);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
472 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
473
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
474 /*- findCtext: look up COMPOUND_TEXT from encoding list -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
475 static int
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
476 findCtext(conn, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
477 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
478 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
479 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
480 int offset, name_end;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
481 int encoding_index;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
482 unsigned int name_bytes;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
483
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
484 offset = 2;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
485 name_bytes = IMGetC16(conn, offset);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
486 offset += 2;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
487 name_end = offset + name_bytes;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
488 if (name_end > arglen) return -2;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
489
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
490 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
491 * Examine encodings listed by name.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
492 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
493 encoding_index = 0;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
494 while (offset < name_end) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
495 char str_buf[256 + 1];
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
496 int str_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
497
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
498 str_len = IMGetC8(conn, offset++);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
499 IMGetString(conn, offset, str_buf, str_len);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
500 if (!strcmp(str_buf, "COMPOUND_TEXT")) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
501 return encoding_index;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
502 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
503 offset += str_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
504 encoding_index++;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
505 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
506
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
507 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
508 * Encodings listed by detailed data follow, but
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
509 * I have no idea what they are.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
510 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
511 return -1;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
512 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
513
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
514 /*- ximEncodingNegotiationProc: handle XIM_ENCODING_NEGOTIATION request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
515 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
516 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
517 ximEncodingNegotiationProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
518 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
519 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
520 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
521 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
522 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
523 IMIM *imp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
524 int encoding_index;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
525
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
526 TRACE(("ximEncodingNegotiationProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
527
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
528 if ((imp = IMGetIM(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
529
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
530 if (arglen < 8) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
531 DPRINT(("ximEncodingNegotiationProc: arglen < 8\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
532 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
533 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
534 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
535
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
536 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
537 * Always use COMPOUND_TEXT.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
538 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
539 if ((encoding_index = findCtext(conn, arglen)) < -1) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
540 /* bad argument error */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
541 DPRINT(("ximEncodingNegotiationProc: encoding list corrupted\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
542 IMSendError(conn, IMBadSomething, imp->id, 0,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
543 "corrupted argument");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
544 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
545 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
546 TRACE(("\tselected encoding index: %d\n", encoding_index));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
547
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
548 (void)IMPutHeader(conn, XIM_ENCODING_NEGOTIATION_REPLY, 0, 8);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
549 IMPutC16(conn, imp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
550 IMPutC16(conn, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
551 IMPutI16(conn, encoding_index);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
552 IMPutPad(conn);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
553 IMSchedule(conn, SCHED_WRITE);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
554 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
555
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
556 /*- getExtension: search named extension -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
557 static IMRequest *
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
558 getExtension(name)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
559 char *name;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
560 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
561 IMRequest *req = extRequestTbl;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
562
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
563 while (req->name != NULL) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
564 if (!strcmp(req->name, name)) return req;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
565 req++;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
566 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
567 return NULL;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
568 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
569
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
570 /*- putExtension: put extension information on the output stream -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
571 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
572 putExtension(conn, req)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
573 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
574 IMRequest *req;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
575 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
576 int text_length;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
577
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
578 text_length = strlen(req->name);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
579 IMPutC8(conn, req->major);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
580 IMPutC8(conn, req->minor);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
581 IMPutC16(conn, (unsigned int)text_length);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
582 IMPutString(conn, req->name, text_length);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
583 IMPutPad(conn);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
584 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
585
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
586 /*- ximQueryExtensionProc: handle XIM_QUERY_EXTENSION request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
587 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
588 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
589 ximQueryExtensionProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
590 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
591 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
592 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
593 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
594 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
595 IMIM *imp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
596 int ext_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
597 int cur_off;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
598 int req_offset;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
599 int size_offset;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
600 int list_start, list_end;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
601
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
602 TRACE(("ximQueryExtensionProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
603
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
604 if ((imp = IMGetIM(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
605 if (arglen < 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
606 DPRINT(("ximQueryExtensionProc: arglen < 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
607 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
608 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
609 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
610 ext_len = IMGetC16(conn, 2);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
611 if (4 + ext_len > arglen) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
612 DPRINT(("ximQueryExtensionProc: extension list too long\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
613 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
614 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
615 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
616 cur_off = 4;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
617
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
618 req_offset = IMPutHeader(conn, XIM_QUERY_EXTENSION_REPLY, 0, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
619 IMPutC16(conn, imp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
620 size_offset = IMWritePos(conn);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
621 IMPutC16(conn, 0); /* dummy. overwritten afterwards */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
622
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
623 list_start = IMWritePos(conn);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
624
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
625 if (ext_len == 0) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
626 IMRequest *ext_req = extRequestTbl;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
627
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
628 while (ext_req->name != NULL) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
629 putExtension(conn, ext_req);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
630 ext_req++;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
631 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
632
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
633 } else {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
634 IMRequest *ext_req;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
635
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
636 while (ext_len > 1) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
637 int str_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
638 char ext_name[256 + 1];
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
639
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
640 str_len = IMGetC8(conn, cur_off);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
641 cur_off++;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
642
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
643 if (str_len + 1 > ext_len) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
644 DPRINT(("ximQueryExtensionProc: extension name too long\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
645 IMCancelRequest(conn, req_offset);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
646 /* BadString */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
647 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
648 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
649 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
650
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
651 IMGetString(conn, cur_off, ext_name, str_len);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
652 TRACE(("\tclient queries %s extension\n", ext_name));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
653
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
654 if ((ext_req = getExtension(ext_name)) != NULL) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
655 putExtension(conn, ext_req);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
656 imp->mask |= ext_req->mask;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
657 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
658 cur_off += str_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
659 ext_len -= str_len + 1;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
660 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
661 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
662
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
663 list_end = IMWritePos(conn);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
664 IMRewriteC16(conn, size_offset, (unsigned int)(list_end - list_start));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
665
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
666 IMFinishRequest(conn, req_offset);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
667 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
668
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
669 /*- ximSetIMValuesProc: handle XIM_SET_IM_VALUES request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
670 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
671 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
672 ximSetIMValuesProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
673 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
674 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
675 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
676 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
677 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
678 IMIM *imp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
679 char *attr;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
680 int attr_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
681
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
682 TRACE(("ximSetIMValuesProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
683
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
684 if ((imp = IMGetIM(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
685 if (arglen < 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
686 DPRINT(("ximSetIMValuesProc: arglen < 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
687 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
688 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
689 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
690
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
691 attr_len = IMGetC16(conn, 2);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
692 attr = IMBUFDATA(IM_INBUF(conn)) + 4;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
693
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
694 if (arglen < attr_len + 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
695 DPRINT(("ximSetIMValuesProc: attribute len too long\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
696 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
697 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
698 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
699
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
700 if (IMSetIMValues(imp, attr, attr_len, major) < 0) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
701
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
702 (void)IMPutHeader(conn, XIM_SET_IM_VALUES_REPLY, 0, 4);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
703 IMPutC16(conn, imp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
704 IMPutPad(conn);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
705 IMSchedule(conn, SCHED_WRITE);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
706 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
707
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
708 /*- ximGetIMValuesProc: handle XIM_GET_IM_VALUES request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
709 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
710 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
711 ximGetIMValuesProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
712 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
713 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
714 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
715 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
716 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
717 IMIM *imp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
718 char *attr;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
719 int attr_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
720 int offset;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
721
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
722 TRACE(("ximGetIMValuesProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
723
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
724 if ((imp = IMGetIM(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
725 if (arglen < 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
726 DPRINT(("ximGetIMValuesProc: arglen < 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
727 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
728 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
729 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
730
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
731 attr_len = IMGetC16(conn, 2);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
732 attr = IMBUFDATA(IM_INBUF(conn)) + 4;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
733 if (arglen < attr_len + 4 || attr_len % 2 == 1) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
734 DPRINT(("ximGetIMValuesProc: attr_len too long or an odd number\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
735 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
736 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
737 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
738
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
739 offset = IMPutHeader(conn, XIM_GET_IM_VALUES_REPLY, 0, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
740 IMPutC16(conn, imp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
741
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
742 if (IMGetIMValues(imp, attr, attr_len, offset) < 0) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
743
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
744 IMFinishRequest(conn, offset);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
745 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
746
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
747 /*- ximCreateICProc: handle XIM_CREATE_IC request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
748 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
749 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
750 ximCreateICProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
751 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
752 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
753 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
754 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
755 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
756 IMIM *imp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
757 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
758 char *attr_data;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
759 int attr_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
760
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
761 TRACE(("ximCreateICProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
762
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
763 if ((imp = IMGetIM(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
764 if (arglen < 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
765 /* BadArglen */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
766 DPRINT(("ximCreateICProc: arglen < 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
767 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
768 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
769 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
770
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
771 attr_len = IMGetC16(conn, 2);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
772 attr_data = IMBUFDATA(IM_INBUF(conn)) + 4;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
773 if (arglen < attr_len + 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
774 DPRINT(("ximCreateICProc: attr_len too long\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
775 IMSendBadLength(conn, imp->id, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
776 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
777 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
778 icp = IMCreateIC(imp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
779 if (IMSetICValues(icp, attr_data, attr_len, major) < 0) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
780 IMDestroyIC(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
781 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
782 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
783 IMSendRequestWithIC(conn, XIM_CREATE_IC_REPLY, 0, icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
784
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
785 IMStatusStart(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
786 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
787
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
788 /*- ximDestroyICProc: handle XIM_DESTROY_IC request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
789 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
790 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
791 ximDestroyICProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
792 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
793 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
794 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
795 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
796 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
797 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
798 unsigned int imid, icid;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
799
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
800 TRACE(("ximDestroyICProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
801
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
802 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
803 if (arglen != 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
804 DPRINT(("ximDestroyICProc: arglen != 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
805 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
806 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
807 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
808
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
809 /* Save ID of IM/IC before IMDestroyIC() */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
810 imid = icp->im->id;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
811 icid = icp->id;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
812
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
813 IMStatusDone(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
814
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
815 IMDestroyIC(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
816
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
817 /* IMSendRequestWithIC(conn, XIM_DESTROY_IC_REPLY, 0, icp); */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
818 IMPutHeader(conn, XIM_DESTROY_IC_REPLY, 0, 4);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
819 IMPutC16(conn, imid);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
820 IMPutC16(conn, icid);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
821 IMSchedule(conn, SCHED_WRITE);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
822 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
823
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
824 /*- ximSetICValuesProc: handle XIM_SET_IC_VALUES request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
825 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
826 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
827 ximSetICValuesProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
828 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
829 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
830 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
831 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
832 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
833 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
834 char *attr;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
835 int attr_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
836
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
837 TRACE(("ximSetICValuesProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
838
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
839 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
840 if (arglen < 8) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
841 DPRINT(("ximSetICValuesProc: arglen < 8\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
842 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
843 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
844 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
845
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
846 attr_len = IMGetC16(conn, 4);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
847 attr = IMBUFDATA(IM_INBUF(conn)) + 8;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
848
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
849 if (arglen < attr_len + 8) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
850 DPRINT(("ximSetICValuesProc: attr_len too long\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
851 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
852 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
853 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
854
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
855 if (IMSetICValues(icp, attr, attr_len, major) < 0) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
856
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
857 IMSendRequestWithIC(conn, XIM_SET_IC_VALUES_REPLY, 0, icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
858 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
859
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
860 /*- ximGetICValuesProc: handle XIM_GET_IC_VALUES request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
861 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
862 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
863 ximGetICValuesProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
864 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
865 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
866 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
867 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
868 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
869 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
870 char *attr;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
871 int attr_len;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
872 int offset;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
873
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
874 TRACE(("ximGetICValuesProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
875
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
876 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
877 if (arglen < 6) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
878 DPRINT(("ximGetICValuesProc: arglen < 6\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
879 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
880 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
881 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
882
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
883 attr_len = IMGetC16(conn, 4);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
884 attr = IMBUFDATA(IM_INBUF(conn)) + 6;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
885 if (arglen < attr_len + 6 || attr_len % 2 == 1) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
886 DPRINT(("ximGetICValuesProc: attr_len too long or an odd number\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
887 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
888 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
889 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
890
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
891 offset = IMPutHeader(conn, XIM_GET_IC_VALUES_REPLY, 0, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
892 IMPutC16(conn, icp->im->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
893 IMPutC16(conn, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
894
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
895 if (IMGetICValues(icp, attr, attr_len, offset) < 0) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
896
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
897 IMFinishRequest(conn, offset);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
898 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
899
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
900 /*- ximSetICFocusProc: handle XIM_SET_IC_FOCUS request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
901 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
902 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
903 ximSetICFocusProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
904 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
905 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
906 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
907 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
908 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
909 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
910
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
911 TRACE(("ximSetICFocusProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
912
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
913 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
914 if (arglen != 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
915 DPRINT(("ximSetICFocusProc: arglen != 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
916 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
917 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
918 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
919 IMStatusStart(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
920 IMSetFocus(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
921 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
922
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
923 /*- ximUnsetICFocusProc: handle XIM_UNSET_IC_FOCUS request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
924 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
925 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
926 ximUnsetICFocusProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
927 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
928 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
929 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
930 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
931 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
932 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
933
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
934 TRACE(("ximUnsetICFocusProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
935
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
936 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
937 if (arglen != 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
938 DPRINT(("ximUnsetICFocusProc: arglen != 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
939 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
940 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
941 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
942 IMUnsetFocus(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
943 IMStatusDone(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
944 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
945
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
946 /*- swapData: do byte swapping -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
947 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
948 swapData(data, format)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
949 char *data;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
950 char *format;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
951 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
952 unsigned char *p = (unsigned char *)data;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
953 int x;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
954 int f;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
955
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
956 #define SWAPB(b1, b2) x = b1; b1 = b2; b2 = x
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
957 while ((f = *format++) != '\0') {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
958 switch (f) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
959 case 'x':
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
960 p++;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
961 break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
962 case 'l':
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
963 SWAPB(p[0], p[3]);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
964 SWAPB(p[1], p[2]);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
965 p += 4;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
966 break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
967 case 's':
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
968 SWAPB(p[0], p[1]);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
969 p += 2;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
970 break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
971 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
972 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
973 #undef SWAPB
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
974 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
975
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
976
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
977 /*- getEvent: read a wire event and convert it to XEvent format -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
978 static int
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
979 getEvent(conn, serial, offset, ev)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
980 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
981 unsigned int serial;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
982 int offset;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
983 XEvent *ev;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
984 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
985 IMBuffer *ibp = IM_INBUF(conn);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
986 xEvent wire_event;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
987 int swap_needed;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
988 int one = 1;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
989 char *onep = (char *)&one;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
990
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
991 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
992 * Get wire event from input buffer.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
993 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
994 bcopy(IMBUFDATA(ibp) + offset, (char *)&wire_event, sizeof(wire_event));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
995
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
996 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
997 * Do we need byte swapping?
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
998 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
999 if (*onep == 0) { /* big endian */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1000 swap_needed = (conn->byte_order == ORDER_LITTLE);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1001 } else { /* little endian */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1002 swap_needed = (conn->byte_order == ORDER_BIG);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1003 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1004
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1005 #define SWAPEV(format) if (swap_needed) swapData((char *)&wire_event, format)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1006
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1007 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1008 * Get common part of the wire event.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1009 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1010 SWAPEV("xxs");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1011 ev->type = wire_event.u.u.type & 0x7f;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1012 ev->xany.serial = (serial << 16) | wire_event.u.u.sequenceNumber;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1013 ev->xany.display = XtDisplay(conn->proto_widget);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1014 ev->xany.send_event = wire_event.u.u.type > 127;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1015
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1016 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1017 * Convert wire format to XEvent format.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1018 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1019 switch (ev->type) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1020 case KeyPress:
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1021 case KeyRelease:
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1022 SWAPEV("xxxxllllsssssxx");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1023 #define WIRE wire_event.u.keyButtonPointer
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1024 ev->xkey.window = WIRE.event;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1025 ev->xkey.root = WIRE.root;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1026 ev->xkey.subwindow = WIRE.child;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1027 ev->xkey.time = WIRE.time;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1028 ev->xkey.x = cvtINT16toInt(WIRE.eventX);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1029 ev->xkey.y = cvtINT16toInt(WIRE.eventY);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1030 ev->xkey.x_root = cvtINT16toInt(WIRE.rootX);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1031 ev->xkey.y_root = cvtINT16toInt(WIRE.rootY);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1032 ev->xkey.state = WIRE.state;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1033 ev->xkey.keycode = wire_event.u.u.detail;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1034 ev->xkey.same_screen = WIRE.sameScreen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1035 #undef WIRE
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1036 break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1037 case ButtonPress:
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1038 case ButtonRelease:
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1039 SWAPEV("xxxxllllsssssxx");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1040 #define WIRE wire_event.u.keyButtonPointer
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1041 ev->xbutton.window = WIRE.event;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1042 ev->xbutton.root = WIRE.root;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1043 ev->xbutton.subwindow = WIRE.child;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1044 ev->xbutton.time = WIRE.time;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1045 ev->xbutton.x = cvtINT16toInt(WIRE.eventX);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1046 ev->xbutton.y = cvtINT16toInt(WIRE.eventY);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1047 ev->xbutton.x_root = cvtINT16toInt(WIRE.rootX);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1048 ev->xbutton.y_root = cvtINT16toInt(WIRE.rootY);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1049 ev->xbutton.state = WIRE.state;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1050 ev->xbutton.button = wire_event.u.u.detail;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1051 ev->xbutton.same_screen = WIRE.sameScreen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1052 #undef WIRE
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1053 break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1054 case MotionNotify:
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1055 SWAPEV("xxxxllllsssssxx");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1056 #define WIRE wire_event.u.keyButtonPointer
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1057 ev->xmotion.window = WIRE.event;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1058 ev->xmotion.root = WIRE.root;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1059 ev->xmotion.subwindow = WIRE.child;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1060 ev->xmotion.time = WIRE.time;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1061 ev->xmotion.x = cvtINT16toInt(WIRE.eventX);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1062 ev->xmotion.y = cvtINT16toInt(WIRE.eventY);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1063 ev->xmotion.x_root = cvtINT16toInt(WIRE.rootX);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1064 ev->xmotion.y_root = cvtINT16toInt(WIRE.rootY);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1065 ev->xmotion.state = WIRE.state;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1066 ev->xmotion.is_hint = wire_event.u.u.detail;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1067 ev->xmotion.same_screen = WIRE.sameScreen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1068 #undef WIRE
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1069 break;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1070 default:
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1071 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1072 * For now, this function deals only Key/Pointer events.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1073 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1074 return 0;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1075 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1076 #undef SWAPEV
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1077
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1078 return 1; /* success */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1079 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1080
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1081 /*- postponeEvent: record events for delayed processing -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1082 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1083 postponeEvent(icp, synchronous, ev)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1084 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1085 int synchronous;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1086 XEvent *ev;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1087 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1088 IMPendingEvent *pending;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1089
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1090 pending = XtNew(IMPendingEvent);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1091 pending->ic = icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1092 pending->synchronous = synchronous;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1093 bcopy((char *)ev, (char *)&pending->event, sizeof(XEvent));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1094 pending->next = icp->pending_events;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1095 icp->pending_events = pending;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1096 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1097
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1098 /*- handleForwardedEvent: deal with forwarded events -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1099 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1100 handleForwardedEvent(icp, synchronous, ev)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1101 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1102 int synchronous;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1103 XEvent *ev;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1104 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1105 IMConnection *conn = icp->im->connection;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1106
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1107 TRACE(("handleForwardedEvent()\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1108
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1109 icp->state |= IC_FORWARDING;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1110
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1111 if (icp->state & IC_SYNCING) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1112 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1113 * We are waiting for SYNC_REPLY message.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1114 * Postpone event processing.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1115 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1116 DDPRINT(2, ("forward event processing suspended\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1117 postponeEvent(icp, synchronous, ev);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1118 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1119 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1120
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1121 IMForwardEvent(icp, ev);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1122
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1123 #ifdef notyet
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1124 if (synchronous) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1125 if (!(icp->state & IC_CONVERTING)) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1126 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1127 * Stop forwarding key events.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1128 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1129 IMStopForwarding(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1130 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1131 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1132 * All the processing is done. Send XIM_SYNC_REPLY.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1133 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1134 IMSendRequestWithIC(conn, XIM_SYNC_REPLY, 0, icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1135 } else {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1136 int cur_pos2;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1137
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1138 cur_pos2 = IMWritePos(conn);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1139 if (!(icp->state & IC_CONVERTING)) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1140 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1141 * Stop forwarding key events.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1142 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1143 IMStopForwarding(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1144 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1145 * Put dummy commit request (for setting sync flag).
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1146 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1147 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1148 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1149 #else
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1150 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1151 * Currently, kinput2 supports only full synchronous method.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1152 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1153 if (!(icp->state & IC_CONVERTING)) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1154 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1155 * Stop forwarding key events.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1156 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1157 IMStopForwarding(icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1158 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1159 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1160 * All the processing is done. Send XIM_SYNC_REPLY.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1161 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1162 if (icp->state & IC_FORWARDING) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1163 icp->state &= ~IC_FORWARDING;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1164 IMSendRequestWithIC(conn, XIM_SYNC_REPLY, 0, icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1165 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1166 #endif
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1167 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1168
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1169 /*- ximForwardEventProc: handle XIM_FORWARD_EVENT request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1170 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1171 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1172 ximForwardEventProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1173 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1174 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1175 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1176 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1177 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1178 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1179 int synchronous;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1180 unsigned int serial;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1181 XEvent event;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1182
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1183 TRACE(("ximForwardEventProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1184
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1185 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1186 if (arglen != 40) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1187 DPRINT(("ximForwardEventProc: arglen != 40\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1188 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1189 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1190 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1191
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1192 synchronous = IMGetC16(conn, 4) & 1;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1193 serial = IMGetC16(conn, 6);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1194
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1195 if (getEvent(conn, serial, 8, &event)) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1196 handleForwardedEvent(icp, synchronous, &event);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1197 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1198 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1199
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1200 /*- ximExtForwardKeyeventProc: handle XIM_EXT_FORWARD_KEYEVENT_MASK request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1201 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1202 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1203 ximExtForwardKeyeventProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1204 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1205 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1206 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1207 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1208 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1209 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1210 int synchronous;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1211 int type;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1212 unsigned int serial;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1213 XEvent event;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1214
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1215 TRACE(("ximExtForwardKeyeventProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1216
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1217 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1218
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1219 if (!(icp->im->mask & XIM_EXT_FORWARD_KEYEVENT_MASK)) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1220 DPRINT(("ximExtForwardKeyeventProc: ext_forward_keyevent disabled\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1221 IMSendBadProtocol(conn, "ext_forward_keyevent extension not enabled");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1222 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1223 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1224
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1225 if (arglen != 16) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1226 DPRINT(("ximExtForwardKeyeventProc: arglen != 16\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1227 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1228 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1229 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1230
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1231 synchronous = IMGetC16(conn, 4) & 1;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1232 serial = IMGetC16(conn, 6);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1233 type = IMGetC8(conn, 8);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1234 if (type != KeyPress && type != KeyRelease) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1235 /* Badtype */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1236 IMSendError(conn, IMBadSomething, icp->im->id, icp->id,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1237 "forwarded event is invalid type");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1238 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1239 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1240
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1241 event.type = type;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1242 event.xkey.serial = serial; /* ??? */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1243 event.xkey.keycode = IMGetC8(conn, 9);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1244 event.xkey.state = IMGetC16(conn, 10);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1245 event.xkey.time = IMGetC32(conn, 12);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1246 event.xkey.window = IMGetC32(conn, 16);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1247 event.xkey.root = icp->client_profile.root;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1248 event.xkey.subwindow = None;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1249 event.xkey.x = 0;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1250 event.xkey.y = 0;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1251 event.xkey.x_root = 0;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1252 event.xkey.y_root = 0;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1253 event.xkey.same_screen = True;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1254
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1255 handleForwardedEvent(icp, synchronous, &event);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1256 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1257
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1258 /*- ximSyncProc: handle XIM_SYNC request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1259 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1260 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1261 ximSyncProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1262 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1263 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1264 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1265 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1266 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1267 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1268
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1269 TRACE(("ximSyncProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1270
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1271 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1272 if (arglen != 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1273 DPRINT(("ximSyncProc: arglen != 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1274 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1275 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1276 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1277 IMSendRequestWithIC(conn, XIM_SYNC_REPLY, 0, icp);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1278 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1279
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1280 /*- processPendingEvents: process pending events forwarded by the client -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1281 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1282 processPendingEvents(icp, pending_event)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1283 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1284 IMPendingEvent *pending_event;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1285 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1286 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1287 * Pending events list is in reverse order.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1288 * Processing is done from the tail of the list, using
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1289 * recursive call.
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1290 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1291 if (pending_event == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1292 processPendingEvents(icp, pending_event->next);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1293 pending_event->next = NULL;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1294 handleForwardedEvent(icp, pending_event->synchronous,
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1295 &pending_event->event);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1296 XtFree((char *)pending_event);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1297 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1298
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1299 /*- ximSyncReplyProc: handle XIM_SYNC_REPLY message -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1300 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1301 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1302 ximSyncReplyProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1303 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1304 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1305 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1306 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1307 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1308 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1309
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1310 TRACE(("ximSyncReplyProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1311
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1312 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1313 if (arglen != 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1314 DPRINT(("ximSyncReplyProc: arglen != 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1315 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1316 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1317 if (icp->state & IC_SYNCING) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1318 icp->state &= ~IC_SYNCING;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1319 processPendingEvents(icp, icp->pending_events);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1320 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1321 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1322
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1323 /*- ximResetICProc: handle XIM_RESET_IC message -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1324 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1325 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1326 ximResetICProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1327 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1328 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1329 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1330 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1331 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1332 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1333 char *text = NULL;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1334 int offset;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1335 int text_length;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1336
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1337 TRACE(("ximResetICProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1338
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1339 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1340 if (arglen != 4) {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1341 DPRINT(("ximResetICProc: arglen != 4\n"));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1342 IMSendBadLength(conn, icp->im->id, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1343 return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1344 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1345 icp->state |= IC_RESETTING;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1346 text_length = IMResetIC(icp, &text);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1347
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1348 offset = IMPutHeader(conn, XIM_RESET_IC_REPLY, 0, 0);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1349 IMPutC16(conn, icp->im->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1350 IMPutC16(conn, icp->id);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1351 IMPutC16(conn, (unsigned int)text_length);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1352 if (text_length > 0) IMPutString(conn, text, text_length);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1353 IMFinishRequest(conn, offset);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1354 if (text != NULL) XtFree(text);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1355 icp->state &= ~IC_RESETTING;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1356 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1357
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1358 /*- ximExtMoveProc: handle XIM_EXT_MOVE request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1359 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1360 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1361 ximExtMoveProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1362 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1363 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1364 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1365 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1366 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1367 IMIC *icp;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1368 int x, y;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1369
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1370 TRACE(("ximExtMoveProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1371
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1372 if ((icp = IMGetIC(conn, arglen)) == NULL) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1373 x = IMGetI16(conn, 4);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1374 y = IMGetI16(conn, 6);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1375 IMMoveLocation(icp, x, y);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1376 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1377
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1378 /*- ximAlreadyConnectedProc: handle duplicate XIM_CONNECT request -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1379 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1380 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1381 ximAlreadyConnectedProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1382 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1383 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1384 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1385 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1386 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1387 TRACE(("ximAlreadyConnectedProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1388
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1389 DPRINT(("connection #%d sent multiple XIM_CONNECT request\n",
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1390 conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1391 IMSendBadProtocol(conn, "duplicate XIM_CONNECT message");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1392 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1393
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1394 /*- ximShouldNotBeSentProc: handle requests which clients should not send -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1395 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1396 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1397 ximShouldNotBeSentProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1398 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1399 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1400 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1401 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1402 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1403 TRACE(("ximShouldNotBeSentProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1404
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1405 DPRINT(("connection #%d sent invalid request\n", conn->serial))
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1406 IMSendBadProtocol(conn, "Clients should not send this request");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1407 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1408
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1409 /*- ximAuthPhaseProc: handle requests for authentication -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1410 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1411 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1412 ximAuthPhaseProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1413 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1414 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1415 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1416 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1417 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1418 TRACE(("ximAuthPhaseProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1419
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1420 DPRINT(("connection #%d sends auth-related request\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1421 IMSendBadProtocol(conn, "not authentication phase");
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1422 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1423
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1424 /*- ximNopProc: nop -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1425 /* ARGSUSED */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1426 static void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1427 ximNopProc(conn, major, minor, arglen)
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1428 IMConnection *conn;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1429 int major;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1430 int minor;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1431 int arglen;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1432 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1433 TRACE(("ximNopProc(#%d)\n", conn->serial));
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1434
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1435 /* do nothing */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1436 }
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1437
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1438 /*
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1439 * Public Function
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1440 */
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1441
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1442 /*- IMCompileReq: initialize IMMainDispatchTable -*/
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1443 void
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1444 IMCompileReq()
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1445 {
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1446 static int compiled = 0;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1447
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1448 if (compiled) return;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1449 compileTbl(coreRequestTbl);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1450 compileTbl(extRequestTbl);
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1451 compiled = 1;
92745d501b9a initial import from kinput2-v3.1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1452 }