예제 #1
0
        static XplatUI()
        {
            // Compose name with current domain id because on Win32 we register class name
            // and name must be unique to process. If we load MWF into multiple appdomains
            // and try to register same class name we fail.
            //			default_class_name = "SWFClass" + System.Threading.Thread.GetDomainID ().ToString ();
            Console.WriteLine("XplatUI constructor");
            if (RunningOnUnix)
            {
                //if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null) {
                //        driver=XplatUIX11_new.GetInstance ();
                //} else
                if (Environment.GetEnvironmentVariable("MONO_MWF_MAC_FORCE_X11") != null)
                {
                    driver = XplatUIX11.GetInstance();
                }
                else
                {
                    IntPtr buf = Marshal.AllocHGlobal(8192);
                    // This is a hacktastic way of getting sysname from uname ()
                    if (uname(buf) != 0)
                    {
                        // WTF: We cannot run uname
                        driver = XplatUIX11.GetInstance();
                    }
                    else
                    {
                        string os = Marshal.PtrToStringAnsi(buf);
                        if (os == "Darwin")
                        {
                            driver = XplatUICarbon.GetInstance();
                        }
                        else
                        {
                            driver = XplatUIX11.GetInstance();
                        }
                    }
                    Marshal.FreeHGlobal(buf);
                }
            }
            else
            {
                //driver=XplatUIWin32.GetInstance ();

                driver = XplatUINanoX.GetInstance();
            }

            driver.InitializeDriver();

            // Initialize things that need to be done after the driver is ready
            DataFormats.GetFormat(0);

            // Signal that the Application loop can be run.
            // This allows UIA to initialize a11y support for MWF
            // before the main loop begins.
            Application.FirePreRun();
        }
예제 #2
0
파일: X11.cs 프로젝트: vkarthim/libpalaso
            /// <summary>
            /// Get mono's internal display handle to the X server
            /// </summary>
            public static IntPtr MonoGetDisplayHandle()
            {
                if (_displayHandleFieldInfo == null)
                {
                    _displayHandleFieldInfo = XplatUIX11.GetField("DisplayHandle",
                                                                  BindingFlags.NonPublic | BindingFlags.Static);
                }

                return((IntPtr)_displayHandleFieldInfo.GetValue(null));
            }
예제 #3
0
        /// <summary>
        /// Get mono's internal display handle to the X server
        /// </summary>
        public static IntPtr MonoGetDisplayHandle()
        {
            if (_displayHandle == null)
            {
                _displayHandle = XplatUIX11.GetField("DisplayHandle",
                                                     System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
            }

            return((IntPtr)_displayHandle.GetValue(null));
        }
예제 #4
0
        /// <summary>
        /// Gets mono's internal Focused Window Ptr/Handle.
        /// </summary>
        public static IntPtr MonoGetFocus()
        {
            if (_focusWindow == null)
            {
                _focusWindow = XplatUIX11.GetField("FocusWindow",
                                                   System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
            }

            // Get static field to determine Focused Window.
            return((IntPtr)_focusWindow.GetValue(null));
        }
예제 #5
0
        static XplatUI()
        {
            // Compose name with current domain id because on Win32 we register class name
            // and name must be unique to process. If we load MWF into multiple appdomains
            // and try to register same class name we fail.
//			default_class_name = "SWFClass" + System.Threading.Thread.GetDomainID ().ToString ();

            if (RunningOnUnix)
            {
#if NO_X11
#if NO_CARBON
                driver = XplatUICocoa.GetInstance();
#else
                driver = XplatUICarbon.GetInstance();
#endif
#else
                //if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null) {
                //        driver=XplatUIX11_new.GetInstance ();
                //} else
                if (Environment.GetEnvironmentVariable("MONO_MWF_MAC_FORCE_X11") != null)
                {
                    driver = XplatUIX11.GetInstance();
                }
                else
                {
                    IntPtr buf = Marshal.AllocHGlobal(8192);
                    // This is a hacktastic way of getting sysname from uname ()
                    if (uname(buf) != 0)
                    {
                        // WTF: We cannot run uname
                        driver = XplatUIX11.GetInstance();
                    }
                    else
                    {
                        string os = Marshal.PtrToStringAnsi(buf);
                        if (os == "Darwin")
#if NO_CARBON
                        { driver = XplatUICocoa.GetInstance(); }
#else
                        { driver = XplatUICarbon.GetInstance(); }
#endif
                        else
                        {
                            driver = XplatUIX11.GetInstance();
                        }
                    }
예제 #6
0
        /// <summary>
        /// Sets XplatUI.State.ModifierKeys, which is what the Control.ModifierKeys WinForm property returns.
        /// </summary>
        public static void SetKeyStateTable(int virtualKey, byte value)
        {
            var keyboard = XplatUIX11.GetField("Keyboard",
                                               System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);

            if (keyboard == null)
            {
                return;
            }

            var key_state_table = X11Keyboard.GetField("key_state_table", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            if (key_state_table == null)
            {
                return;
            }

            var b = (byte[])key_state_table.GetValue(keyboard.GetValue(null));

            b[virtualKey] = value;

            key_state_table.SetValue(keyboard.GetValue(null), b);
        }