Пример #1
0
		internal void MoveCurrentCaretPos ()
		{
			if (positionContext == null || ximStyle != styleOverTheSpot || client_window == IntPtr.Zero)
				return;

			int x = positionContext.X;
			int y = positionContext.Y;
			CaretStruct caret = positionContext.Caret;
			IntPtr xic = GetXic (client_window);
			if (xic == IntPtr.Zero)
				return;
			Control control = Control.FromHandle (client_window);
			if (control == null || !control.IsHandleCreated)
				return;
			control = Control.FromHandle (caret.Hwnd);
			if (control == null || !control.IsHandleCreated)
				return;
			Hwnd hwnd = Hwnd.ObjectFromHandle (client_window);
			if (!hwnd.mapped)
				return;

			int dx, dy;
			IntPtr child;
			lock (XlibLock) {
				XplatUIX11.XTranslateCoordinates (display, client_window, client_window, x, y, out dx, out dy, out child);
			}

			XPoint spot = new XPoint ();
			spot.X = (short) dx;
			spot.Y = (short) dy;

			IntPtr pSL = IntPtr.Zero;
			try {
				pSL = Marshal.StringToHGlobalAnsi (XNames.XNSpotLocation);
				IntPtr preedit = XVaCreateNestedList (0, pSL, spot, IntPtr.Zero);
				XSetICValues (xic, XNames.XNPreeditAttributes, preedit, IntPtr.Zero);
			} finally {
				if (pSL != IntPtr.Zero)
					Marshal.FreeHGlobal (pSL);
			}
		}
Пример #2
0
		private static extern IntPtr XVaCreateNestedList (int dummy, IntPtr name0, XPoint value0, IntPtr name1, IntPtr value1, IntPtr terminator);
Пример #3
0
		private IntPtr CreateOverTheSpotXic (IntPtr window, IntPtr xim)
		{
			IntPtr list;
			int count;
			Control c = Control.FromHandle (window);
			string xlfd = String.Format ("-*-*-*-*-*-*-{0}-*-*-*-*-*-*-*", (int) c.Font.Size);
			IntPtr fontSet = XCreateFontSet (display, xlfd, out list, out count, IntPtr.Zero);
			XPoint spot = new XPoint ();
			spot.X = 0;
			spot.Y = 0;
			IntPtr pSL = IntPtr.Zero, pFS = IntPtr.Zero;
			try {
				pSL = Marshal.StringToHGlobalAnsi (XNames.XNSpotLocation);
				pFS = Marshal.StringToHGlobalAnsi (XNames.XNFontSet);
				IntPtr preedit = XVaCreateNestedList (0,
					pSL, spot,
					pFS, fontSet,
					IntPtr.Zero);
				return XCreateIC (xim,
					XNames.XNInputStyle, styleOverTheSpot,
					XNames.XNClientWindow, window,
					XNames.XNPreeditAttributes, preedit,
					IntPtr.Zero);
			} finally {
				if (pSL != IntPtr.Zero)
					Marshal.FreeHGlobal (pSL);
				if (pFS != IntPtr.Zero)
					Marshal.FreeHGlobal (pFS);
				XFreeStringList (list);
				//XplatUIX11.XFree (preedit);
				//XFreeFontSet (fontSet);
			}
		}