コード例 #1
0
        public static X11Clipboard Create()
        {
            IntPtr display  = IntPtr.Zero;
            ulong  windowId = 0;

            try
            {
                display = LibX11.XOpenDisplay(null);
                if (display == IntPtr.Zero)
                {
                    throw new InvalidOperationException("Cannot open display.");
                }

                ulong  rootWindow    = LibX11.XDefaultRootWindow(display);
                int    defaultScreen = LibX11.XDefaultScreen(display);
                IntPtr defaultVisual = LibX11.XDefaultVisual(display, defaultScreen);

                XSetWindowAttributes attr = new XSetWindowAttributes();
                windowId = LibX11.XCreateWindow
                           (
                    display,
                    rootWindow,
                    0, 0,
                    10, 10,
                    0,
                    0,
                    WindowClass.InputOnly,
                    defaultVisual,
                    0,
                    ref attr
                           );

                LibX11.XFlush(display);

                X11Clipboard clipboard = new X11Clipboard(display, windowId);
                clipboard.Start();
                windowId = 0;
                display  = IntPtr.Zero;
                return(clipboard);
            }
            finally
            {
                if (windowId != 0)
                {
                    LibX11.XDestroyWindow(display, windowId);
                    LibX11.XFlush(display);
                }

                if (display != IntPtr.Zero)
                {
                    LibX11.XCloseDisplay(display);
                }
            }
        }
コード例 #2
0
        public void Init()
        {
            LibX11.XInitThreads();
            display = LibX11.XOpenDisplay(null);
            if (display == IntPtr.Zero)
            {
                throw new InvalidOperationException("Cannot open display.");
            }

            WM_PROTOCOLS               = LibX11.XInternAtom(display, "WM_PROTOCOLS", 0);
            WM_DELETE_WINDOW           = LibX11.XInternAtom(display, "WM_DELETE_WINDOW", 0);
            XA_NWINDOWS_PAINT_COMPLETE = LibX11.XInternAtom(display, "NWINDOWS_PAINT_COMPLETE", 0);

            graphics   = X11Graphics.Create(display);
            imageCodec = new GdkPixBufImageCodec(display, graphics.Visual, graphics.RootWindow);
            clipboard  = X11Clipboard.Create();
        }
コード例 #3
0
        public static bool IsAvailable()
        {
            try
            {
                LibX11.XInitThreads();
                IntPtr display = LibX11.XOpenDisplay(null);
                if (display == IntPtr.Zero)
                {
                    return(false);
                }

                LibX11.XCloseDisplay(display);
                return(true);
            }
            catch (DllNotFoundException)
            {
                return(false);
            }
            catch (EntryPointNotFoundException)
            {
                return(false);
            }
        }