isVirtual = OS.XLookupString (xEvent, buffer, buffer.length, keysym, status) == 0;
isVirtual = OS.XLookupString (xEvent, buffer, buffer.length, keysym, null) == 0;
byte [] sendKeyEvent (int type, XKeyEvent xEvent) {		/* Look up the keysym and character(s) */	byte [] buffer;	boolean isVirtual = false;	int [] keysym = new int [1], status = new int [1];	if (xEvent.keycode != 0) {		buffer = new byte [1];		isVirtual = OS.XLookupString (xEvent, buffer, buffer.length, keysym, status) == 0;	} else {		/*		* Bug in Motif. On Linux only, XmImMbLookupString() does not return 		* XBufferOverflow as the status if the buffer is too small. The fix is		* to pass a bigger buffer.		*/		buffer = new byte [512];		int size = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, keysym, status);		if (status [0] == OS.XBufferOverflow) {			buffer = new byte [size];			size = OS.XmImMbLookupString (handle, xEvent, buffer, size, keysym, status);		}		if (size == 0) return null;	}	/*	* Bug in MOTIF.  On Solaris only, XK_F11 and XK_F12 are not	* translated correctly by XLookupString().  They are mapped	* to 0x1005FF10 and 0x1005FF11 respectively.  The fix is to	* look for these values explicitly and correct them.	*/	if (OS.IsSunOS) {		if ((keysym [0] == 0x1005FF10) || (keysym [0] == 0x1005FF11)) {			if (keysym [0] == 0x1005FF10) keysym [0] = OS.XK_F11;			if (keysym [0] == 0x1005FF11) keysym [0] = OS.XK_F12;		}	}		/*	* Bug in MOTIF.  On Solaris only, their is garbage in the	* high 16-bits for Keysyms such as XK_Down.  Since Keysyms	* must be 16-bits to fit into a Character, mask away the	* high 16-bits on all platforms.	*/	keysym [0] &= 0xFFFF;	/* Convert from MBCS to UNICODE and send the event */	/* Use the character encoding for the default locale */	char [] result = Converter.mbcsToWcs (null, buffer);	int index = 0;	while (index < result.length) {		if (result [index] == 0) break;		Event event = new Event ();		event.time = xEvent.time;		event.character = result [index];		if (isVirtual) event.keyCode = Display.translateKey (keysym [0]);		if ((xEvent.state & OS.Mod1Mask) != 0) event.stateMask |= SWT.ALT;		if ((xEvent.state & OS.ShiftMask) != 0) event.stateMask |= SWT.SHIFT;		if ((xEvent.state & OS.ControlMask) != 0) event.stateMask |= SWT.CONTROL;		if ((xEvent.state & OS.Button1Mask) != 0) event.stateMask |= SWT.BUTTON1;		if ((xEvent.state & OS.Button2Mask) != 0) event.stateMask |= SWT.BUTTON2;		if ((xEvent.state & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;		postEvent (type, event);		index++;	}		return buffer;}