Atspi.Registry.GetAtspiBus C# (CSharp) Method

GetAtspiBus() static private method

static private GetAtspiBus ( ) : NDesk.DBus.Bus
return NDesk.DBus.Bus
        internal static Bus GetAtspiBus()
        {
            string displayName = Environment.GetEnvironmentVariable ("AT_SPI_DISPLAY");
            if (displayName == null || displayName == String.Empty)
                displayName = Environment.GetEnvironmentVariable ("DISPLAY");
            if (displayName == null || displayName == String.Empty)
                displayName = ":0";
            for (int i = displayName.Length - 1; i >= 0; i--) {
                if (displayName [i] == '.') {
                    displayName = displayName.Substring (0, i);
                    break;
                } else if (displayName [i] == ':')
                    break;
            }
            IntPtr display = XOpenDisplay (displayName);
            if (display == IntPtr.Zero)
                return null;
            IntPtr atSpiBus = XInternAtom (display, "AT_SPI_BUS", 0);
            IntPtr actualType, nItems, leftOver;
            int actualFormat;
            string data;
            XGetWindowProperty (display,
                XDefaultRootWindow (display),
                    atSpiBus, (IntPtr) 0,
                    (IntPtr) 2048, 0,
                (IntPtr) 31, out actualType, out actualFormat,
                out nItems, out leftOver, out data);
            if (data == null)
                return null;
            return Bus.Open (data);
        }