예제 #1
0
		internal extern static int Xutf8LookupString(IntPtr xic, ref XEvent xevent, byte [] buffer, int num_bytes, out IntPtr keysym, out XLookupStatus status);
예제 #2
0
		private int LookupString (ref XEvent xevent, int len, out XKeySym keysym, out XLookupStatus status)
		{
			IntPtr keysym_res;
			int res;

			status = XLookupStatus.XLookupNone;
			IntPtr xic = GetXic (client_window);
			if (xic != IntPtr.Zero && have_Xutf8LookupString && xevent.type == XEventName.KeyPress) {
				do {
					try {
						res = Xutf8LookupString (xic, ref xevent, lookup_byte_buffer, 100, out keysym_res,  out status);
					} catch (EntryPointNotFoundException) {
						have_Xutf8LookupString = false;

						// call again, this time we'll go through the non-xic clause
						return LookupString (ref xevent, len, out keysym, out status);
					}
					if (status != XLookupStatus.XBufferOverflow)
						break;
					lookup_byte_buffer = new byte [lookup_byte_buffer.Length << 1];
				} while (true);
				lookup_buffer.Length = 0;
				string s = Encoding.UTF8.GetString (lookup_byte_buffer, 0, res);
				lookup_buffer.Append (s);
				keysym = (XKeySym) keysym_res.ToInt32 ();
				return s.Length;
			} else {
				IntPtr statusPtr = IntPtr.Zero;
				lookup_buffer.Length = 0;
				res = XLookupString (ref xevent, lookup_buffer, len, out keysym_res, out statusPtr);
				keysym = (XKeySym) keysym_res.ToInt32 ();
				return res;
			}
		}