1 /* # skkinput (Simple Kana-Kanji Input)
2  *
3  * This file is part of skkinput.
4  * Copyright (C) 2002
5  * Takashi SAKAMOTO (PXG01715@nifty.ne.jp)
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with skkinput; see the file COPYING.  If not, write to
19  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 #include "AfxWin.h"
22 #include "local.h"
23 #include <stdio.h>
24 #include <X11/Xlib.h>
25 #include <X11/Intrinsic.h>
26 #include <X11/StringDefs.h>
27 #include <sys/time.h>
28 //#include "skkinput.h"
29 #include "XIMInputContextP.h"
30 #include "XIMClient.h"
31 #include "XIMData.h"
32 #include "dispatch.h"
33 #include "lmachine.h"
34 #include "lispmgr.h"
35 #include "TFrame.h"
36 #include "TRootWindow.h"
37 #include "TOverTheSpotWindow.h"
38 #include "TOffTheSpotWindow.h"
39 #include "TOnTheSpotWindow.h"
40 #include "TNormalFrame.h"
41 #include "TSubWindowFrame.h"
42 #include "lispyevent.h"
43 
44 #define	DEFAULT_XIM_PREEDIT_LINESPACING		(14)
45 #define	DEFAULT_XIM_STATUS_LINESPACING		(14)
46 
47 static	Boolean	ximInputContext_createFrame			(XIMInputContext*) ;
48 static	Boolean	ximInputContext_initializeLispPart	(XIMInputContext*, Widget, Widget) ;
49 static	void	ximInputContext_onKeyPress			(Widget, XtPointer, XtPointer) ;
50 static	void	ximInputContext_onFrameConfigure	(Widget, XtPointer, XtPointer) ;
51 static	void	ximInputContext_onFrameDestroy		(Widget, XtPointer, XtPointer) ;
52 static	void	ximInputContext_onPreeditStart		(Widget, XtPointer, XtPointer) ;
53 static	void	ximInputContext_onPreeditDraw		(Widget, XtPointer, XtPointer) ;
54 static	void	ximInputContext_onPreeditCaret		(Widget, XtPointer, XtPointer) ;
55 static	void	ximInputContext_onPreeditDone		(Widget, XtPointer, XtPointer) ;
56 static	void	ximInputContext_onStatusStart		(Widget, XtPointer, XtPointer) ;
57 static	void	ximInputContext_onStatusDraw		(Widget, XtPointer, XtPointer) ;
58 static	void	ximInputContext_onStatusDone		(Widget, XtPointer, XtPointer) ;
59 
60 static	void	ximInputContext_onKeyNotify			(void*, TXEvent*) ;
61 static	void	ximInputContext_onTextNotify		(void*, const Char*, int) ;
62 static	void	ximInputContext_onEndNotify			(void*) ;
63 
64 static	Boolean	ximInputContext_packetToCombinep	(XIMPacket*) ;
65 static	XIMPacket*	ximInputContext_combineXimCommit(XIMInputContext*, XIMPacket*, XIMPacket*) ;
66 static	void	ximInputContext_addFrameCallbacks	(XIMInputContext*, Widget) ;
67 static	void	ximInputContext_removeFrameCallbacks(XIMInputContext*, Widget) ;
68 
69 XIMInputContext*
XIMInputContext_Create(register XIMInputMethod * pInputMethod,register int nID)70 XIMInputContext_Create (
71 	register XIMInputMethod*	pInputMethod,
72 	register int				nID)
73 {
74 	register XIMInputContext*	pInputContext ;
75 
76 	pInputContext	= MALLOC (sizeof (XIMInputContext)) ;
77 	if (pInputContext == NULL)
78 		return	NULL ;
79 
80 	pInputContext->m_pInputMethod		= pInputMethod ;
81 	pInputContext->m_pNext				= NULL ;
82 	pInputContext->m_woID				= nID ;
83 	pInputContext->m_ulAttributeMask	= 0L ;
84 	pInputContext->m_wgTopFrame			= NULL ;
85 	pInputContext->m_wgTopMinibufFrame	= NULL ;
86 	pInputContext->m_ulResetState		= XIMInitialState ;
87 	pInputContext->m_preeditState		= XIMPreeditDisable ;
88 	pInputContext->m_wndClient			= None ;
89 	pInputContext->m_wndFocus			= None ;
90 	pInputContext->m_dwFilterEvents		= 0 ;
91 	pInputContext->m_uSyncStatus		= 0 ;
92 	pInputContext->m_dwInputStyle		= XIMStatusNothing | XIMPreeditNothing ;
93 	pInputContext->m_pNext				= NULL ;
94 	pInputContext->m_fDestroy			= False ;
95 	pInputContext->m_fFocus				= False ;
96 	pInputContext->m_atPStdColormap		= None ;
97 	pInputContext->m_atSStdColormap		= None ;
98 	TQueue_Initialize     (&pInputContext->m_quePacketSpool,   sizeof (XIMPacket*)) ;
99 	TVarbuffer_Initialize (&pInputContext->m_vbufPFontSetName, sizeof (char)) ;
100 	TVarbuffer_Initialize (&pInputContext->m_vbufSFontSetName, sizeof (char)) ;
101 	TConvAttr_Initialize (&pInputContext->m_ConvAttr) ;
102 	TLispClient_PreInitialize (&pInputContext->m_LispClient) ;
103 
104 	/*	�����������֤����褬�İ��� Client ��������ʤ���ʬ����ʤ��ġ�
105 	 *	����Ū�˥����Ф��饳��ȥ���Ǥ��ʤ��Ȥ����Τϡ�
106 	 *	���ˤ��ʤäƤ���Τ�����Ȥ�ġ�*/
107 	pInputContext->m_wndKeyFocus		= None ;
108 	return	pInputContext ;
109 }
110 
111 void
XIMInputContext_Destroy(register XIMInputContext * pThis)112 XIMInputContext_Destroy (
113 	register XIMInputContext*	pThis)
114 {
115 	register XIMPacket**	ppPacket ;
116 	register int			nPacket ;
117 
118 	ppPacket	= TQueue_GetData  (&pThis->m_quePacketSpool) ;
119 	nPacket		= TQueue_GetUsage (&pThis->m_quePacketSpool) ;
120 	while (nPacket -- > 0)
121 		XIMPacket_Release (*ppPacket ++) ;
122 
123 	TQueue_Uninitialize     (&pThis->m_quePacketSpool) ;
124 	TVarbuffer_Uninitialize (&pThis->m_vbufPFontSetName) ;
125 	TVarbuffer_Uninitialize (&pThis->m_vbufSFontSetName) ;
126 	TConvAttr_Uninitialize  (&pThis->m_ConvAttr) ;
127 
128 	if (pThis->m_wgTopFrame != NULL)
129 		ximInputContext_removeFrameCallbacks (pThis, pThis->m_wgTopFrame) ;
130 	if (pThis->m_wgTopMinibufFrame != NULL &&
131 		pThis->m_wgTopMinibufFrame != pThis->m_wgTopFrame)
132 		ximInputContext_removeFrameCallbacks (pThis, pThis->m_wgTopMinibufFrame) ;
133 	pThis->m_wgTopFrame			= NULL ;
134 	pThis->m_wgTopMinibufFrame	= NULL ;
135 
136 	TLispClient_Uninitialize (&pThis->m_LispClient) ;
137 	FREE (pThis) ;
138 	return ;
139 }
140 
141 void
XIMInputContext_SetNext(register XIMInputContext * pThis,register XIMInputContext * pNext)142 XIMInputContext_SetNext (
143 	register XIMInputContext*	pThis,
144 	register XIMInputContext*	pNext)
145 {
146 	assert (pThis != NULL) ;
147 	pThis->m_pNext	= pNext ;
148 	return ;
149 }
150 
151 XIMInputContext*
XIMInputContext_GetNext(register XIMInputContext * pThis)152 XIMInputContext_GetNext (
153 	register XIMInputContext*	pThis)
154 {
155 	assert (pThis != NULL) ;
156 	return	pThis->m_pNext ;
157 }
158 
159 int
XIMInputContext_GetID(register XIMInputContext * pThis)160 XIMInputContext_GetID (
161 	register XIMInputContext*	pThis)
162 {
163 	assert (pThis != NULL) ;
164 	return	pThis->m_woID ;
165 }
166 
167 Boolean
XIMInputContext_Alivep(register XIMInputContext * pThis)168 XIMInputContext_Alivep (
169 	register XIMInputContext*	pThis)
170 {
171 	assert (pThis != NULL) ;
172 	return	!pThis->m_fDestroy ;
173 }
174 
175 Boolean
XIMInputContext_ForwardEvent(register XIMInputContext * pThis,register XEvent * pXEvent)176 XIMInputContext_ForwardEvent (
177 	register XIMInputContext*	pThis,
178 	register XEvent*			pXEvent)
179 {
180 #if defined (DEBUG) || 0
181 	struct timeval				te, tl ;
182 	struct timezone				tz ;
183 	gettimeofday (&te, &tz) ;
184 #endif
185 
186 	if (pXEvent->type != KeyPress)
187 		return	True ;
188 
189 	pThis->m_wndKeyFocus	= pXEvent->xkey.window ;
190 	TLispMachine_EventProc (pThis->m_LispClient.m_pLM, LMEVENT_KEYPRESS, pXEvent, 0) ;
191 	TLispClient_SetModificationFlag (&pThis->m_LispClient, True) ;
192 #if !defined (USE_ASYNC_XIM)
193 	TLispClient_Tick (&pThis->m_LispClient) ;
194 #endif
195 #if defined (DEBUG) || 0
196 	gettimeofday (&tl, &tz) ;
197 	fprintf (stderr, "forward-event: ellapsed time (%ld,%ld)\n",
198 			 tl.tv_sec - te.tv_sec, tl.tv_usec - te.tv_usec) ;
199 #endif
200 	return	True ;
201 }
202 
203 Boolean
XIMInputContext_StartConversion(register XIMInputContext * pThis)204 XIMInputContext_StartConversion (
205 	register XIMInputContext*	pThis)
206 {
207 	register Widget	wgClient ;
208 
209 #if defined (DEBUG)
210 	fprintf (stderr, "XIMInputContext_StartConversion (%p)\n", pThis) ;
211 #endif
212 
213 	if (pThis->m_preeditState == XIMPreeditEnable)
214 		return	True ;
215 
216 	/*	���ֺǽ���Ѵ�ư��ξ��ˤ� Widget ���������ɬ�פ����롣
217 	 */
218 	if (pThis->m_wgTopFrame == NULL) {
219 		if (!ximInputContext_createFrame (pThis))
220 			return	False ;
221 	} else {
222 		/*	������ʤɤν�����Ԥ���*/
223 		TLispClient_Reinitialize (&pThis->m_LispClient) ;
224 	}
225 
226 	pThis->m_preeditState	= XIMPreeditEnable ;
227 	wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
228 	//XIMClient_PreeditStateChange (wgClient, pThis->m_pInputMethod, pThis) ;
229 #if 0
230 	XIMInputContext_Activate (pThis, True) ;
231 #else
232 	XIMInputContext_Activate (pThis, True) ;
233 	pThis->m_fFocus	= True ;
234 #endif
235 	return	True ;
236 }
237 
238 Boolean
XIMInputContext_EndConversion(register XIMInputContext * pThis)239 XIMInputContext_EndConversion (
240 	register XIMInputContext*	pThis)
241 {
242 	register Widget	wgClient ;
243 
244 	if (pThis->m_preeditState == XIMPreeditDisable)
245 		return	False ;
246 
247 	pThis->m_preeditState	= XIMPreeditDisable ;
248 	XIMInputContext_Activate (pThis, False) ;
249 
250 	wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
251 	//XIMClient_PreeditStateChange (wgClient, pThis->m_pInputMethod, pThis) ;
252 	return	True ;
253 }
254 
255 Boolean
XIMInputContext_ResetConversion(register XIMInputContext * pThis)256 XIMInputContext_ResetConversion (
257 	register XIMInputContext*	pThis)
258 {
259 	return	True ;
260 }
261 
262 unsigned
XIMInputContext_GetSyncMode(register XIMInputContext * pThis)263 XIMInputContext_GetSyncMode (
264 	register XIMInputContext*	pThis)
265 {
266 	assert (pThis != NULL) ;
267 	return	pThis->m_uSyncStatus ;
268 }
269 
270 void
XIMInputContext_SetSyncMode(register XIMInputContext * pThis,register unsigned uMode)271 XIMInputContext_SetSyncMode (
272 	register XIMInputContext*	pThis,
273 	register unsigned			uMode)
274 {
275 	assert (pThis != NULL) ;
276 	assert ((uMode & XIMClientSync) || !(pThis->m_uSyncStatus & ~XIMClientSync)) ;
277 	pThis->m_uSyncStatus	|= uMode ;
278 	return ;
279 }
280 
281 void
XIMInputContext_UnsetSyncMode(register XIMInputContext * pThis,register unsigned uMode)282 XIMInputContext_UnsetSyncMode (
283 	register XIMInputContext*	pThis,
284 	register unsigned			uMode)
285 {
286 	assert (pThis != NULL) ;
287 
288 	pThis->m_uSyncStatus	&= ~uMode ;
289 	return ;
290 }
291 
292 Boolean
XIMInputContext_SpoolPacket(register XIMInputContext * pThis,XIMPacket * pPacket)293 XIMInputContext_SpoolPacket (
294 	register XIMInputContext*	pThis,
295 	XIMPacket*					pPacket)
296 {
297 	/*	Spool ����Ƥ���ľ���� packet �� XIM_COMMIT �ʤ�С�Ϣ�뤹�롣*/
298 	if (ximInputContext_packetToCombinep (pPacket)) {
299 		register XIMPacket**	ppSpooledPacket ;
300 		register int			npSpooledPacket ;
301 
302 		ppSpooledPacket	= TQueue_GetData  (&pThis->m_quePacketSpool) ;
303 		npSpooledPacket	= TQueue_GetUsage (&pThis->m_quePacketSpool) ;
304 		if (npSpooledPacket > 0) {
305 			register XIMPacket*		pLastPacket ;
306 
307 			pLastPacket	= *(ppSpooledPacket + npSpooledPacket - 1) ;
308 			if (ximInputContext_packetToCombinep (pLastPacket)) {
309 				register XIMPacket*	pNewPacket ;
310 				pNewPacket	= ximInputContext_combineXimCommit (pThis, pLastPacket, pPacket) ;
311 				if (pNewPacket == NULL)
312 					return	False ;
313 				XIMPacket_Release (pLastPacket) ;
314 				*(ppSpooledPacket + npSpooledPacket - 1)	= pNewPacket ;
315 				return	True ;
316 			}
317 		}
318 	}
319 
320 	if (TFAILED (TQueue_In (&pThis->m_quePacketSpool, &pPacket, 1)))
321 		return	False ;
322 	XIMPacket_AddRef (pPacket) ;
323 	return	True ;
324 }
325 
326 XIMPacket*
XIMInputContext_GetSpooledPacket(register XIMInputContext * pThis)327 XIMInputContext_GetSpooledPacket (
328 	register XIMInputContext*	pThis)
329 {
330 	XIMPacket*		pPacket ;
331 	register int	nOut ;
332 
333 	nOut	= TQueue_Out (&pThis->m_quePacketSpool, &pPacket, 1) ;
334 	if (nOut <= 0)
335 		return	NULL ;
336 	return	pPacket ;
337 }
338 
339 XIMPacket*
XIMInputContext_LookSpooledPacket(register XIMInputContext * pThis)340 XIMInputContext_LookSpooledPacket (
341 	register XIMInputContext*	pThis)
342 {
343 	register TQueue*	pQueue ;
344 
345 	assert (pThis != NULL) ;
346 
347 	pQueue	= &pThis->m_quePacketSpool ;
348 	if (TQueue_GetUsage (pQueue) <= 0)
349 		return	NULL ;
350 
351 	return	TQueue_GetData (pQueue) ;
352 }
353 
354 int
XIMInputContext_GetNumberOfSpooledPacket(register XIMInputContext * pThis)355 XIMInputContext_GetNumberOfSpooledPacket (
356 	register XIMInputContext*	pThis)
357 {
358 	return	TQueue_GetUsage (&pThis->m_quePacketSpool) ;
359 }
360 
361 Boolean
XIMInputContext_SetFocus(register XIMInputContext * pThis)362 XIMInputContext_SetFocus (
363 	register XIMInputContext*	pThis)
364 {
365 	if (pThis->m_preeditState == XIMPreeditDisable)
366 		return	False ;
367 
368 #if defined (DEBUG) || 0
369 	fprintf (stderr, "XIMInputContext_SetFocus (%p, %d)\n",
370 			 pThis, pThis->m_woID) ;
371 #endif
372 	/*	setfocus */
373 	pThis->m_fFocus	= True ;
374 	if (pThis->m_wgTopFrame != NULL)
375 		XIMInputContext_Activate (pThis, True) ;
376 	return	True ;
377 }
378 
379 Boolean
XIMInputContext_UnsetFocus(register XIMInputContext * pThis)380 XIMInputContext_UnsetFocus (
381 	register XIMInputContext*	pThis)
382 {
383 	if (pThis->m_preeditState == XIMPreeditDisable)
384 		return	False ;
385 
386 #if defined (DEBUG) || 0
387 	fprintf (stderr, "XIMInputContext_UnsetFocus (%p, %d)\n",
388 			 pThis, pThis->m_woID) ;
389 #endif
390 	/*	unsetfocus */
391 	pThis->m_fFocus	= False ;
392 	if (pThis->m_wgTopFrame != NULL)
393 		XIMInputContext_Activate (pThis, False) ;
394 	return	True ;
395 }
396 
397 Boolean
XIMInputContext_SetInputStyle(register XIMInputContext * pThis,register XIMStyle imstyle)398 XIMInputContext_SetInputStyle (
399 	register XIMInputContext*	pThis,
400 	register XIMStyle			imstyle)
401 {
402 #if defined (DEBUG) || 0
403 	fprintf (stderr, "XIMInputContext_SetInputStyle (%p, %ld)\n",
404 			 pThis, imstyle) ;
405 #endif
406 	pThis->m_dwInputStyle		= imstyle ;
407 	SET_CONVATTR_MASK (pThis->m_ConvAttr, CAInputStyle) ;
408 	return	True ;
409 }
410 
411 Boolean
XIMInputContext_SetClientWindow(register XIMInputContext * pThis,register Window wndClient)412 XIMInputContext_SetClientWindow (
413 	register XIMInputContext*	pThis,
414 	register Window				wndClient)
415 {
416 #if defined (DEBUG) || 0
417 	fprintf (stderr, "XIMInputContext_SetClientWindow (%p, %lx)\n",
418 			 pThis, wndClient) ;
419 #endif
420 	/*	client window �ϰ��٤�������Ǥ��ʤ���*/
421 	if (pThis->m_wndClient != None)
422 		return	False ;
423 	pThis->m_wndClient	= wndClient ;
424 	return	True ;
425 }
426 
427 Boolean
XIMInputContext_SetFocusWindow(register XIMInputContext * pThis,register Window wndFocus)428 XIMInputContext_SetFocusWindow (
429 	register XIMInputContext*	pThis,
430 	register Window				wndFocus)
431 {
432 #if defined (DEBUG) || 0
433 	fprintf (stderr, "XIMInputContext_SetFocusWindow (%p, %lx)\n",
434 			 pThis, wndFocus) ;
435 #endif
436 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAFocusWindow) ||
437 		pThis->m_ConvAttr.m_wndFocus != wndFocus) {
438 		pThis->m_ConvAttr.m_wndFocus	= wndFocus ;
439 
440 		if (pThis->m_wgTopFrame != NULL) {
441 			TConversionAttribute	ca ;
442 			TConvAttr_Initialize (&ca) ;
443 			SET_CONVATTR_MASK (ca, CAFocusWindow) ;
444 			ca.m_wndFocus	= wndFocus ;
445 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
446 			TConvAttr_Uninitialize (&ca) ;
447 		}
448 	}
449 	SET_CONVATTR_MASK (pThis->m_ConvAttr, CAFocusWindow) ;
450 	return	True ;
451 }
452 
453 Boolean
XIMInputContext_SetResetState(register XIMInputContext * pThis,register XIMResetState ulResetState)454 XIMInputContext_SetResetState (
455 	register XIMInputContext*	pThis,
456 	register XIMResetState		ulResetState)
457 {
458 	if (ulResetState != XIMInitialState && ulResetState != XIMPreserveState)
459 		return	False ;
460 	pThis->m_ulResetState	= ulResetState ;
461 	return	True ;
462 }
463 
464 Boolean
XIMInputContext_SetPreeditState(register XIMInputContext * pThis,register XIMPreeditState ulPreeditState)465 XIMInputContext_SetPreeditState (
466 	register XIMInputContext*	pThis,
467 	register XIMPreeditState	ulPreeditState)
468 {
469 	if (ulPreeditState != XIMPreeditEnable && ulPreeditState != XIMPreeditDisable)
470 		return	False ;
471 	if (ulPreeditState != pThis->m_preeditState) {
472 		Widget	wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
473 		if (ulPreeditState == XIMPreeditEnable) {
474 			XIMClient_ControlEventFlow (wgClient, pThis->m_pInputMethod, pThis, True) ;
475 			XIMInputContext_StartConversion (pThis) ;
476 		} else {
477 			XIMClient_ControlEventFlow (wgClient, pThis->m_pInputMethod, pThis, False) ;
478 			XIMInputContext_EndConversion (pThis) ;
479 		}
480 	}
481 	return	True ;
482 }
483 
484 XIMStyle
XIMInputContext_GetInputStyle(register XIMInputContext * pThis)485 XIMInputContext_GetInputStyle (
486 	register XIMInputContext*	pThis)
487 {
488 	return	pThis->m_dwInputStyle ;
489 }
490 
491 Window
XIMInputContext_GetClientWindow(register XIMInputContext * pThis)492 XIMInputContext_GetClientWindow (
493 	register XIMInputContext*	pThis)
494 {
495 	return	pThis->m_wndClient ;
496 }
497 
498 Window
XIMInputContext_GetFocusWindow(register XIMInputContext * pThis)499 XIMInputContext_GetFocusWindow (
500 	register XIMInputContext*	pThis)
501 {
502 	return	pThis->m_wndFocus ;
503 }
504 
505 CARD32
XIMInputContext_GetFilterEvents(register XIMInputContext * pThis)506 XIMInputContext_GetFilterEvents (
507 	register XIMInputContext*	pThis)
508 {
509 	return	pThis->m_dwFilterEvents ;
510 }
511 
512 XIMResetState
XIMInputContext_GetResetState(register XIMInputContext * pThis)513 XIMInputContext_GetResetState (
514 	register XIMInputContext*	pThis)
515 {
516 	return	pThis->m_ulResetState ;
517 }
518 
519 XIMPreeditState
XIMInputContext_GetPreeditState(register XIMInputContext * pThis)520 XIMInputContext_GetPreeditState (
521 	register XIMInputContext*	pThis)
522 {
523 	return	pThis->m_preeditState ;
524 }
525 
526 Boolean
XIMInputContext_SetPreeditArea(register XIMInputContext * pThis,register const XRectangle * pRect)527 XIMInputContext_SetPreeditArea (
528 	register XIMInputContext*	pThis,
529 	register const XRectangle*	pRect)
530 {
531 	TConversionAttribute	ca ;
532 
533 #if defined (DEBUG) || 0
534 	fprintf (stderr, "XIMInputContext[%d]: SetPreeditArea (%d, %d, %d, %d)\n",
535 			 pThis->m_woID,
536 			 pRect->x, pRect->y, pRect->width, pRect->height) ;
537 #endif
538 #if 1
539 	if (pRect->width <= 0 || pRect->height <= 0)
540 		return	False ;
541 #endif
542 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
543 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientArea) ||
544 		!IS_AREA_EQUAL (pThis->m_ConvAttr.m_Preedit.m_area, *pRect)) {
545 
546 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
547 		SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientArea) ;
548 		pThis->m_ConvAttr.m_Preedit.m_area	=  *pRect ;
549 
550 		if (pThis->m_wgTopFrame != NULL) {
551 			TConvAttr_Initialize (&ca) ;
552 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
553 			SET_CONVATTR_PREEDIT_MASK (ca, CAClientArea) ;
554 			ca.m_Preedit.m_area		=  *pRect ;
555 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
556 			TConvAttr_Uninitialize (&ca) ;
557 		}
558 	}
559 	return	True ;
560 }
561 
562 Boolean
XIMInputContext_SetPreeditAreaNeeded(register XIMInputContext * pThis,register const XRectangle * pRect)563 XIMInputContext_SetPreeditAreaNeeded (
564 	register XIMInputContext*	pThis,
565 	register const XRectangle*	pRect)
566 {
567 #if defined (DEBUG) || 0
568 	fprintf (stderr, "XIMInputContext_SetPreeditAreaNeeded (%p, %p)\n",
569 			 pThis, pRect) ;
570 #endif
571 	/*	ClientAreaNeeded ������ȡ�ClientArea �Υ�������
572 	 *	������ˤҤäѤ��롣
573 	 */
574 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
575 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientAreaNeeded) ||
576 		!IS_AREA_EQUAL (pThis->m_ConvAttr.m_Preedit.m_areaNeeded, *pRect)) {
577 
578 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
579 		SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientAreaNeeded) ;
580 		pThis->m_ConvAttr.m_Preedit.m_areaNeeded	= *pRect ;
581 	}
582 	return	True ;
583 }
584 
585 Boolean
XIMInputContext_SetSpotLocation(register XIMInputContext * pThis,register const XPoint * pPos)586 XIMInputContext_SetSpotLocation (
587 	register XIMInputContext*	pThis,
588 	register const XPoint*		pPos)
589 {
590 	register XPoint*	pCurPos ;
591 
592 #if defined (DEBUG) || 0
593 	fprintf (stderr, "XIMInputContext_SetSpotLocation (%p, %d, %d)\n",
594 			 pThis, pPos->x, pPos->y) ;
595 #endif
596 	pCurPos	= &pThis->m_ConvAttr.m_Preedit.m_spot ;
597 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
598 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CASpotLocation) ||
599 		pPos->x != pCurPos->x || pPos->y != pCurPos->y) {
600 		if (pThis->m_wgTopFrame != NULL) {
601 			TConversionAttribute	ca ;
602 
603 			TConvAttr_Initialize (&ca) ;
604 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
605 			SET_CONVATTR_PREEDIT_MASK (ca, CASpotLocation) ;
606 			memcpy (&ca.m_Preedit.m_spot, pPos, sizeof (XPoint)) ;
607 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
608 			TConvAttr_Uninitialize (&ca) ;
609 		}
610 		pCurPos->x	= pPos->x ;
611 		pCurPos->y	= pPos->y ;
612 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
613 		SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CASpotLocation) ;
614 	}
615 	return	True ;
616 }
617 
618 Boolean
XIMInputContext_SetPreeditColormap(register XIMInputContext * pThis,register Colormap colormap)619 XIMInputContext_SetPreeditColormap (
620 	register XIMInputContext*	pThis,
621 	register Colormap			colormap)
622 {
623 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
624 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAColormap) ||
625 		pThis->m_ConvAttr.m_Preedit.m_colormap != colormap) {
626 
627 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
628 		SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAColormap) ;
629 		pThis->m_ConvAttr.m_Preedit.m_colormap	= colormap ;
630 
631 		if (pThis->m_wgTopFrame) {
632 			TConversionAttribute	ca ;
633 
634 			TConvAttr_Initialize (&ca) ;
635 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
636 			SET_CONVATTR_PREEDIT_MASK (ca, CAColormap) ;
637 			ca.m_Preedit.m_colormap	= colormap ;
638 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
639 			TConvAttr_Uninitialize (&ca) ;
640 		}
641 	}
642 	return	True ;
643 }
644 
645 Boolean
XIMInputContext_SetPreeditStdColormap(register XIMInputContext * pThis,register Atom atStdColormap)646 XIMInputContext_SetPreeditStdColormap (
647 	register XIMInputContext*	pThis,
648 	register Atom				atStdColormap)
649 {
650 	register Widget		gw			= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
651 	register Display*	pDisplay	= XtDisplay (gw) ;
652 	register Window		wndFocus ;
653 	XStandardColormap*	pStdColormap ;
654 	int					nCount ;
655 
656 #if defined (DEBUG) || 0
657 	fprintf (stderr, "XIMInputContext_SetPreeditStdColormap (%p, %lx)\n",
658 					 pThis, atStdColormap) ;
659 #endif
660 
661 	if (atStdColormap == None)
662 		return	False ;
663 
664 	wndFocus	= pThis->m_wndClient ;
665 	if (IS_CONVATTR_MASK (pThis->m_ConvAttr, CAFocusWindow))
666 		wndFocus	= pThis->m_ConvAttr.m_wndFocus ;
667 	if (wndFocus == None)
668 		return	False ;
669 
670 	if (!XGetRGBColormaps (pDisplay, wndFocus, &pStdColormap, &nCount, atStdColormap))
671 		return	False ;
672 
673 	pThis->m_atPStdColormap	= atStdColormap ;
674 
675 	/*	ɸ��Ǥʤ� colormap ��������Ƥ��Ƥ���С�����ǽ�ʬ��*/
676 	if ((!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
677 		 !IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAColormap)) &&
678 		nCount > 0) {
679 		register Colormap	colormap	= pStdColormap->colormap ;
680 		pThis->m_ConvAttr.m_Preedit.m_colormap	= colormap ;
681 
682 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
683 		SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAColormap) ;
684 
685 		if (pThis->m_wgTopFrame) {
686 			TConversionAttribute	ca ;
687 
688 			TConvAttr_Initialize (&ca) ;
689 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
690 			SET_CONVATTR_PREEDIT_MASK (ca, CAColormap) ;
691 			ca.m_Preedit.m_colormap	= colormap ;
692 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
693 			TConvAttr_Uninitialize (&ca) ;
694 		}
695 	}
696 	return	True ;
697 }
698 
699 Boolean
XIMInputContext_SetPreeditForeground(register XIMInputContext * pThis,register unsigned long ulForeground)700 XIMInputContext_SetPreeditForeground (
701 	register XIMInputContext*	pThis,
702 	register unsigned long		ulForeground)
703 {
704 #if defined (DEBUG) || 0
705 	fprintf (stderr, "XIMInputContext_SetPreeditForeground (%p, %lx)\n",
706 			 pThis, ulForeground) ;
707 #endif
708 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
709 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAForegroundPixel) ||
710 		pThis->m_ConvAttr.m_Preedit.m_foreground != ulForeground) {
711 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
712 		SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAForegroundPixel) ;
713 		pThis->m_ConvAttr.m_Preedit.m_foreground	= ulForeground ;
714 		if (pThis->m_wgTopFrame != NULL) {
715 			TConversionAttribute	ca ;
716 
717 			TConvAttr_Initialize (&ca) ;
718 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
719 			SET_CONVATTR_PREEDIT_MASK (ca, CAForegroundPixel) ;
720 			ca.m_Preedit.m_foreground	= ulForeground ;
721 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
722 			TConvAttr_Uninitialize (&ca) ;
723 		}
724 	}
725 	return	True ;
726 }
727 
728 Boolean
XIMInputContext_SetPreeditBackground(register XIMInputContext * pThis,register unsigned long ulBackground)729 XIMInputContext_SetPreeditBackground (
730 	register XIMInputContext*	pThis,
731 	register unsigned long		ulBackground)
732 {
733 #if defined (DEBUG) || 0
734 	fprintf (stderr, "XIMInputContext_SetPreeditBackground (%p, %lx)\n",
735 			 pThis, ulBackground) ;
736 #endif
737 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
738 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CABackgroundPixel) ||
739 		pThis->m_ConvAttr.m_Preedit.m_background != ulBackground) {
740 
741 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
742 		SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CABackgroundPixel) ;
743 		pThis->m_ConvAttr.m_Preedit.m_background	= ulBackground ;
744 
745 		if (pThis->m_wgTopFrame != NULL) {
746 			TConversionAttribute	ca ;
747 
748 			TConvAttr_Initialize (&ca) ;
749 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
750 			SET_CONVATTR_PREEDIT_MASK (ca, CABackgroundPixel) ;
751 			ca.m_Preedit.m_background	= ulBackground ;
752 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
753 			TConvAttr_Uninitialize (&ca) ;
754 		}
755 	}
756 	return	True ;
757 }
758 
759 Boolean
XIMInputContext_SetPreeditBackgroundPixmap(register XIMInputContext * pThis,register Pixmap pixmap)760 XIMInputContext_SetPreeditBackgroundPixmap (
761 	register XIMInputContext*	pThis,
762 	register Pixmap				pixmap)
763 {
764 	return	True ;
765 }
766 
767 Boolean
XIMInputContext_SetPreeditFontSet(register XIMInputContext * pThis,register const char * pBaseName,register int nBaseNameLength)768 XIMInputContext_SetPreeditFontSet (
769 	register XIMInputContext*	pThis,
770 	register const char*		pBaseName,
771 	register int				nBaseNameLength)
772 {
773 	register const char*	pPFontSetName ;
774 	register int			nPFontSetName ;
775 
776 	pPFontSetName	= TVarbuffer_GetBuffer (&pThis->m_vbufPFontSetName) ;
777 	nPFontSetName	= TVarbuffer_GetUsage  (&pThis->m_vbufPFontSetName) - 1 ;
778 
779 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
780 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAFont) ||
781 		nPFontSetName != nBaseNameLength ||
782 		strncmp (pPFontSetName, pBaseName, nPFontSetName) != 0) {
783 		register Display*		pDisplay ;
784 		register Widget			wgClient ;
785 		register const char*	pFontSetName ;
786 		register TConversionAttribute*	pCA ;
787 
788 		/*	�ե���Ȥ��ѹ���ɬ�פ����롣*/
789 		TVarbuffer_Clear (&pThis->m_vbufPFontSetName) ;
790 		TVarbuffer_Add (&pThis->m_vbufPFontSetName, pBaseName, nBaseNameLength) ;
791 		TVarbuffer_Add (&pThis->m_vbufPFontSetName, "\0", 1) ;
792 
793 		pFontSetName	= TVarbuffer_GetBuffer (&pThis->m_vbufPFontSetName) ;
794 		assert (pThis->m_pInputMethod != NULL) ;
795 		wgClient		= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
796 		assert (wgClient != NULL) ;
797 		pDisplay		= XtDisplay (wgClient) ;
798 		pCA				= &pThis->m_ConvAttr ;
799 #if defined (DEBUG) || 0
800 		fprintf (stderr, "PreeditFontSet => \"%s\"\n", pFontSetName) ;
801 #endif
802 		TFontSet_Load (pDisplay, &pCA->m_Preedit.m_FontSet, pFontSetName, False) ;
803 
804 		if (pThis->m_wgTopFrame != NULL) {
805 			TConversionAttribute	ca ;
806 
807 			TConvAttr_Initialize (&ca) ;
808 			SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
809 			SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAFont) ;
810 			TFontSet_Copy (&ca.m_Preedit.m_FontSet, &pCA->m_Preedit.m_FontSet) ;
811 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
812 			SET_CONVATTR_PREEDIT_MASK (ca, CAFont) ;
813 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
814 			TConvAttr_Uninitialize (&ca) ;
815 		}
816 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
817 		SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAFont) ;
818 
819 		/*	�ե���Ȥ��ѹ������� line-spacing �ξ����̵���ˤʤ롣*/
820 		UNSET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CALineSpacing) ;
821 	}
822 	return	True ;
823 }
824 
825 Boolean
XIMInputContext_SetPreeditLineSpacing(register XIMInputContext * pThis,register int nLineSpacing)826 XIMInputContext_SetPreeditLineSpacing (
827 	register XIMInputContext*	pThis,
828 	register int 				nLineSpacing)
829 {
830 #if defined (DEBUG) || 0
831 	fprintf (stderr, "XIMInputContext_SetPreeditLineSpacing (%p, %d)\n",
832 			 pThis, nLineSpacing) ;
833 #endif
834 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
835 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CALineSpacing) ||
836 		pThis->m_ConvAttr.m_Preedit.m_nLineSpacing != nLineSpacing) {
837 
838 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ;
839 		SET_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CALineSpacing) ;
840 		pThis->m_ConvAttr.m_Preedit.m_nLineSpacing	= nLineSpacing ;
841 
842 		if (pThis->m_wgTopFrame != NULL) {
843 			TConversionAttribute	ca ;
844 
845 			TConvAttr_Initialize (&ca) ;
846 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
847 			SET_CONVATTR_PREEDIT_MASK (ca, CALineSpacing) ;
848 			ca.m_Preedit.m_nLineSpacing	= nLineSpacing ;
849 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
850 			TConvAttr_Uninitialize (&ca) ;
851 		}
852 	}
853 	return	True ;
854 }
855 
856 /*
857  *(�ؿ�̾)
858  *	virtual Boolean
859 XIMInputContext_SetPreeditCursor (Cursor cursor) ;
860  *(������)
861  *	Preedit Area �Υ�����������ꤹ�롣
862  */
863 Boolean
XIMInputContext_SetPreeditCursor(register XIMInputContext * pThis,register Cursor cursor)864 XIMInputContext_SetPreeditCursor (
865 	register XIMInputContext*	pThis,
866 	register Cursor				cursor)
867 {
868 	return	False ;
869 }
870 
871 /*
872  *(�ؿ�̾)
873  *	virtual bool	GetPreeditArea (XRectangle* pArea) const ;
874  *(������)
875  *	Preedt Area ���礭�����֤���
876  *	��Client Window ���ꥵ������ȯ�Ԥ��Ƥ���ʤ��� Preedit Area
877  *	�θ��ߤ��礭�������������Ĥ��ȤϤǤ��ʤ���
878  *	�������Ĥɤ���褹�٤�����(���⤽��ꥵ������������ä�ñ��
879  *	���ΰ���������ʤ����⤢�������)
880  */
881 Boolean
XIMInputContext_GetPreeditArea(register XIMInputContext * pThis,register XRectangle * pRect)882 XIMInputContext_GetPreeditArea (
883 	register XIMInputContext*	pThis,
884 	register XRectangle*		pRect)
885 {
886 	assert (pThis != NULL) ;
887 	assert (pRect != NULL) ;
888 
889 	/*
890 	 *	PreeditArea ������ʤ��ΤǤ���С�ɬ�פ��ΰ���֤�ɬ�פϤʤ���
891 	 */
892 	if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditNothing)
893 		return	True ;
894 
895 	if (IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) &&
896 		IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientArea)) {
897 		/*	����ɽ���ΰ褬���ꤵ��Ƥ��롣*/
898 		memcpy (pRect, &pThis->m_ConvAttr.m_Preedit.m_area, sizeof (XRectangle)) ;
899 	} else {
900 		if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditPosition){
901 			register Display*	pDisplay ;
902 			register Window		wndFocus ;
903 
904 			/*
905 			 *	ɽ���ΰ褬���ꤵ�줿���Ȥ��ʤ���
906 			 *		����
907 			 *	ɽ����ɬ�פ��ΰ������⤵�줿���Ȥ��ʤ�
908 			 *
909 			 *	�ޤ���PreeditPosition �Τ���� AreaNeeded �����ꤵ��Ƥ����
910 			 *	�����櫓�ǤϤʤ���(PreeditArea �ʤ� AreaNeeded �����ꤵ��Ƥ�
911 			 *	��ɬ�פ�����)
912 			 *
913 			 *	�����������ˤϡ�Focus ���Ƥ��� Window ���ΰ��Ȥ뤳�Ȥˤ��롣
914 			 */
915 			wndFocus	= (pThis->m_wndFocus == None)? pThis->m_wndClient : pThis->m_wndFocus ;
916 			if (wndFocus != None){
917 				register Widget	wgClient ;
918 				Window			wndRoot ;
919 				int				iX, iY ;
920 				unsigned int	iWidth, iHeight, iBorder, iDepth ;
921 
922 				wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
923 				pDisplay	= XtDisplay (wgClient) ;
924 				XGetGeometry (pDisplay, wndFocus, &wndRoot, &iX, &iY, &iWidth, &iHeight, &iBorder, &iDepth) ;
925 				pRect->x		= 0 ;
926 				pRect->y		= 0 ;
927 				pRect->width	= iWidth ;
928 				pRect->height	= iHeight ;
929 			} else {
930 				/*	Focus, Client Window ��ʤ������� Area �����Ҥͤ��Ƥ��ޤä��ġ�*/
931 				return	False ;
932 			}
933 		} else {
934 			/*
935 			 *	���餯�� PreeditArea (�Ĥޤ� Preedit �ΰ�� Area ����ɬ�פ�
936 			 *	����)�ʤΤǡ�AreaNeeded �����ꤵ��Ƥ��롣
937 			 *	���ξ��ˤ� AreaNeeded ʬ�������ݤ��줿��ΤȤ�������Τ�Ȥ�
938 			 *	�ͤ��֤���
939 			 */
940 			if (IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) &&
941 				IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientAreaNeeded)) {
942 				memcpy (pRect, &pThis->m_ConvAttr.m_Preedit.m_areaNeeded, sizeof (XRectangle)) ;
943 			} else {
944 				XIMInputContext_GetPreeditAreaNeeded (pThis, pRect) ;
945 			}
946 		}
947 	}
948 	return	True ;
949 }
950 
951 /*
952  *(�ؿ�̾)
953  *	virtual bool	GetPreeditAreaNeeded (XRectangle* pArea) const ;
954  *(������)
955  *	ɬ�פȤ��� Preedit Area ���礭���������֤��ʤ���Фʤ�ʤ���
956  *	�ɤ����٤ο��ͤ������ʤΤ��������ġ�
957  *	�ޤ��������ͤ�����Ƥ��ޤ��٤��ʤΤ��Ĥ���Ȥ⤳�������ɬ�פ�
958  *	�����Ǿ��ͤ�����Ƥ��ޤ��٤��ʤΤ��ġ�
959  */
960 Boolean
XIMInputContext_GetPreeditAreaNeeded(register XIMInputContext * pThis,register XRectangle * pRect)961 XIMInputContext_GetPreeditAreaNeeded (
962 	register XIMInputContext*	pThis,
963 	register XRectangle*		pRect)
964 {
965 	assert (pThis != NULL) ;
966 	assert (pRect != NULL) ;
967 
968 	/*
969 	 *	RootWindowStyle �ʤ�� PreeditArea ��¸�ߤ��ʤ��Τǡ�AreaNeeded
970 	 *	���֤����ȤϤǤ��ʤ���
971 	 */
972 	if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditNothing)
973 		return	True ;
974 
975 	/*
976 	 *	ɬ�פȤ����ΰ��ɤ��ˤ����ꤹ�롣
977 	 */
978 	if (IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) &&
979 		IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientAreaNeeded)) {
980 		/*
981 		 *	����ɬ�פ��ΰ褬�׻�����Ƥ���
982 		 *		���뤤��
983 		 *	����ɬ�פ��ΰ褬���饤����Ȥ������ꤵ��Ƥ���
984 		 *	���ˤϡ����ο�����Ȥ���
985 		 */
986 		memcpy (pRect, &pThis->m_ConvAttr.m_Preedit.m_areaNeeded, sizeof (XRectangle)) ;
987 	} else {
988 		/*
989 		 *	ɬ�פ��ΰ襵�����Ϸ׻�����Ƥ��餺�����ο��ͤϥ�����Ǥ���ȤʤäƤ��롣
990 		 */
991 		if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditArea){
992 			register int	nLineSpacing ;
993 			/*
994 			 *	PreeditArea ���礭��������ǻ��ꤹ��ɬ�פ������
995 			 *		�⤷����
996 			 *	ɬ�פ��礭���������������������
997 			 *	���ơ��ɤ������׵᤹��٤��ʤΤ���
998 			 */
999 			nLineSpacing	= XIMInputContext_GetPreeditLineSpacing (pThis) ;
1000 			if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusArea &&
1001 				IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) &&
1002 				IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAClientAreaNeeded)) {
1003 				pRect->x		= 0 ;
1004 				pRect->y		= 0 ;
1005 				pRect->width	= pThis->m_ConvAttr.m_Status.m_areaNeeded.width ;
1006 				pRect->height	= nLineSpacing ;
1007 			} else {
1008 				pRect->x		= 0 ;
1009 				pRect->y		= 0 ;
1010 				pRect->width	= nLineSpacing * 20 ;
1011 				pRect->height	= nLineSpacing * 20 ;
1012 			}
1013 		} else {
1014 			/*
1015 			 *	OverTheSpot Style �ξ��ˤ����ꤷ�ʤ��ġ�
1016 			 *	�ɤ���顢�������׵᤬��뤳�ȤϤʤ�������
1017 			 */
1018 			register Window		wndFocus ;
1019 			wndFocus	= (pThis->m_wndFocus == None)? pThis->m_wndClient : pThis->m_wndFocus ;
1020 			if (wndFocus != None){
1021 				register Display*	pDisplay ;
1022 				register Widget		wgClient ;
1023 				Window			wndRoot ;
1024 				int				iX, iY ;
1025 				unsigned int	iWidth, iHeight, iBorder, iDepth ;
1026 
1027 				wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
1028 				pDisplay	= XtDisplay (wgClient) ;
1029 				XGetGeometry (pDisplay, wndFocus, &wndRoot, &iX, &iY, &iWidth, &iHeight, &iBorder, &iDepth) ;
1030 				pRect->x		= 0 ;
1031 				pRect->y		= 0 ;
1032 				pRect->width	= iWidth ;
1033 				pRect->height	= iHeight ;
1034 			} else {
1035 				//	Focus, Client Window ��ʤ������� Area �����Ҥͤ��Ƥ��ޤä��ġ�
1036 				return	False ;
1037 			}
1038 		}
1039 	}
1040 	return	True ;
1041 }
1042 
1043 /*
1044  *(�ؿ�̾)
1045  *	virtual const XPoint	GetSpotLocation () const ;
1046  *(������)
1047  *	���ߤ� Composition Window �ΰ��֤��֤���
1048  *	���� Attribute �� Status �ˤϤʤ���
1049  */
1050 Boolean
XIMInputContext_GetSpotLocation(register XIMInputContext * pThis,register XPoint * pPos)1051 XIMInputContext_GetSpotLocation (
1052 	register XIMInputContext*	pThis,
1053 	register XPoint*			pPos)
1054 {
1055 	assert (pThis != NULL) ;
1056 	assert (pPos  != NULL) ;
1057 	/*
1058 	 *	UIWindow ���� Text �� Position �����롣
1059 	 *	��������RootWindowStyle �ξ��ˤ� SpotLocation �ϰ�̣������ʤ���
1060 	 *	XIMStyle & XIMPreeditPosition ���ä����ˤϸ��̤�����Ȥ����Ȥ�����
1061 	 */
1062 	if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditPosition &&
1063 		IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) &&
1064 		IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CASpotLocation)) {
1065 		register XPoint*	pCurPos	= &pThis->m_ConvAttr.m_Preedit.m_spot ;
1066 		pPos->x	= pCurPos->x ;
1067 		pPos->y	= pCurPos->y ;
1068 	} else {
1069 		pPos->x	= 0 ;
1070 		pPos->y	= 0 ;
1071 	}
1072 	return	True ;
1073 }
1074 
1075 /*
1076  *(�ؿ�̾)
1077  *	virtual const Colormap&	GetPreeditColormap () const ;
1078  *(������)
1079  *	PreeditArea �θ��ߤ� Colormap �����롣
1080  *	�ǥե���Ȥ������Τ��Ȥʤ��顢
1081  *		DefaultColormap (display, 0)
1082  *	��ȤäƤ��롣
1083  */
1084 Colormap
XIMInputContext_GetPreeditColormap(register XIMInputContext * pThis)1085 XIMInputContext_GetPreeditColormap (
1086 	register XIMInputContext*	pThis)
1087 {
1088 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
1089 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAColormap))
1090 		return	None ;
1091 	return	pThis->m_ConvAttr.m_Preedit.m_colormap ;
1092 }
1093 
1094 /*
1095  *(�ؿ�̾)
1096  *	virtual const Colormap&	GetPreeditColormap () const ;
1097  *(������)
1098  *	PreeditArea �� Standard Colormap �����롣
1099  *	�ǥե���Ȥ������Τ��Ȥʤ��顢
1100  *		DefaultColormap (display, 0)
1101  *	��ȤäƤ��롣
1102  */
1103 Atom
XIMInputContext_GetPreeditStdColormap(register XIMInputContext * pThis)1104 XIMInputContext_GetPreeditStdColormap (
1105 	register XIMInputContext*	pThis)
1106 {
1107 	return	pThis->m_atPStdColormap ;
1108 }
1109 
1110 unsigned long
XIMInputContext_GetPreeditForeground(register XIMInputContext * pThis)1111 XIMInputContext_GetPreeditForeground (
1112 	register XIMInputContext*	pThis)
1113 {
1114 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
1115 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAForegroundPixel)) {
1116 		/* What to do? */
1117 	}
1118 	return	pThis->m_ConvAttr.m_Preedit.m_foreground ;
1119 }
1120 
1121 unsigned long
XIMInputContext_GetPreeditBackground(register XIMInputContext * pThis)1122 XIMInputContext_GetPreeditBackground (
1123 	register XIMInputContext*	pThis)
1124 {
1125 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
1126 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CABackgroundPixel)) {
1127 		/* What to do? */
1128 	}
1129 	return	pThis->m_ConvAttr.m_Preedit.m_background ;
1130 }
1131 
1132 Pixmap
XIMInputContext_GetPreeditBackgroundPixmap(register XIMInputContext * pThis)1133 XIMInputContext_GetPreeditBackgroundPixmap (
1134 	register XIMInputContext*	pThis)
1135 {
1136 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
1137 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CABackgroundPixmap)) {
1138 		/* What to do? */
1139 	}
1140 	return	pThis->m_ConvAttr.m_Preedit.m_pixBackground ;
1141 }
1142 
1143 const char*
XIMInputContext_GetPreeditFontSet(register XIMInputContext * pThis)1144 XIMInputContext_GetPreeditFontSet (
1145 	register XIMInputContext*	pThis)
1146 {
1147 	return	TVarbuffer_GetBuffer (&pThis->m_vbufPFontSetName) ;
1148 }
1149 
1150 int
XIMInputContext_GetPreeditLineSpacing(register XIMInputContext * pThis)1151 XIMInputContext_GetPreeditLineSpacing (
1152 	register XIMInputContext*	pThis)
1153 {
1154 	assert (pThis != NULL) ;
1155 
1156 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask))
1157 		return	DEFAULT_XIM_PREEDIT_LINESPACING ;
1158 
1159 	if (IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CALineSpacing))
1160 		return	pThis->m_ConvAttr.m_Preedit.m_nLineSpacing ;
1161 
1162 	if (!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAFont))
1163 		return	DEFAULT_XIM_PREEDIT_LINESPACING ;
1164 
1165 	return	TFontSet_GetHeight (&pThis->m_ConvAttr.m_Preedit.m_FontSet) ;
1166 }
1167 
1168 Cursor
XIMInputContext_GetPreeditCursor(register XIMInputContext * pThis)1169 XIMInputContext_GetPreeditCursor (
1170 	register XIMInputContext*	pThis)
1171 {
1172 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) ||
1173 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CACursor)) {
1174 	}
1175 	return	pThis->m_ConvAttr.m_Preedit.m_cursor ;
1176 }
1177 
1178 /*
1179  *	Status ¦�� Interface
1180  */
1181 Boolean
XIMInputContext_SetStatusArea(register XIMInputContext * pThis,register const XRectangle * pRect)1182 XIMInputContext_SetStatusArea (
1183 	register XIMInputContext*	pThis,
1184 	register const XRectangle*	pRect)
1185 {
1186 	TConversionAttribute	ca ;
1187 
1188 #if defined (DEBUG)
1189 	fprintf (stderr, "XIMInputContext[%d]: SetStatusArea (%d, %d, %d, %d)\n",
1190 			 pThis->m_woID,
1191 			 pRect->x, pRect->y, pRect->width, pRect->height) ;
1192 #endif
1193 
1194 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ||
1195 		!IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAClientArea) ||
1196 		!IS_AREA_EQUAL (pThis->m_ConvAttr.m_Status.m_area, *pRect)) {
1197 
1198 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ;
1199 		SET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAClientArea) ;
1200 		pThis->m_ConvAttr.m_Status.m_area	=  *pRect ;
1201 
1202 		if (pThis->m_wgTopFrame != NULL) {
1203 			TConvAttr_Initialize (&ca) ;
1204 			SET_CONVATTR_MASK (ca, CAStatusMask) ;
1205 			SET_CONVATTR_STATUS_MASK (ca, CAClientArea) ;
1206 			ca.m_Status.m_area		=  *pRect ;
1207 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
1208 			TConvAttr_Uninitialize (&ca) ;
1209 		}
1210 	}
1211 	return	True ;
1212 }
1213 
1214 Boolean
XIMInputContext_SetStatusAreaNeeded(register XIMInputContext * pThis,register const XRectangle * pRect)1215 XIMInputContext_SetStatusAreaNeeded (
1216 	register XIMInputContext*	pThis,
1217 	register const XRectangle*	pRect)
1218 {
1219 	/*	ClientAreaNeeded ������ȡ�ClientArea �Υ�������
1220 	 *	������ˤҤäѤ��롣
1221 	 */
1222 #if defined (DEBUG)
1223 	fprintf (stderr, "XIMInputContext[%d]: SetStatusAreaNeeded (%d, %d, %d, %d)\n",
1224 			 pThis->m_woID,
1225 			 pRect->x, pRect->y, pRect->width, pRect->height) ;
1226 #endif
1227 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ||
1228 		!IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAClientAreaNeeded) ||
1229 		!IS_AREA_EQUAL (pThis->m_ConvAttr.m_Status.m_areaNeeded, *pRect)) {
1230 
1231 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ;
1232 		SET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAClientAreaNeeded) ;
1233 		pThis->m_ConvAttr.m_Status.m_areaNeeded	= *pRect ;
1234 	}
1235 	return	True ;
1236 }
1237 
1238 Boolean
XIMInputContext_SetStatusColormap(register XIMInputContext * pThis,register Colormap colormap)1239 XIMInputContext_SetStatusColormap (
1240 	register XIMInputContext*	pThis,
1241 	register Colormap			colormap)
1242 {
1243 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ||
1244 		!IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAColormap) ||
1245 		pThis->m_ConvAttr.m_Status.m_colormap != colormap) {
1246 		TConversionAttribute	ca ;
1247 
1248 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ;
1249 		SET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAColormap) ;
1250 		pThis->m_ConvAttr.m_Status.m_colormap	= colormap ;
1251 
1252 		if (pThis->m_wgTopFrame) {
1253 			TConvAttr_Initialize (&ca) ;
1254 			SET_CONVATTR_MASK (ca, CAStatusMask) ;
1255 			SET_CONVATTR_STATUS_MASK (ca, CAColormap) ;
1256 			ca.m_Status.m_colormap	= colormap ;
1257 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
1258 			TConvAttr_Uninitialize (&ca) ;
1259 		}
1260 		if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusArea &&
1261 			pThis->m_wgTopMinibufFrame != NULL &&
1262 			pThis->m_wgTopFrame != pThis->m_wgTopMinibufFrame) {
1263 			TConvAttr_Initialize (&ca) ;
1264 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
1265 			SET_CONVATTR_PREEDIT_MASK (ca, CAColormap) ;
1266 			ca.m_Preedit.m_colormap	= colormap ;
1267 			TFrame_SetAttribute (pThis->m_wgTopMinibufFrame, &ca) ;
1268 			TConvAttr_Uninitialize (&ca) ;
1269 		}
1270 	}
1271 	return	True ;
1272 }
1273 
1274 Boolean
XIMInputContext_SetStatusStdColormap(register XIMInputContext * pThis,register Atom atStdColormap)1275 XIMInputContext_SetStatusStdColormap (
1276 	register XIMInputContext*	pThis,
1277 	register Atom				atStdColormap)
1278 {
1279 	register Widget		gw			= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
1280 	register Display*	pDisplay	= XtDisplay (gw) ;
1281 	register Window		wndFocus ;
1282 	XStandardColormap*	pStdColormap ;
1283 	int					nCount ;
1284 
1285 #if defined (DEBUG) || 0
1286 	fprintf (stderr, "XIMInputContext_SetStatusStdColormap (%p, %lx)\n",
1287 					 pThis, atStdColormap) ;
1288 #endif
1289 
1290 	if (atStdColormap == None)
1291 		return	False ;
1292 
1293 	wndFocus	= pThis->m_wndClient ;
1294 	if (IS_CONVATTR_MASK (pThis->m_ConvAttr, CAFocusWindow))
1295 		wndFocus	= pThis->m_ConvAttr.m_wndFocus ;
1296 	if (wndFocus == None)
1297 		return	False ;
1298 
1299 	if (!XGetRGBColormaps (pDisplay, wndFocus, &pStdColormap, &nCount, atStdColormap))
1300 		return	False ;
1301 
1302 	pThis->m_atSStdColormap	= atStdColormap ;
1303 
1304 	/*	ɸ��Ǥʤ� colormap ��������Ƥ��Ƥ���С�����ǽ�ʬ��*/
1305 	if ((!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ||
1306 		 !IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAColormap)) &&
1307 		nCount > 0) {
1308 		register Colormap	colormap	= pStdColormap->colormap ;
1309 		pThis->m_ConvAttr.m_Status.m_colormap	= colormap ;
1310 
1311 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ;
1312 		SET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAColormap) ;
1313 
1314 		if (pThis->m_wgTopFrame) {
1315 			TConversionAttribute	ca ;
1316 
1317 			TConvAttr_Initialize (&ca) ;
1318 			SET_CONVATTR_MASK (ca, CAStatusMask) ;
1319 			SET_CONVATTR_STATUS_MASK (ca, CAColormap) ;
1320 			ca.m_Status.m_colormap	= colormap ;
1321 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
1322 			TConvAttr_Uninitialize (&ca) ;
1323 		}
1324 	}
1325 	return	True ;
1326 }
1327 
1328 Boolean
XIMInputContext_SetStatusForeground(register XIMInputContext * pThis,register unsigned long ulForeground)1329 XIMInputContext_SetStatusForeground (
1330 	register XIMInputContext*	pThis,
1331 	register unsigned long		ulForeground)
1332 {
1333 	assert (pThis != NULL) ;
1334 
1335 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ||
1336 		!IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAForegroundPixel) ||
1337 		pThis->m_ConvAttr.m_Status.m_foreground != ulForeground) {
1338 		TConversionAttribute	ca ;
1339 
1340 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ;
1341 		SET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAForegroundPixel) ;
1342 		pThis->m_ConvAttr.m_Status.m_foreground	= ulForeground ;
1343 
1344 		if (pThis->m_wgTopFrame != NULL) {
1345 			TConvAttr_Initialize (&ca) ;
1346 			SET_CONVATTR_MASK (ca, CAStatusMask) ;
1347 			SET_CONVATTR_STATUS_MASK (ca, CAForegroundPixel) ;
1348 			ca.m_Status.m_foreground	= ulForeground ;
1349 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
1350 			TConvAttr_Uninitialize (&ca) ;
1351 		}
1352 		if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusArea &&
1353 			pThis->m_wgTopMinibufFrame != NULL &&
1354 			pThis->m_wgTopFrame != pThis->m_wgTopMinibufFrame) {
1355 			TConvAttr_Initialize (&ca) ;
1356 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
1357 			SET_CONVATTR_PREEDIT_MASK (ca, CAForegroundPixel) ;
1358 			ca.m_Preedit.m_foreground	= ulForeground ;
1359 			TFrame_SetAttribute (pThis->m_wgTopMinibufFrame, &ca) ;
1360 			TConvAttr_Uninitialize (&ca) ;
1361 		}
1362 	}
1363 	return	True ;
1364 }
1365 
1366 Boolean
XIMInputContext_SetStatusBackground(register XIMInputContext * pThis,register unsigned long ulBackground)1367 XIMInputContext_SetStatusBackground (
1368 	register XIMInputContext*	pThis,
1369 	register unsigned long		ulBackground)
1370 {
1371 	assert (pThis != NULL) ;
1372 
1373 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ||
1374 		!IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CABackgroundPixel) ||
1375 		pThis->m_ConvAttr.m_Status.m_background != ulBackground) {
1376 		TConversionAttribute	ca ;
1377 
1378 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ;
1379 		SET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CABackgroundPixel) ;
1380 		pThis->m_ConvAttr.m_Status.m_background	= ulBackground ;
1381 
1382 		if (pThis->m_wgTopFrame != NULL) {
1383 			TConvAttr_Initialize (&ca) ;
1384 			SET_CONVATTR_MASK (ca, CAStatusMask) ;
1385 			SET_CONVATTR_STATUS_MASK (ca, CABackgroundPixel) ;
1386 			ca.m_Status.m_background	= ulBackground ;
1387 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
1388 			TConvAttr_Uninitialize (&ca) ;
1389 		}
1390 		if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusArea &&
1391 			pThis->m_wgTopMinibufFrame != NULL &&
1392 			pThis->m_wgTopFrame != pThis->m_wgTopMinibufFrame) {
1393 			TConvAttr_Initialize (&ca) ;
1394 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
1395 			SET_CONVATTR_PREEDIT_MASK (ca, CABackgroundPixel) ;
1396 			ca.m_Preedit.m_background	= ulBackground ;
1397 			TFrame_SetAttribute (pThis->m_wgTopMinibufFrame, &ca) ;
1398 			TConvAttr_Uninitialize (&ca) ;
1399 		}
1400 	}
1401 	return	True ;
1402 }
1403 
1404 Boolean
XIMInputContext_SetStatusBackgroundPixmap(register XIMInputContext * pThis,register Pixmap pixmap)1405 XIMInputContext_SetStatusBackgroundPixmap (
1406 	register XIMInputContext*	pThis,
1407 	register Pixmap				pixmap)
1408 {
1409 	assert (pThis != NULL) ;
1410 	return	True ;
1411 }
1412 
1413 /*	Status �ΰ�Ϻ��ϲ��⤷�Ƥ��ʤ��Τ�������Բ�ǽ��
1414  */
1415 Boolean
XIMInputContext_SetStatusFontSet(register XIMInputContext * pThis,register const char * pBaseName,register int nBaseNameLength)1416 XIMInputContext_SetStatusFontSet (
1417 	register XIMInputContext*	pThis,
1418 	register const char*		pBaseName,
1419 	register int				nBaseNameLength)
1420 {
1421 	register const char*	pSFontSetName ;
1422 	register int			nSFontSetName ;
1423 
1424 	pSFontSetName	= TVarbuffer_GetBuffer (&pThis->m_vbufSFontSetName) ;
1425 	nSFontSetName	= TVarbuffer_GetUsage  (&pThis->m_vbufSFontSetName) - 1 ;
1426 
1427 	assert (pThis != NULL) ;
1428 
1429 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ||
1430 		!IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAFont) ||
1431 		nSFontSetName != nBaseNameLength ||
1432 		strncmp (pSFontSetName, pBaseName, nSFontSetName) != 0) {
1433 		register Display*		pDisplay ;
1434 		register Widget			wgClient ;
1435 		register const char*	pFontSetName ;
1436 		register TConversionAttribute*	pCA ;
1437 		TConversionAttribute	ca ;
1438 
1439 		/*	�ե���Ȥ��ѹ���ɬ�פ����롣*/
1440 		TVarbuffer_Clear (&pThis->m_vbufSFontSetName) ;
1441 		TVarbuffer_Add (&pThis->m_vbufSFontSetName, pBaseName, nBaseNameLength) ;
1442 		TVarbuffer_Add (&pThis->m_vbufSFontSetName, "\0", 1) ;
1443 
1444 		pFontSetName	= TVarbuffer_GetBuffer (&pThis->m_vbufSFontSetName) ;
1445 		assert (pThis->m_pInputMethod != NULL) ;
1446 		wgClient		= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
1447 		assert (wgClient != NULL) ;
1448 		pDisplay		= XtDisplay (wgClient) ;
1449 		pCA				= &pThis->m_ConvAttr ;
1450 #if defined (DEBUG) || 0
1451 		fprintf (stderr, "StatusFontSet => \"%s\"\n", pFontSetName) ;
1452 #endif
1453 		TFontSet_Load (pDisplay, &pCA->m_Status.m_FontSet, pFontSetName, False) ;
1454 
1455 		if (pThis->m_wgTopFrame != NULL) {
1456 			TConvAttr_Initialize (&ca) ;
1457 			SET_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ;
1458 			SET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAFont) ;
1459 			TFontSet_Copy (&ca.m_Status.m_FontSet, &pCA->m_Status.m_FontSet) ;
1460 			TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
1461 			TConvAttr_Uninitialize (&ca) ;
1462 		}
1463 		if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusArea &&
1464 			pThis->m_wgTopMinibufFrame != NULL &&
1465 			pThis->m_wgTopFrame != pThis->m_wgTopMinibufFrame) {
1466 			TConvAttr_Initialize (&ca) ;
1467 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
1468 			SET_CONVATTR_PREEDIT_MASK (ca, CAFont) ;
1469 			TFontSet_Copy (&ca.m_Preedit.m_FontSet, &pCA->m_Status.m_FontSet) ;
1470 			TFrame_SetAttribute (pThis->m_wgTopMinibufFrame, &ca) ;
1471 			TConvAttr_Uninitialize (&ca) ;
1472 		}
1473 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ;
1474 		SET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAFont) ;
1475 
1476 		/*	�ե���Ȥ��ѹ������� line-spacing �ξ����̵���ˤʤ롣*/
1477 		UNSET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CALineSpacing) ;
1478 	}
1479 	return	True ;
1480 }
1481 
1482 Boolean
XIMInputContext_SetStatusLineSpacing(register XIMInputContext * pThis,register int nLineSpacing)1483 XIMInputContext_SetStatusLineSpacing (
1484 	register XIMInputContext*	pThis,
1485 	register int				nLineSpacing)
1486 {
1487 	assert (pThis != NULL) ;
1488 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ||
1489 		!IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CALineSpacing) ||
1490 		pThis->m_ConvAttr.m_Status.m_nLineSpacing != nLineSpacing) {
1491 
1492 		SET_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ;
1493 		SET_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CALineSpacing) ;
1494 		pThis->m_ConvAttr.m_Status.m_nLineSpacing	= nLineSpacing ;
1495 
1496 		if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusArea &&
1497 			pThis->m_wgTopMinibufFrame != NULL &&
1498 			pThis->m_wgTopFrame != pThis->m_wgTopMinibufFrame) {
1499 			TConversionAttribute	ca ;
1500 
1501 			TConvAttr_Initialize (&ca) ;
1502 			SET_CONVATTR_MASK (ca, CAPreeditMask) ;
1503 			SET_CONVATTR_PREEDIT_MASK (ca, CALineSpacing) ;
1504 			ca.m_Status.m_nLineSpacing	= nLineSpacing ;
1505 			TFrame_SetAttribute (pThis->m_wgTopMinibufFrame, &ca) ;
1506 			TConvAttr_Uninitialize (&ca) ;
1507 		}
1508 	}
1509 	return	True ;
1510 }
1511 
1512 Boolean
XIMInputContext_SetStatusCursor(register XIMInputContext * pThis,register Cursor cursor)1513 XIMInputContext_SetStatusCursor (
1514 	register XIMInputContext*	pThis,
1515 	register Cursor				cursor)
1516 {
1517 	assert (pThis != NULL) ;
1518 	return	True ;
1519 }
1520 
1521 /*
1522  *(�ؿ�̾)
1523  *	virtual bool	GetStatusArea (XRectangle* pArea) const ;
1524  *(������)
1525  *	Preedt Area ���礭�����֤���
1526  *	��Client Window ���ꥵ������ȯ�Ԥ��Ƥ���ʤ��� Status Area
1527  *	�θ��ߤ��礭�������������Ĥ��ȤϤǤ��ʤ���
1528  *	�������Ĥɤ���褹�٤�����(���⤽��ꥵ������������ä�ñ��
1529  *	���ΰ���������ʤ����⤢�������)
1530  */
1531 Boolean
XIMInputContext_GetStatusArea(register XIMInputContext * pThis,register XRectangle * pRect)1532 XIMInputContext_GetStatusArea (
1533 	register XIMInputContext*	pThis,
1534 	register XRectangle*		pRect)
1535 {
1536 	assert (pThis != NULL) ;
1537 	assert (pRect != NULL) ;
1538 	if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusNothing)
1539 		return	False ;
1540 
1541 	if (IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) &&
1542 		IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientArea)) {
1543 		memcpy (pRect, &pThis->m_ConvAttr.m_Status.m_area, sizeof (XRectangle)) ;
1544 	} else {
1545 		if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusArea &&
1546 			IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientAreaNeeded)) {
1547 			memcpy (pRect, &pThis->m_ConvAttr.m_Status.m_areaNeeded, sizeof (XRectangle)) ;
1548 		} else {
1549 			register int	nLineSpacing ;
1550 
1551 			pRect->x	= 0 ;
1552 			pRect->y	= 0 ;
1553 			nLineSpacing	= XIMInputContext_GetStatusLineSpacing (pThis) ;
1554 			if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditPosition){
1555 				/*	���⤽�� line spacing �ä����ꤵ��Ƥʤ����顢�����Ͻ�������
1556 				 *	ɬ�פ����롣*/
1557 				pRect->width	= nLineSpacing * 80 / 2 ;
1558 			} else {
1559 				pRect->width	= nLineSpacing * 7 / 2 ;
1560 			}
1561 			pRect->height	= nLineSpacing ;
1562 		}
1563 	}
1564 	return	True ;
1565 }
1566 
1567 /*
1568  *(�ؿ�̾)
1569  *	virtual bool	GetStatusAreaNeeded (XRectangle* pArea) const ;
1570  *(������)
1571  *	ɬ�פȤ��� Status Area ���礭���������֤��ʤ���Фʤ�ʤ���
1572  *	�ɤ����٤ο��ͤ������ʤΤ��������ġ�
1573  *	�ޤ��������ͤ�����Ƥ��ޤ��٤��ʤΤ��Ĥ���Ȥ⤳�������ɬ�פ�
1574  *	�����Ǿ��ͤ�����Ƥ��ޤ��٤��ʤΤ��ġ�
1575  */
1576 Boolean
XIMInputContext_GetStatusAreaNeeded(register XIMInputContext * pThis,register XRectangle * pRect)1577 XIMInputContext_GetStatusAreaNeeded (
1578 	register XIMInputContext*	pThis,
1579 	register XRectangle*		pRect)
1580 {
1581 	assert (pThis != NULL) ;
1582 	if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusNothing)
1583 		return	False ;
1584 	if (IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) &&
1585 		IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAClientAreaNeeded)) {
1586 		memcpy (pRect, &pThis->m_ConvAttr.m_Status.m_areaNeeded, sizeof (XRectangle)) ;
1587 	} else {
1588 		register int	nLineSpacing ;
1589 		pRect->x		= 0 ;
1590 		pRect->y		= 0 ;
1591 		nLineSpacing	= XIMInputContext_GetStatusLineSpacing (pThis) ;
1592 		if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditPosition){
1593 			pRect->width	= nLineSpacing * 80 / 2 ;
1594 		} else {
1595 			pRect->width	= nLineSpacing * 7 / 2 ;
1596 		}
1597 		pRect->height	= nLineSpacing ;
1598 	}
1599 	return	True ;
1600 }
1601 
1602 /*
1603  *(�ؿ�̾)
1604  *	virtual const Colormap&	GetStatusColormap () const ;
1605  *(������)
1606  *	StatusArea �θ��ߤ� Colormap �����롣
1607  *	�ǥե���Ȥ������Τ��Ȥʤ��顢
1608  *		DefaultColormap (display, 0)
1609  *	��ȤäƤ��롣
1610  */
1611 Colormap
XIMInputContext_GetStatusColormap(register XIMInputContext * pThis)1612 XIMInputContext_GetStatusColormap (
1613 	register XIMInputContext*	pThis)
1614 {
1615 	assert (pThis != NULL) ;
1616 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask) ||
1617 		!IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CAColormap))
1618 		return	None ;
1619 	return	pThis->m_ConvAttr.m_Status.m_colormap ;
1620 }
1621 
1622 /*
1623  *(�ؿ�̾)
1624  *	virtual const Colormap&	GetStatusColormap () const ;
1625  *(������)
1626  *	StatusArea �� Standard Colormap �����롣
1627  *	�ǥե���Ȥ������Τ��Ȥʤ��顢
1628  *		DefaultColormap (display, 0)
1629  *	��ȤäƤ��롣
1630  */
1631 Atom
XIMInputContext_GetStatusStdColormap(register XIMInputContext * pThis)1632 XIMInputContext_GetStatusStdColormap (
1633 	register XIMInputContext*	pThis)
1634 {
1635 	assert (pThis != NULL) ;
1636 	return	pThis->m_atSStdColormap ;
1637 }
1638 
1639 unsigned long
XIMInputContext_GetStatusForeground(register XIMInputContext * pThis)1640 XIMInputContext_GetStatusForeground (
1641 	register XIMInputContext*	pThis)
1642 {
1643 	assert (pThis != NULL) ;
1644 	return	pThis->m_ConvAttr.m_Status.m_foreground ;
1645 }
1646 
1647 unsigned long
XIMInputContext_GetStatusBackground(register XIMInputContext * pThis)1648 XIMInputContext_GetStatusBackground (
1649 	register XIMInputContext*	pThis)
1650 {
1651 	assert (pThis != NULL) ;
1652 	return	pThis->m_ConvAttr.m_Status.m_background ;
1653 }
1654 
1655 Pixmap
XIMInputContext_GetStatusBackgroundPixmap(register XIMInputContext * pThis)1656 XIMInputContext_GetStatusBackgroundPixmap (
1657 	register XIMInputContext*	pThis)
1658 {
1659 	assert (pThis != NULL) ;
1660 	return	pThis->m_ConvAttr.m_Status.m_pixBackground ;
1661 }
1662 
1663 const char*
XIMInputContext_GetStatusFontSet(register XIMInputContext * pThis)1664 XIMInputContext_GetStatusFontSet (
1665 	register XIMInputContext*	pThis)
1666 {
1667 	assert (pThis != NULL) ;
1668 	return	TVarbuffer_GetBuffer (&pThis->m_vbufSFontSetName) ;
1669 }
1670 
1671 /*
1672  *
1673  */
1674 int
XIMInputContext_GetStatusLineSpacing(register XIMInputContext * pThis)1675 XIMInputContext_GetStatusLineSpacing (
1676 	register XIMInputContext*	pThis)
1677 {
1678 	assert (pThis != NULL) ;
1679 
1680 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask))
1681 		return	DEFAULT_XIM_STATUS_LINESPACING ;
1682 
1683 	if (IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CALineSpacing))
1684 		return	pThis->m_ConvAttr.m_Status.m_nLineSpacing ;
1685 
1686 	if (!IS_CONVATTR_STATUS_MASK (pThis->m_ConvAttr, CAFont))
1687 		return	DEFAULT_XIM_STATUS_LINESPACING ;
1688 
1689 	return	TFontSet_GetHeight (&pThis->m_ConvAttr.m_Status.m_FontSet) ;
1690 }
1691 
1692 Cursor
XIMInputContext_GetStatusCursor(register XIMInputContext * pThis)1693 XIMInputContext_GetStatusCursor (
1694 	register XIMInputContext*	pThis)
1695 {
1696 	return	pThis->m_ConvAttr.m_Status.m_cursor ;
1697 }
1698 
1699 Boolean
XIMInputContext_SetPreeditAttributes(register XIMInputContext * pThis)1700 XIMInputContext_SetPreeditAttributes (
1701 	register XIMInputContext*	pThis)
1702 {
1703 	TConversionAttribute	ca ;
1704 
1705 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask))
1706 		return	True ;
1707 
1708 	/*	�����Ͼ����ľ��ɬ�פ�����ʡ�ConversionAttribute ��
1709 	 *	������ copy ����ؿ����Ѱդ��٤�������*/
1710 	TConvAttr_Initialize (&ca) ;
1711 	TConvAttr_Copy (&ca, &pThis->m_ConvAttr) ;
1712 	CLR_CONVATTR_MASK (ca) ;
1713 	SET_CONVATTR_MASK (ca, CAPreeditMask) ;
1714 	TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
1715 	TConvAttr_Uninitialize (&ca) ;
1716 	return	True ;
1717 }
1718 
1719 Boolean
XIMInputContext_SetStatusAttributes(register XIMInputContext * pThis)1720 XIMInputContext_SetStatusAttributes (
1721 	register XIMInputContext*	pThis)
1722 {
1723 	TConversionAttribute	ca ;
1724 
1725 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAStatusMask))
1726 		return	True ;
1727 
1728 	/*	�����Ͼ����ľ��ɬ�פ�����ʡ�ConversionAttribute ��
1729 	 *	������ copy ����ؿ����Ѱդ��٤�������*/
1730 	TConvAttr_Initialize (&ca) ;
1731 	TConvAttr_Copy (&ca, &pThis->m_ConvAttr) ;
1732 	CLR_CONVATTR_MASK (ca) ;
1733 	SET_CONVATTR_MASK (ca, CAStatusMask) ;
1734 	TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
1735 	TConvAttr_Uninitialize (&ca) ;
1736 	return	True ;
1737 }
1738 
1739 Boolean
XIMInputContext_Activate(register XIMInputContext * pThis,register Boolean fActive)1740 XIMInputContext_Activate (
1741 	register XIMInputContext*		pThis,
1742 	register Boolean				fActive)
1743 {
1744 	assert (pThis != NULL) ;
1745 	assert (pThis->m_wgTopFrame != NULL) ;
1746 
1747 	TLispClient_Activate (&pThis->m_LispClient, fActive) ;
1748 	if (fActive)
1749 		TLispClient_SetModificationFlag (&pThis->m_LispClient, True) ;
1750 	return	True ;
1751 }
1752 
1753 Boolean
ximInputContext_createFrame(register XIMInputContext * pThis)1754 ximInputContext_createFrame (
1755 	register XIMInputContext*	pThis)
1756 {
1757 	register Widget	wgTop, wgFrame ;
1758 	register Window	wndFocus ;
1759 	Widget			wgMinibufFrame ;
1760 	Arg				rArg [12] ;
1761 	register int	nArg ;
1762 
1763 	nArg		= 0 ;
1764 	XtSetArg (rArg [nArg], XtNmappedWhenManaged,	False) ; nArg ++ ;
1765 	XtSetArg (rArg [nArg], XtNclientWindow,			pThis->m_wndClient) ; nArg ++ ;
1766 	if (!IS_CONVATTR_MASK (pThis->m_ConvAttr, CAFocusWindow)) {
1767 		wndFocus	= pThis->m_wndClient ;
1768 	} else {
1769 		wndFocus	= pThis->m_ConvAttr.m_wndFocus ;
1770 	}
1771 	XtSetArg (rArg [nArg], XtNfocusWindow,	wndFocus) ; nArg ++ ;
1772 	XtSetArg (rArg [nArg], XtNinput,		False) ;	nArg ++ ;
1773 
1774 	wgTop	= AfxGetToplevelWidget () ;
1775 	switch (pThis->m_dwInputStyle & XIMPreeditMask) {
1776 	case	XIMPreeditPosition:
1777 		wgFrame	= TOverTheSpotWindowFrame_Create (wgTop, rArg, nArg) ;
1778 		break ;
1779 	case	XIMPreeditArea:
1780 		wgFrame	= TOffTheSpotWindowFrame_Create (wgTop, rArg, nArg) ;
1781 		break ;
1782 	case	XIMPreeditCallbacks:
1783 		wgFrame	= TOnTheSpotWindowFrame_Create (wgTop, rArg, nArg) ;
1784 		break ;
1785 	case	XIMPreeditNothing:
1786 	case	XIMPreeditNone:
1787 	default:
1788 		wgFrame	= TRootWindowFrame_Create (wgTop, rArg, nArg) ;
1789 		break ;
1790 	}
1791 	if (wgFrame == NULL)
1792 		return	False ;
1793 
1794 	pThis->m_wgTopFrame	= wgFrame ;
1795 
1796 	if (IS_CONVATTR_MASK (pThis->m_ConvAttr, CAPreeditMask) &&
1797 		IS_CONVATTR_PREEDIT_MASK (pThis->m_ConvAttr, CASpotLocation)) {
1798 		TConversionAttribute	ca ;
1799 
1800 		TConvAttr_Initialize (&ca) ;
1801 		SET_CONVATTR_MASK (ca, CAPreeditMask) ;
1802 		SET_CONVATTR_PREEDIT_MASK (ca, CASpotLocation) ;
1803 		memcpy (&ca.m_Preedit.m_spot, &pThis->m_ConvAttr.m_Preedit.m_spot, sizeof (XPoint)) ;
1804 		TFrame_SetAttribute (pThis->m_wgTopFrame, &ca) ;
1805 		TConvAttr_Uninitialize (&ca) ;
1806 	}
1807 	XIMInputContext_SetPreeditAttributes (pThis) ;
1808 	XIMInputContext_SetStatusAttributes  (pThis) ;
1809 
1810 	ximInputContext_addFrameCallbacks (pThis, wgFrame) ;
1811 	XtRealizeWidget (wgFrame) ;
1812 
1813 	wgMinibufFrame	= NULL ;
1814 	XtVaGetValues (wgFrame, XtNminibufFrame, &wgMinibufFrame, NULL) ;
1815 #if defined (DEBUG)
1816 	fprintf (stderr, "Frame(%p), MinibufFrame(%p)\n", wgFrame, wgMinibufFrame) ;
1817 #endif
1818 	if (wgMinibufFrame != NULL && wgMinibufFrame != wgFrame) {
1819 		ximInputContext_addFrameCallbacks (pThis, wgMinibufFrame) ;
1820 #if defined (DEBUG)
1821 		fprintf (stderr, "MinibufFrame(%p, %d)\n",
1822 				 wgMinibufFrame, XtIsRealized (wgMinibufFrame)) ;
1823 #endif
1824 		XtRealizeWidget (wgMinibufFrame) ;
1825 	}
1826 	pThis->m_wgTopMinibufFrame	= wgMinibufFrame ;
1827 
1828 	ximInputContext_initializeLispPart (pThis, wgFrame, wgMinibufFrame) ;
1829 	XFlush (XtDisplay (wgFrame)) ;
1830 	return	True ;
1831 }
1832 
1833 Boolean
ximInputContext_initializeLispPart(register XIMInputContext * pThis,register Widget wgFrame,register Widget wgMinibufFrame)1834 ximInputContext_initializeLispPart (
1835 	register XIMInputContext*	pThis,
1836 	register Widget				wgFrame,
1837 	register Widget				wgMinibufFrame)
1838 {
1839 	register TLispClient*	pLispClient ;
1840 	register Widget			wgClient ;
1841 	Widget					wgProtocol ;
1842 	Arg						rArg [1] ;
1843 	TLispMachine*			pTopLM ;
1844 	TLispClientArg			arg ;
1845 
1846 	wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
1847 	XtSetArg (rArg [0], XtNprotocolWidget, &wgProtocol) ;
1848 	XtGetValues (wgClient, rArg, 1) ;
1849 	assert (wgProtocol != NULL) ;
1850 
1851 	XtSetArg (rArg [0], XtNlispMachine, &pTopLM) ;
1852 	XtGetValues (wgProtocol, rArg, 1) ;
1853 	assert (pTopLM != NULL) ;
1854 
1855 	pLispClient				= &pThis->m_LispClient ;
1856 	arg.m_pLispMgr			= TLispMachine_GetLispManager (pTopLM) ;
1857 	arg.m_pLM				= pTopLM ;
1858 	arg.m_wgFrame			= wgFrame ;
1859 	arg.m_wgMinibufFrame	= wgMinibufFrame ;
1860 	arg.m_pKeyNotify		= &ximInputContext_onKeyNotify ;
1861 	arg.m_pTextNotify		= &ximInputContext_onTextNotify ;
1862 	arg.m_pEndNotify		= &ximInputContext_onEndNotify ;
1863 	arg.m_pvClient			= pThis ;
1864 	return	TLispClient_Initialize (pLispClient, &arg) ;
1865 }
1866 
1867 /*	XIM_COMMIT �Υѥ��å�Ʊ�Τ�Ϣ�뤹��Τ��������Ԥ����Υѥ��åȤ�
1868  *	�Ĥʤ��ǤϤ����ʤ����Ĥʤ��ȡֲ��ԡפ�����ʤ��ʤ����������Τǡ�
1869  *	Spool ���������ʳ��ǡֲ��ԡפΤߤΥѥ��åȤ�虜�虜�������Ƥ��롣
1870  */
1871 Boolean
ximInputContext_packetToCombinep(register XIMPacket * pPacket)1872 ximInputContext_packetToCombinep (
1873 	register XIMPacket*			pPacket)
1874 {
1875 	XIMData					imData ;
1876 	int						nMajor ;
1877 	register unsigned int	uBitMask ;
1878 
1879 	assert (pPacket != NULL) ;
1880 
1881 	XIMPacket_GetHeader (pPacket, &nMajor, NULL) ;
1882 	if (nMajor != XIM_COMMIT)
1883 		return	False ;
1884 	XIMData_Initialize (&imData, XIMPacket_GetData (pPacket), XIMPacket_GetEndian (pPacket)) ;
1885 	XIMData_Forward8  (&imData, XIM_HEADER_SIZE + 2 + 2) ;
1886 	uBitMask	= XIMData_GetCard16 (&imData) ;
1887 	return	(uBitMask & 4)? False : True ;
1888 }
1889 
1890 XIMPacket*
ximInputContext_combineXimCommit(register XIMInputContext * pThis,register XIMPacket * pSrcPacket1,register XIMPacket * pSrcPacket2)1891 ximInputContext_combineXimCommit (
1892 	register XIMInputContext*	pThis,
1893 	register XIMPacket*			pSrcPacket1,
1894 	register XIMPacket*			pSrcPacket2)
1895 {
1896 	register XIMPacket*	pPacket ;
1897 	XIMData			imSrc ;
1898 	register int	nctext, nctotal, nIndex ;
1899 	CARD16			uMask ;
1900 
1901 	assert (pThis != NULL) ;
1902 	assert (pSrcPacket1 != NULL) ;
1903 	assert (pSrcPacket2 != NULL) ;
1904 
1905 	pPacket	= XIMPacket_Create (XIMPacket_GetEndian (pSrcPacket1)) ;
1906 	if (pPacket == NULL)
1907 		return	NULL ;
1908 #if defined (DEBUG)
1909 	fprintf (stderr, "Combine X_COMMIT\n") ;
1910 	fprintf (stderr, "Packet1:\n") ;
1911 	XIMPacket_Show (pSrcPacket1) ;
1912 	fprintf (stderr, "Packet2:\n") ;
1913 	XIMPacket_Show (pSrcPacket2) ;
1914 #endif
1915 	XIMPacket_SetHeader (pPacket, XIM_COMMIT, 0) ;
1916 	XIMPacket_AddCard16 (pPacket, XIMInputMethod_GetID  (pThis->m_pInputMethod)) ;
1917 	XIMPacket_AddCard16 (pPacket, XIMInputContext_GetID (pThis)) ;
1918 	XIMPacket_SetInputContext (pPacket, pThis) ;
1919 	XIMPacket_SetSyncMode  (pPacket, XIMPacket_GetSyncMode (pSrcPacket1)) ;
1920 	XIMPacket_GetCard16    (pSrcPacket1, XIM_HEADER_SIZE + 2 + 2, &uMask) ;
1921 	XIMPacket_AddBitmask16 (pPacket, uMask) ;
1922 	nIndex	= XIMPacket_GetDataSize (pPacket) ;
1923 	XIMPacket_AddCard16 (pPacket, 0 /* dummy */) ;
1924 
1925 	XIMData_Initialize (&imSrc, XIMPacket_GetData (pSrcPacket1), XIMPacket_GetEndian (pSrcPacket1)) ;
1926 	XIMData_Forward8  (&imSrc, XIM_HEADER_SIZE) ;
1927 	XIMData_Forward16 (&imSrc, 3 /* IMID + IMIC + Bitmask16 */) ;
1928 	nctext	= XIMData_GetCard16 (&imSrc) ;
1929 	nctotal	= nctext ;
1930 	XIMPacket_AddString8 (pPacket, XIMData_GetHead (&imSrc), nctext) ;
1931 
1932 	XIMData_Initialize (&imSrc, XIMPacket_GetData (pSrcPacket2), XIMPacket_GetEndian (pSrcPacket2)) ;
1933 	XIMData_Forward8  (&imSrc, XIM_HEADER_SIZE) ;
1934 	XIMData_Forward16 (&imSrc, 3 /* IMID + IMIC + Bitmask16 */) ;
1935 	nctext	= XIMData_GetCard16 (&imSrc) ;
1936 	nctotal	+= nctext ;
1937 	XIMPacket_AddString8 (pPacket, XIMData_GetHead (&imSrc), nctext) ;
1938 	XIMPacket_AddPad (pPacket, nctotal) ;
1939 	XIMPacket_SetCard16 (pPacket, nIndex, nctotal) ;
1940 	XIMPacket_SetLength (pPacket) ;
1941 #if defined (DEBUG)
1942 	fprintf (stderr, "Result Packet:\n") ;
1943 	XIMPacket_Show (pPacket) ;
1944 #endif
1945 	return	pPacket ;
1946 }
1947 
1948 void
ximInputContext_addFrameCallbacks(register XIMInputContext * pThis,register Widget wgFrame)1949 ximInputContext_addFrameCallbacks (
1950 	register XIMInputContext*	pThis,
1951 	register Widget				wgFrame)
1952 {
1953 	assert (pThis != NULL) ;
1954 	assert (wgFrame != NULL) ;
1955 
1956 	XtAddCallback (wgFrame, XtNkeyPressCallback,	ximInputContext_onKeyPress,		(XtPointer)pThis) ;
1957 	XtAddCallback (wgFrame, XtNconfigureCallback,	ximInputContext_onFrameConfigure,	(XtPointer)pThis) ;
1958 	XtAddCallback (wgFrame, XtNdestroyCallback,		ximInputContext_onFrameDestroy,	(XtPointer)pThis) ;
1959 
1960 	if (XtIsSubclass (wgFrame, tonTheSpotWindowWidgetClass)) {
1961 		if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditCallbacks) {
1962 			XtAddCallback (wgFrame, XtNpreeditStartCallback, ximInputContext_onPreeditStart, (XtPointer) pThis) ;
1963 			XtAddCallback (wgFrame, XtNpreeditDrawCallback,  ximInputContext_onPreeditDraw,  (XtPointer) pThis) ;
1964 			XtAddCallback (wgFrame, XtNpreeditCaretCallback, ximInputContext_onPreeditCaret, (XtPointer) pThis) ;
1965 			XtAddCallback (wgFrame, XtNpreeditDoneCallback,  ximInputContext_onPreeditDone,  (XtPointer) pThis) ;
1966 		}
1967 		if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusCallbacks) {
1968 			XtAddCallback (wgFrame, XtNstatusStartCallback, ximInputContext_onStatusStart, (XtPointer) pThis) ;
1969 			XtAddCallback (wgFrame, XtNstatusDrawCallback,  ximInputContext_onStatusDraw,  (XtPointer) pThis) ;
1970 			XtAddCallback (wgFrame, XtNstatusDoneCallback,  ximInputContext_onStatusDone,  (XtPointer) pThis) ;
1971 		}
1972 	}
1973 	return ;
1974 }
1975 
1976 void
ximInputContext_removeFrameCallbacks(register XIMInputContext * pThis,register Widget wgFrame)1977 ximInputContext_removeFrameCallbacks (
1978 	register XIMInputContext*	pThis,
1979 	register Widget				wgFrame)
1980 {
1981 	XtRemoveAllCallbacks (wgFrame, XtNkeyPressCallback) ;
1982 	XtRemoveAllCallbacks (wgFrame, XtNconfigureCallback) ;
1983 	XtRemoveAllCallbacks (wgFrame, XtNdestroyCallback) ;
1984 
1985 	if (XtIsSubclass (wgFrame, tonTheSpotWindowWidgetClass)) {
1986 		if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditCallbacks) {
1987 			XtRemoveAllCallbacks (wgFrame, XtNpreeditStartCallback) ;
1988 			XtRemoveAllCallbacks (wgFrame, XtNpreeditDrawCallback) ;
1989 			XtRemoveAllCallbacks (wgFrame, XtNpreeditCaretCallback) ;
1990 			XtRemoveAllCallbacks (wgFrame, XtNpreeditDoneCallback) ;
1991 		}
1992 		if ((pThis->m_dwInputStyle & XIMStatusMask) == XIMStatusCallbacks) {
1993 			XtRemoveAllCallbacks (wgFrame, XtNstatusStartCallback) ;
1994 			XtRemoveAllCallbacks (wgFrame, XtNstatusDrawCallback) ;
1995 			XtRemoveAllCallbacks (wgFrame, XtNstatusDoneCallback) ;
1996 		}
1997 	}
1998 	return ;
1999 }
2000 
2001 void
ximInputContext_onKeyPress(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2002 ximInputContext_onKeyPress (
2003 	register Widget		wgFrame,
2004 	register XtPointer	closure,
2005 	register XtPointer	call_data)
2006 {
2007 	register XIMInputContext*	pThis	= (XIMInputContext *) closure ;
2008 
2009 	TLispMachine_EventProc (pThis->m_LispClient.m_pLM, LMEVENT_KEYPRESS, call_data, 0) ;
2010 	TLispClient_SetModificationFlag (&pThis->m_LispClient, True) ;
2011 	return ;
2012 }
2013 
2014 void
ximInputContext_onFrameConfigure(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2015 ximInputContext_onFrameConfigure (
2016 	register Widget		wgFrame,
2017 	register XtPointer	closure,
2018 	register XtPointer	call_data)
2019 {
2020 	register XIMInputContext*	pThis	= (XIMInputContext *) closure ;
2021 	TLispEntity*	pEntFrame	= NULL ;
2022 
2023 #if defined (DEBUG)
2024 	fprintf (stderr, "ximInputContext_onFrameConfigure(%p): destroyed.\n", wgFrame) ;
2025 #endif
2026 	pEntFrame	= TFrame_GetLispFrameObject (wgFrame) ;
2027 	assert (pEntFrame != NULL) ;
2028 	TLispMachine_EventProc (pThis->m_LispClient.m_pLM, LMEVENT_FRAMERESIZE, pEntFrame, call_data) ;
2029 	TLispClient_SetModificationFlag (&pThis->m_LispClient, True) ;
2030 
2031 #if 0
2032 	/*	XIM_GEOMETRY �����롣���Υ����ߥ����ɤ��Τ����������*/
2033 	if ((pThis->m_dwInputStyle) & XIMPreeditMask == XIMPreeditArea ||
2034 		(pThis->m_dwInputStyle) & XIMStatusMask  == XIMStatusArea) {
2035 		register Widget		wgClient ;
2036 		register int		nMethodId ;
2037 
2038 		wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2039 		nMethodId	= XIMInputMethod_GetID     (pThis->m_pInputMethod) ;
2040 		XIMClient_WriteXimGeomtery (wgClient, nMethodId, pThis->m_woID) ;
2041 	}
2042 #endif
2043 	return ;
2044 }
2045 
2046 void
ximInputContext_onFrameDestroy(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2047 ximInputContext_onFrameDestroy (
2048 	register Widget		wgFrame,
2049 	register XtPointer	closure,
2050 	register XtPointer	call_data)
2051 {
2052 	register XIMInputContext*	pThis	= (XIMInputContext *) closure ;
2053 #if defined (DEBUG)
2054 	fprintf (stderr, "ximInputContext_onFrameDestroy(%p): destroyed.\n", wgFrame) ;
2055 #endif
2056 	ximInputContext_removeFrameCallbacks (pThis, wgFrame) ;
2057 	if (wgFrame == pThis->m_wgTopFrame)
2058 		pThis->m_wgTopFrame	= NULL ;
2059 	if (wgFrame == pThis->m_wgTopMinibufFrame)
2060 		pThis->m_wgTopMinibufFrame	= NULL ;
2061 	/*	���Ȥ������Բ�ǽ�ˤʤäƤ��뤳�Ȥ�Ͽ���롣*/
2062 	pThis->m_fDestroy	= True ;
2063 	return ;
2064 }
2065 
2066 void
ximInputContext_onPreeditStart(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2067 ximInputContext_onPreeditStart (
2068 	register Widget		wgFrame,
2069 	register XtPointer	closure,
2070 	register XtPointer	call_data)
2071 {
2072 	register XIMInputContext*	pThis	= (XIMInputContext*) closure ;
2073 	register Widget				wgClient ;
2074 	register int				nInputMethodID ;
2075 
2076 	assert (wgFrame != NULL) ;
2077 	assert (pThis   != NULL) ;
2078 
2079 #if defined (DEBUG) || 0
2080 	fprintf (stderr, "ximInputContext_onPreeditStart (%p, %p, %p)\n",
2081 			 wgFrame, closure, call_data) ;
2082 #endif
2083 	wgClient		= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2084 	nInputMethodID	= XIMInputMethod_GetID (pThis->m_pInputMethod) ;
2085 	XIMClient_WritePreeditStart (wgClient, nInputMethodID, pThis) ;
2086 	return ;
2087 }
2088 
2089 void
ximInputContext_onPreeditDraw(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2090 ximInputContext_onPreeditDraw (
2091 	register Widget		wgFrame,
2092 	register XtPointer	closure,
2093 	register XtPointer	call_data)
2094 {
2095 	register XIMInputContext*	pThis	= (XIMInputContext*) closure ;
2096 	register Widget				wgClient ;
2097 	register int				nInputMethodID ;
2098 	register const TOnTheSpotDrawArg*	pArg ;
2099 
2100 	assert (wgFrame != NULL) ;
2101 	assert (pThis   != NULL) ;
2102 
2103 #if defined (DEBUG) || 0
2104 	fprintf (stderr, "ximInputContext_onPreeditDraw (%p, %p, %p)\n",
2105 			 wgFrame, closure, call_data) ;
2106 #endif
2107 
2108 	wgClient		= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2109 	pArg			= (const TOnTheSpotDrawArg *)call_data ;
2110 	assert (wgClient != NULL) ;
2111 	assert (pArg     != NULL) ;
2112 	nInputMethodID	= XIMInputMethod_GetID (pThis->m_pInputMethod) ;
2113 	XIMClient_WritePreeditDraw (wgClient, nInputMethodID, pThis, pArg) ;
2114 	return ;
2115 }
2116 
2117 void
ximInputContext_onPreeditCaret(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2118 ximInputContext_onPreeditCaret (
2119 	register Widget		wgFrame,
2120 	register XtPointer	closure,
2121 	register XtPointer	call_data)
2122 {
2123 	register XIMInputContext*	pThis	= (XIMInputContext*) closure ;
2124 	register Widget				wgClient ;
2125 	register int				nInputMethodID ;
2126 	register const TOnTheSpotDrawArg*	pArg ;
2127 
2128 	assert (wgFrame != NULL) ;
2129 	assert (pThis   != NULL) ;
2130 
2131 #if defined (DEBUG) || 0
2132 	fprintf (stderr, "ximInputContext_onPreeditCaret (%p, %p, %p)\n",
2133 			 wgFrame, closure, call_data) ;
2134 #endif
2135 	wgClient		= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2136 	pArg			= (const TOnTheSpotDrawArg *)call_data ;
2137 	assert (wgClient != NULL) ;
2138 	assert (pArg     != NULL) ;
2139 	nInputMethodID	= XIMInputMethod_GetID (pThis->m_pInputMethod) ;
2140 	XIMClient_WritePreeditCaret (wgClient, nInputMethodID, pThis, pArg) ;
2141 	return ;
2142 }
2143 
2144 void
ximInputContext_onPreeditDone(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2145 ximInputContext_onPreeditDone (
2146 	register Widget		wgFrame,
2147 	register XtPointer	closure,
2148 	register XtPointer	call_data)
2149 {
2150 	register XIMInputContext*	pThis	= (XIMInputContext*) closure ;
2151 	register Widget				wgClient ;
2152 	register int				nInputMethodID ;
2153 
2154 	assert (wgFrame != NULL) ;
2155 	assert (pThis   != NULL) ;
2156 
2157 #if defined (DEBUG) || 0
2158 	fprintf (stderr, "ximInputContext_onPreeditDone (%p, %p, %p)\n",
2159 			 wgFrame, closure, call_data) ;
2160 #endif
2161 	wgClient		= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2162 	nInputMethodID	= XIMInputMethod_GetID (pThis->m_pInputMethod) ;
2163 	XIMClient_WritePreeditDone (wgClient, nInputMethodID, pThis) ;
2164 	return ;
2165 }
2166 
2167 void
ximInputContext_onStatusStart(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2168 ximInputContext_onStatusStart (
2169 	register Widget		wgFrame,
2170 	register XtPointer	closure,
2171 	register XtPointer	call_data)
2172 {
2173 	register XIMInputContext*	pThis	= (XIMInputContext*) closure ;
2174 	register Widget				wgClient ;
2175 	register int				nInputMethodID ;
2176 
2177 	assert (wgFrame != NULL) ;
2178 	assert (pThis   != NULL) ;
2179 
2180 	wgClient		= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2181 	nInputMethodID	= XIMInputMethod_GetID (pThis->m_pInputMethod) ;
2182 	XIMClient_WriteStatusStart (wgClient, nInputMethodID, pThis) ;
2183 	return ;
2184 }
2185 
2186 void
ximInputContext_onStatusDraw(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2187 ximInputContext_onStatusDraw (
2188 	register Widget		wgFrame,
2189 	register XtPointer	closure,
2190 	register XtPointer	call_data)
2191 {
2192 	register XIMInputContext*	pThis	= (XIMInputContext*) closure ;
2193 	register Widget				wgClient ;
2194 	register int				nInputMethodID ;
2195 	register const TOnTheSpotDrawArg*	pArg ;
2196 
2197 	assert (wgFrame != NULL) ;
2198 	assert (pThis   != NULL) ;
2199 
2200 	wgClient		= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2201 	pArg			= (const TOnTheSpotDrawArg *)call_data ;
2202 	assert (wgClient != NULL) ;
2203 	assert (pArg     != NULL) ;
2204 	nInputMethodID	= XIMInputMethod_GetID (pThis->m_pInputMethod) ;
2205 	XIMClient_WriteStatusDraw (wgClient, nInputMethodID, pThis, pArg) ;
2206 	return ;
2207 }
2208 
2209 void
ximInputContext_onStatusDone(register Widget wgFrame,register XtPointer closure,register XtPointer call_data)2210 ximInputContext_onStatusDone (
2211 	register Widget		wgFrame,
2212 	register XtPointer	closure,
2213 	register XtPointer	call_data)
2214 {
2215 	register XIMInputContext*	pThis	= (XIMInputContext*) closure ;
2216 	register Widget				wgClient ;
2217 	register int				nInputMethodID ;
2218 
2219 	assert (wgFrame != NULL) ;
2220 	assert (pThis   != NULL) ;
2221 
2222 	wgClient		= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2223 	nInputMethodID	= XIMInputMethod_GetID (pThis->m_pInputMethod) ;
2224 	XIMClient_WriteStatusDone (wgClient, nInputMethodID, pThis) ;
2225 	return ;
2226 }
2227 
2228 void
ximInputContext_onKeyNotify(register void * pvClient,register TXEvent * pEv)2229 ximInputContext_onKeyNotify (
2230 	register void*			pvClient,
2231 	register TXEvent*		pEv)
2232 {
2233 	register XIMInputContext*	pThis		= (XIMInputContext *)pvClient ;
2234 	register Widget				wgClient ;
2235 	register Display*			pDisplay ;
2236 	register Window				wndFocus ;
2237 	register Char				cc ;
2238 	Window						wndRoot, wndChild ;
2239 	int							nRootX, nRootY, nX, nY ;
2240 	unsigned int				uKeyCode, uState, uMask ;
2241 	XEvent						ev ;
2242 	struct timeval				t ;
2243 	struct timezone				tz ;
2244 
2245 	wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2246 	pDisplay	= XtDisplay (wgClient) ;
2247 
2248 	if (!pEv->m_fChar) {
2249 		XIMClient_ForwardEvent (wgClient, pThis->m_pInputMethod, pThis, (XEvent *)pEv->u.m_pEv) ;
2250 		return ;
2251 	}
2252 	cc	= pEv->u.m_ch ;
2253 
2254 	if (pThis->m_wndKeyFocus != None) {
2255 		wndFocus	= pThis->m_wndKeyFocus ;
2256 	} else {
2257 		if (IS_CONVATTR_MASK (pThis->m_ConvAttr, CAFocusWindow)) {
2258 			wndFocus	= pThis->m_ConvAttr.m_wndFocus ;
2259 		} else {
2260 			wndFocus	= pThis->m_wndClient ;
2261 		}
2262 	}
2263 	/*	Ʊ�� Screen ��̵�����ˤϸ��㲽���ġ�*/
2264 	if (!XQueryPointer (pDisplay, wndFocus, &wndRoot, &wndChild, &nRootX, &nRootY, &nX, &nY, &uMask))
2265 		return ;
2266 
2267 	if (TFAILED (cchar2keycode (pDisplay, cc, &uKeyCode, &uState))) {
2268 		Char	ch	= cc ;
2269 		/*	Guess �˼��Ԥ������ˤ� key-event �Ȥ������뤳�Ȥ�
2270 		 *	�Ǥ��ʤ����ƥ����ȤȤ������Ф��롣*/
2271 		ximInputContext_onTextNotify (pvClient, &ch, 1) ;
2272 		return ;
2273 	}
2274 	gettimeofday (&t, &tz) ;
2275 	ev.xkey.type		= KeyPress ;
2276 	ev.xkey.serial		= 0 ;
2277 	ev.xkey.send_event	= False ;
2278 	ev.xkey.display		= pDisplay ;
2279 	ev.xkey.window		= wndFocus ;
2280 	ev.xkey.root		= wndRoot ;
2281 	ev.xkey.subwindow	= wndChild ;
2282 	ev.xkey.time		= (t.tv_sec * 1000) + t.tv_usec ;
2283 	ev.xkey.x			= nX ;
2284 	ev.xkey.y			= nY ;
2285 	ev.xkey.x_root		= nRootX ;
2286 	ev.xkey.y_root		= nRootY ;
2287 	ev.xkey.state		= uState ;
2288 	ev.xkey.keycode		= uKeyCode ;
2289 	ev.xkey.same_screen	= True ;
2290 	XIMClient_ForwardEvent (wgClient, pThis->m_pInputMethod, pThis, (XEvent *)&ev) ;
2291 	return ;
2292 }
2293 
2294 /*
2295  * Kinput Protocol ����Ѵ��׵�Ԥؤ�ʸ����������Ԥ�����δؿ���
2296  *-----
2297  * ʸ���������� SkkInputWidget ����ƽФ���뤿�ᡢcallback�η��ˤʤ�
2298  * �Ƥ��롣�����Ͻ�����;�Ϥ����äѤ����뤱�ɡĤޤ�����괺����ư����
2299  * ���ˤʤäƤ���ľ���ޤ�������
2300  */
2301 void
ximInputContext_onTextNotify(register void * pvClient,register const Char * pText,register int nText)2302 ximInputContext_onTextNotify (
2303 	register void*			pvClient,
2304 	register const Char*	pText,
2305 	register int			nText)
2306 {
2307 	register XIMInputContext*	pThis		= (XIMInputContext *)pvClient ;
2308 	register Widget				wgClient ;
2309 
2310 #if defined (DEBUG) || 0
2311 	fprintf (stderr, "ximInputMethod_onTextNotify (%p, %p, %d)\n", pvClient, pText, nText) ;
2312 #endif
2313 	wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2314 	if ((pThis->m_dwInputStyle & XIMPreeditMask) == XIMPreeditCallbacks &&
2315 		pThis->m_wgTopFrame != NULL) {
2316 		TFrame_Clear (pThis->m_wgTopFrame) ;
2317 		TFrame_Flush (pThis->m_wgTopFrame) ;
2318 	}
2319 	XIMClient_CommitString (wgClient, pThis->m_pInputMethod, pThis, pText, nText) ;
2320 	return ;
2321 }
2322 
2323 void
ximInputContext_onEndNotify(register void * pvClient)2324 ximInputContext_onEndNotify (
2325 	register void*			pvClient)
2326 {
2327 	register XIMInputContext*	pThis		= (XIMInputContext *)pvClient ;
2328 	register Widget				wgClient ;
2329 
2330 #if defined (DEBUG) || 0
2331 	fprintf (stderr, "ximInputMethod_onEndNotify (%p)\n", pvClient) ;
2332 #endif
2333 	wgClient	= XIMInputMethod_GetClient (pThis->m_pInputMethod) ;
2334 	XIMClient_ControlEventFlow (wgClient, pThis->m_pInputMethod, pThis, False) ;
2335 
2336 	XIMInputContext_EndConversion (pThis) ;
2337 	return ;
2338 }
2339 
2340