public static extern IntPtr XCreateIC(IntPtr xim, string name, XIMProperties im_style, string name2, IntPtr value2, string name3, IntPtr value3, IntPtr terminator);
private IntPtr CreateXic (IntPtr window, IntPtr xim) { IntPtr xic = IntPtr.Zero; foreach (XIMProperties targetStyle in GetMatchingStylesInPreferredOrder (xim)) { ximStyle = targetStyle; // FIXME: use __arglist when it gets working. See bug #321686 switch (targetStyle) { case styleOverTheSpot: xic = CreateOverTheSpotXic (window, xim); if (xic != IntPtr.Zero) break; //Console.WriteLine ("failed to create XIC in over-the-spot mode."); continue; case styleOnTheSpot: // Since .NET/Winforms seems to support only over-the-spot mode,, // I'm not likely to continue on-the-spot implementation. But in // case we need it, this code will be still useful. xic = CreateOnTheSpotXic (window, xim); if (xic != IntPtr.Zero) break; //Console.WriteLine ("failed to create XIC in on-the-spot mode."); continue; case styleRoot: xic = XCreateIC (xim, XNames.XNInputStyle, styleRoot, XNames.XNClientWindow, window, IntPtr.Zero); break; } } // fall back to root mode if all modes failed if (xic == IntPtr.Zero) { ximStyle = styleRoot; xic = XCreateIC (xim, XNames.XNInputStyle, styleRoot, XNames.XNClientWindow, window, XNames.XNFocusWindow, window, IntPtr.Zero); } return xic; }
private XIMProperties [] GetSupportedInputStyles (IntPtr xim) { IntPtr stylesPtr; string ret = XGetIMValues (xim, XNames.XNQueryInputStyle, out stylesPtr, IntPtr.Zero); if (ret != null || stylesPtr == IntPtr.Zero) return new XIMProperties [0]; XIMStyles styles = (XIMStyles) Marshal.PtrToStructure (stylesPtr, typeof (XIMStyles)); XIMProperties [] supportedStyles = new XIMProperties [styles.count_styles]; for (int i = 0; i < styles.count_styles; i++) supportedStyles [i] = (XIMProperties) Marshal.PtrToStructure (new IntPtr ((long) styles.supported_styles + i * Marshal.SizeOf (typeof (IntPtr))), typeof (XIMProperties)); lock (XlibLock) { XplatUIX11.XFree (stylesPtr); } return supportedStyles; }
private XIMProperties [] GetPreferredStyles () { string env = Environment.GetEnvironmentVariable (ENV_NAME_XIM_STYLE); if (env == null) env = "over-the-spot"; string [] list = env.Split (' '); XIMProperties [] ret = new XIMProperties [list.Length]; for (int i = 0; i < list.Length; i++) { string s = list [i]; switch (s) { case "over-the-spot": ret [i] = styleOverTheSpot; break; case "on-the-spot": ret [i] = styleOnTheSpot; break; case "root": ret [i] = styleRoot; break; } } return ret; }
private static extern IntPtr XCreateIC (IntPtr xim, string name, XIMProperties im_style, string name2, IntPtr value2, string name3, IntPtr value3, IntPtr terminator);